File: tankvehicle.h

package info (click to toggle)
clanlib 1.0~svn3827-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 24,632 kB
  • ctags: 16,580
  • sloc: cpp: 101,591; xml: 6,410; makefile: 1,743; ansic: 463; perl: 424; php: 247; sh: 53
file content (91 lines) | stat: -rw-r--r-- 1,646 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
#ifndef _TANKVEHICLE_H_
#define _TANKVEHICLE_H_

#include "gameobject.h"

class CL_Sprite;
class CL_SoundBuffer;
class World;

class TankVehicle : public GameObject
{
// Enums
public:
	enum TankType
	{
		SPACE_SHOOT
	};
	
// Construction
public:
	TankVehicle(TankType type, World *world);
	virtual ~TankVehicle() {}

// Attributes:
public:
	bool isSelected() const;
	
// Operations:
public:
	void setAngle(float angle);
	void setDestAngle(float angle);

	void setTurretAngle(float angle);
	void setDestTurretAngle(float angle);
	void setTurretTargetPos(int x, int y);
	
	void getPos(int &x, int &y);
	void setPos(int x, int y);
	void setTargetPos(int x, int y);
	
	void select();
	void deselect();
	
	void fire(bool nuke);
	
	bool hitCheck(CL_CollisionOutline *outline, GameObject *other);
	bool hitCheck(const CL_Rect &rect);
	bool hitCheck(int x, int y);
	
	virtual void draw();
	virtual bool update(float timeElapsed);

// Implementation:
private:
	CL_Sprite *spriteBody;
	CL_Sprite *spriteTurret;
	
	CL_Sprite *spriteBodyStill;
	CL_Sprite *spriteBodyMoving;
	CL_Sprite *spriteTurretStill;
	CL_Sprite *spriteTurretShooting;
	CL_Sprite *spriteTurretReloading;
	CL_Sprite *spriteSelected;
	CL_Sprite *spriteTurretGunFlash;
	CL_Sprite *spriteRedGlow;
	
	CL_SoundBuffer *soundTurret;

	CL_CollisionOutline *collisionBody;
	
	float bodyAngle;
	float destBodyAngle, deltaBodyAngle;

	float turretAngle;
	float destTurretAngle, deltaTurretAngle;

	float posX, posY;
	float destPosX, destPosY;
	float deltaPosX, deltaPosY;
	
	float bodyTurnSpeed;
	float turretTurnSpeed;
	float moveSpeed;
	
	bool selected;
	
	bool isFiring;
	bool reverse;
};

#endif