-
Notifications
You must be signed in to change notification settings - Fork 1
/
rolesdef.h
157 lines (133 loc) · 4.74 KB
/
rolesdef.h
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*******************************************************\
* Author: Cupenoruler *
* Email: Cupenoruler@foxmail.com *
* Notes: Some functions about Console Tank. *
* Date: 2012-3-7 01:36:39 *
\*******************************************************/
#ifndef RULES_H_INCLUDED
#define RULES_H_INCLUDED
#include "pcc32.h"
#include "initdef.h"
typedef struct _Boom
{
int live;
int x;
int y;
int size;
int body;
PCCOLOR color;
} BOOM;
typedef enum _DIR
{
UP = 1,
DOWN = 2,
LEFT = 3,
RIGHT = 4
} DIR;
typedef struct _TANK // see the function which named creat_Tank in the "tank.c" file.
{
int x; //九宫格中心点横坐标
int y; //九宫格中心点纵坐标
DIR dir; //方向
int live; //生命
int is_stop; // 1 or 0
PCCOLOR color;
int id; // good tank or bad tank
int size; // tank size, default value is 1
int bullet_size; // the size of tank's bullet; default value is 0
int bullet_count; // dafault value is 3;
int killCount;
struct _TANK *nextTank;
} TANK;
typedef struct _Bullet
{
int x; //子弹横坐标;
int y; //子弹纵坐标;
DIR dir; //方向
int button; //子弹开关;0无子弹,1有子弹
PCCOLOR color;
int size;
int id;
TANK *host;
} BULLET;
typedef struct _Bullet_Manager
{
int bullet_Count; // Bullet_Count <= 8 must be true
BULLET *bullets; // it is a bullet array
// Bullet *nextBullet;
} BULLET_MANAGER;
typedef struct _Tank_Manager
{
BOOM *boom_manager;
int boom_count;
int tank_count;
TANK *nextTank;
} TANK_MANAGER;
#ifdef __cplusplus
extern "C"
{
#endif
/////////////////////////////////////////////////
// file name: tank.c
/////////////////////////////////////////////////
/* tank 管理器*/
TANK_MANAGER *create_Tank_Manager();
void destroy_Tank_Manager(TANK_MANAGER *);
TANK* create_Tank(int id, int size);
TANK* create_Tank_FromTemplete(TANK templateTank);
TANK* create_TankWithRandom();
int addTank(TANK_MANAGER *t_m, TANK* tank);
int delTank(TANK_MANAGER *t_m, TANK* tank);
/* 使用tank管理器,统一管理tank的行为 */
void move_Tanks(TANK_MANAGER*, BULLET_MANAGER*);
void draw_Tanks(const TANK_MANAGER*);
void clean_Tanks(const TANK_MANAGER*);
/* tank 行为 */
void moveTank(TANK *tank);
void drawTank(TANK *tank);
void cleanTank(TANK *tank);
void tankFire(TANK *tank, const BULLET_MANAGER *);
void operateTankWithAI(TANK *tank, BULLET_MANAGER*);
void tankInfo(int x, int y,const TANK*, PCCOLOR);
void operateTankWithInput(TANK *tank, BULLET_MANAGER*);
///////////////////////////////////////////////////////
// file name: bullet.c
///////////////////////////////////////////////////////
/* bullet 管理器 */
BULLET_MANAGER* create_Bullet_Manager(const int bullet_count);
void destroy_Bullet_Manager(BULLET_MANAGER*);
void Bullet_Manager_Info(int x, int y, BULLET_MANAGER *b_m, PCCOLOR color);
/* 使用Bullet管理器,统一管理Bullet的行为 */
void move_Bullets(BULLET_MANAGER *b_m);
void draw_Bullets(BULLET_MANAGER *b_m);
void clean_Bullets(BULLET_MANAGER *b_m);
/* Bullet的行为*/
void drawBullet(BULLET *bullet);
void moveBullet(BULLET *bullet); //嵌到move_Bullets()里了
void cleanBullet(BULLET *bullet);// 嵌到clean_Bullets()里了
void destroyBullet(BULLET* bullet);
/////////////////////////////////////////////////////
// file name: drawImp.c
/////////////////////////////////////////////////////
void drawBlock(int x,int y,PCCOLOR color, int blockIndex );
void drawString(int x,int y,PCCOLOR color,char* str);
void drawRectangle(int x,int y, int width, int height,PCCOLOR color);
/////////////////////////////////////////////////////
// file name: opetateHitEvent.c
/////////////////////////////////////////////////////
void operate_TankHitTank( TANK* currentTank, const TANK_MANAGER*);
void operate_BulletHitTank( TANK_MANAGER*, const BULLET_MANAGER* );
void operate_BulletHitBullet(BULLET_MANAGER* b_m);
int checkTankHitTank(TANK* tank,TANK* other);
int checkBulletHitTank(BULLET* bullet, TANK* tank);
/////////////////////////////////////////////////////
// file name: boom.c
/////////////////////////////////////////////////////
void addBoom(int x, int y, PCCOLOR color, TANK_MANAGER*);
void drawBoom(BOOM*);
void draw_Booms(BOOM* boom, int count);
BOOM* createBoom(int x, int y, PCCOLOR color, int body_view_index);
#ifdef __cplusplus
}
#endif
#endif // RULES_H_INCLUDED