File: simple_sprite.cc

package info (click to toggle)
ceferino 0.97.8%2Bsvn37-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,916 kB
  • ctags: 744
  • sloc: cpp: 6,120; sh: 423; makefile: 50
file content (78 lines) | stat: -rw-r--r-- 2,086 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Don Ceferino Hazaa - video game similary to Super Pang!
 * Copyright (c) 2004, 2005 Hugo Ruscitti
 * web site: http://www.loosersjuegos.com.ar
 * 
 * This file is part of Don Ceferino Hazaa (ceferino).
 * Written by Hugo Ruscitti <hugoruscitti@yahoo.com.ar>
 *
 * Don Ceferino Hazaa is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Don Ceferino Hazaa is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 */


#include "simple_sprite.h"
#include <stdlib.h>

/*!
 * \brief genera el grafico y se posiciona en la posicion inicial
 */
void simple_sprite :: iniciar(grafico *_ima, int _x_inicial, int _y_inicial, int _x_destino, int _y_destino)
{
	ima = _ima;
	x_destino = _x_destino;
	y_destino = _y_destino;
	x = _x_inicial;
	y = _y_inicial;
}

/*!
 * \brief actualizacion logica de la cadena
 */
void simple_sprite :: actualizar(void)
{

	if (abs(x_destino - x) < 10 && x_destino - x != 0)
		x+= (x_destino - x) / abs(x_destino - x);
	else
		x+= (x_destino - x) / 10;
	

	if (abs(y_destino - y) < 10 && y_destino - y != 0)
		y+= (y_destino - y) / abs(y_destino -y);
	else
		y+= (y_destino - y) / 10;
}


/*!
 * \brief muestra el objeto por pantalla
 */
void simple_sprite :: imprimir(SDL_Surface *screen, SDL_Rect *rect, int *cant_modif)
{
	ima->imprimir(0, screen, rect+*cant_modif, x, y, 1);
	(*cant_modif)++;
}

/*!
 * \brief informa si termin su animacin
 */
int simple_sprite :: termino_anim(void)
{
	if ( (y_destino - y) == 0 && (x_destino - x) == 0)
		return 1;
	else
		return 0;
}