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
|
#include <stdlib.h>
#include <assert.h>
#include "main.h"
#include "wall.h"
#include "shot.h"
#ifndef BUBLIC_SERVER
#include "layer.h"
#include "screen_world.h"
#endif
#ifdef BUBLIC_SERVER
#include "publicServer.h"
#endif
#ifndef BUBLIC_SERVER
wall_t* newWall(int x, int y, int w, int h,
int img_x, int img_y, int layer, SDL_Surface *img)
#endif
#ifdef BUBLIC_SERVER
wall_t* newWall(int x, int y, int w, int h,
int img_x, int img_y, int layer)
#endif
{
wall_t *new;
#ifndef BUBLIC_SERVER
assert( img != NULL );
#endif
new = malloc( sizeof(wall_t) );
assert( new != NULL );
new->x = x;
new->y = y;
new->w = w;
new->h = h;
new->img_x = img_x;
new->img_y = img_y;
new->layer = layer;
#ifndef BUBLIC_SERVER
new->img = img;
#endif
return new;
}
#ifndef BUBLIC_SERVER
void drawWall(wall_t *p)
{
assert( p != NULL );
addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, p->img->h, p->layer);
}
void drawListWall(list_t *listWall)
{
wall_t *thisWall;
int i;
assert( listWall != NULL );
for( i = 0 ; i < listWall->count ; i++ )
{
thisWall = (wall_t *)listWall->list[i];
assert( thisWall != NULL );
drawWall(thisWall);
}
}
#endif
int isConflictWithListWall(list_t *listWall, int x, int y, int w, int h)
{
wall_t *thisWall;
int i;
assert( listWall != NULL );
for( i = 0 ; i < listWall->count ; i++ )
{
thisWall = (wall_t *)listWall->list[i];
assert( thisWall != NULL );
if( conflictSpace(x, y, w, h,
thisWall->x, thisWall->y, thisWall->w, thisWall->h) )
{
return 1;
}
}
return 0;
}
void eventConflictShotWithWall(list_t *listWall, list_t *listShot)
{
shot_t *thisShot;
int i;
assert( listWall != NULL );
assert( listShot != NULL );
for( i = 0 ; i < listShot->count ; i++ )
{
thisShot = (shot_t *)listShot->list[i];
assert( thisShot != NULL );
if( isConflictWithListWall(listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) )
{
if( thisShot->author->bonus == BONUS_GHOST &&
thisShot->author->bonus_time > 0 )
{
continue;
}
delListItem(listShot, i, destroyShot);
i--;
}
}
}
void destroyWall(wall_t *p)
{
assert( p != NULL );
free(p);
}
|