summaryrefslogtreecommitdiff
path: root/src/wall.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-02-01 22:59:06 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-02-01 22:59:06 +0000
commit6d4e1eae16b84918009625a866104ec26a234277 (patch)
treea340a8a547a60c9f63c8dfafe8909242f9c9bbd8 /src/wall.c
nahranie tarballu tuxanci-ng na SVN server
Dusan Durech ( Oroborus ) git-svn-id: http://opensvn.csie.org/tuxanci_ng@1 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/wall.c')
-rw-r--r--src/wall.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/wall.c b/src/wall.c
new file mode 100644
index 0000000..bc0a26d
--- /dev/null
+++ b/src/wall.c
@@ -0,0 +1,108 @@
+
+#include <stdlib.h>
+#include <assert.h>
+
+#include "wall.h"
+#include "layer.h"
+#include "screen_world.h"
+#include "shot.h"
+
+wall_t* newWall(int x, int y, int w, int h,
+ int img_x, int img_y, int layer, SDL_Surface *img)
+{
+ wall_t *new;
+
+ assert( img != NULL );
+
+ 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;
+ new->img = img;
+
+ return new;
+}
+
+void drawWall(wall_t *p)
+{
+ assert( p != NULL );
+
+ addLayer(p->img, p->x, p->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);
+ }
+}
+
+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);
+}
+