File: sprite.h

package info (click to toggle)
epiphany 0.7.0%2B0-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 7,532 kB
  • sloc: cpp: 6,404; ansic: 141; makefile: 78; sh: 7
file content (121 lines) | stat: -rw-r--r-- 2,405 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
                          sprite.h  -  description
                             -------------------
    begin                : Sat Sep 22 2001
    copyright            : (C) 2001 by Giuseppe D'Aqu
    email                : kumber@tiscalinet.it
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License, Version 2, as published by  *
 *   the Free Software Foundation.                                   *
 *                                                                         *
 ***************************************************************************/


#include "dephine.h"
#include "surface.h"

#ifndef SPRITE_H
#define SPRITE_H


enum Anim_State{ SP_STOP=0,
				 SP_UP=k_max_anim,
				 SP_RIGHT=k_max_anim*2,
				 SP_DOWN=k_max_anim*3,
				 SP_LEFT=k_max_anim*4
				 /*, SP_EAT=k_max_anim*5*/};


class Sprite
{

private:

	Surface* m_surface;
	
	Uint32 m_pos_x;
	
	Uint32 m_pos_y;
	
	Uint32 m_move_to_pos_x;
	
	Uint32 m_move_to_pos_y;
	
	Uint32 m_step_x;

	Uint32 m_step_y;

	Uint32 m_speed;
		
	Uint32 m_curr_frame;
	
	bool m_initialized;

	Anim_State m_state;	
	
	Uint32 m_total_frames; 
	
	void put_screen(Sint32 pos_x, Sint32 pos_y, Uint32 size_x, Uint32 size_y, Uint32 frame_num);
	
	void set_curr_frame(Uint32 frame);
	
	void move(Uint32 n_pixel);
	
	Uint32 m_sprite_width;
	
	Uint32 m_sprite_height;
	
public:

	
	
	Sprite():m_initialized(false), m_total_frames(8){};

	Sprite(Surface* surface);
	
	Sprite(const Sprite& sprite);
	
	~Sprite();
	
	void set_speed(Uint32 speed);
		
	void put_screen(Sint32 pos_x, Sint32 pos_y, Uint32 size_x, Uint32 size_y);
	
	
	Uint32 get_pos_x() const
	{
		return m_pos_x;
  	}
	
	Uint32 get_pos_y() const
	{
		return m_pos_y;
 	}
 	
	void set_pos_x(Uint32 x);
	
	void set_pos_y(Uint32 y);
	
	void move_to_pos(Uint32 x, Uint32 y);
	
	void move_to_pos_x(Uint32 x);
	
	void move_to_pos_y(Uint32 y);
	
	void move();
	
	void update_frame();
	
	Uint32 get_frame_number() const;
	
	void init(Surface* surf);
	
	void set_state(Anim_State state);
		
};
	
#endif //SPRITE_H