-
Notifications
You must be signed in to change notification settings - Fork 6
/
Prop.cpp
168 lines (159 loc) · 3.2 KB
/
Prop.cpp
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
158
159
160
161
162
163
164
165
166
167
168
#include "Prop.h"
void Addprop(int flag) {
Prop* p;
switch (flag) {
case WEAPON_UPDATE:
p = (Prop*)malloc(sizeof(Prop));
p->type = WEAPON_UPDATE;
p->x = rand() % (WIDTH - SIZE_PROP);
p->f_create = Frame.f_total - Frame.f_pause;
p->y = -SIZE_PROP;
p->next = prop->next;
prop->next = p;
break;
case SHIELD:
p = (Prop*)malloc(sizeof(Prop));
p->type = SHIELD;
p->x = rand() % (WIDTH - SIZE_PROP);
p->f_create = Frame.f_total - Frame.f_pause;
p->y = -SIZE_PROP;
p->next = prop->next;
prop->next = p;
break;
case HEALTHPOT:
p = (Prop*)malloc(sizeof(Prop));
p->type = HEALTHPOT;
p->x = rand() % (WIDTH - SIZE_PROP);
p->f_create = Frame.f_total - Frame.f_pause;
p->y = -SIZE_PROP;
p->next = prop->next;
prop->next = p;
break;
/*case BOMB:
prop1->type = BOMB;
prop1->x = rand() % (WIDTH - 198);
prop1->y = -HEIGHT_BOMB;
case BOMBS:
prop1->type = BOMBS;
prop1->x = rand() % (WIDTH - 198);
prop1->y = -HEIGHT_BOMBS;*/
}
}
void Move_prop(void) {
Prop* p = prop->next;
while (p != NULL) {
int frameDifference = Frame.f_total - Frame.f_pause - p->f_create;
switch (p->type) {
/*case SHIELD:case HEALTHPOT:case BOMB:case BOMBS:*/
case WEAPON_UPDATE:case SHIELD:case HEALTHPOT:
p->y = frameDifference * 0.4;
break;
}
p = p->next;
}
}
void Paint_prop(void)
{
int FDC = Frame.f_total - Frame.f_pause;
Prop* p = prop->next;
while (p != NULL)
{
switch (p->type)
{
case WEAPON_UPDATE:
{
int dif = FDC - p->f_create;
static int i = 0;
if (dif % 10 == 0)
{
i += 1;
if (i == 13)
i = 0;
}
transparentimage(NULL, p->x, p->y, 109, 64, 109 * i, 0, 109, 64, &weapon_update);
//printf("\nľŔžßľÄ%d %d", p->x, p->y);
break;
}
case SHIELD:
{
int dif = FDC - p->f_create;
static int i = 0;
if (dif % 10 == 0)
{
i += 1;
if (i == 19)
i = 0;
}
transparentimage(NULL, p->x, p->y, 56, 60, 84 * (i % 10), 60 * (i / 10), 56, 60, &shield);
//printf("\nľŔžßľÄ%d %d", p->x, p->y);
break;
}
case HEALTHPOT:
transparentimage(NULL, p->x, p->y,SIZE_PROP,SIZE_PROP,30,45,SIZE_PROP,SIZE_PROP ,&huifu);
break;
}
p = p->next;
}
}
void DeletePropB(int x, int y)
{
Prop* p = prop->next;
Prop* ptr = prop;
while (p != NULL)
{
if (p->x == x && p->y == y)
{
ptr->next = p->next;
free(p);
p = nullptr;
}
else
ptr = p;
p = ptr->next;
}
}
void DeletePropA(void)
{
Prop* p = prop->next;
Prop* ptr = prop;
while (p != NULL)
{
ptr->next = p->next;
free(p);
p = nullptr;
p = ptr->next;
}
}
void Get_prop(void) {
Prop* p = prop->next;
while (p != NULL) {
if (p->x >= pMyself->x - SIZE_PROP / 2 &&
p->x <= pMyself->x + SIZE_PROP / 2 &&
p->y >= pMyself->y - SIZE_PROP/2 && p->y <= pMyself->y + HEIGHT_ME+SIZE_PROP/2)
{
switch (p->type) {
case WEAPON_UPDATE:
pMyself->weaponlevel += 1;
break;
case SHIELD:
pMyself->invincible = Frame.f_total - Frame.f_pause;
break;
case HEALTHPOT:
pMyself->blood += 50;
if (pMyself->blood > 300) {
pMyself->blood = 300;
}
break;
/*
case BOMB:
Damage(20);
case BOMBS:
Damage(100);*/
}
DeletePropB(p->x, p->y);
p = prop->next;
}
else
p = p->next;
}
}