From ca324c005d511752b2bcdc21fdc7d6c46597469b Mon Sep 17 00:00:00 2001 From: oroborus Date: Tue, 25 Mar 2008 21:23:08 +0000 Subject: - drobne upravy v kode - vymazanie duplivitneho kodu pri "hre s GUI" a "public serverom" git-svn-id: http://opensvn.csie.org/tuxanci_ng@36 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/arena.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'src/arena.c') diff --git a/src/arena.c b/src/arena.c index 7f17f57..5e7d1bf 100644 --- a/src/arena.c +++ b/src/arena.c @@ -10,6 +10,24 @@ #include "shot.h" #include "wall.h" #include "item.h" +#include "teleport.h" +#include "pipe.h" + +#ifndef PUBLIC_SERVER +#include "layer.h" +#endif + +static arena_t *currentArena; + +void setCurrentArena(arena_t *p) +{ + currentArena = p; +} + +arena_t* getCurrentArena() +{ + return currentArena; +} arena_t* newArena() { @@ -31,6 +49,92 @@ arena_t* newArena() return new; } +int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2) +{ + return (x1listTux, x, y, w, h) )return 0; + if ( isConflictWithListWall(arena->listWall, x, y, w, h) )return 0; + if ( isConflictWithListShot(arena->listShot, x, y, w, h) )return 0; + if ( isConflictWithListItem(arena->listItem, x, y, w, h) )return 0; + if ( isConflictWithListTeleport(arena->listTeleport, x, y, w, h) )return 0; + if ( isConflictWithListPipe(arena->listPipe, x, y, w, h) )return 0; + + return 1; +} + +void findFreeSpace(arena_t *arena, int *x, int *y, int w, int h) +{ + int z_x; + int z_y; + + assert( x != NULL ); + assert( y != NULL ); + + do{ + z_x = random() % WINDOW_SIZE_X; + z_y = random() % (WINDOW_SIZE_Y-200); + }while( isFreeSpace(arena, z_x, z_y ,w ,h) == 0 ); + + *x = z_x; + *y = z_y; +} + +#ifndef PUBLIC_SERVER + +void drawArena(arena_t *arena) +{ + tux_t *tux = NULL; + + addLayer(arena->background, 0, 0, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, -100); + + drawListTux(arena->listTux); + drawListWall(arena->listWall); + drawListTeleport(arena->listTeleport); + drawListPipe(arena->listPipe); + drawListShot(arena->listShot); + drawListItem(arena->listItem); + +/* + tux = getControlTux( TUX_CONTROL_KEYBOARD_RIGHT ); +*/ + + if( tux == NULL ) + { + drawLayerCenter(WINDOW_SIZE_X/2, WINDOW_SIZE_Y/2); + } + else + { + drawLayerCenter(tux->x, tux->y); + } +} + +#endif + +void eventArena(arena_t *arena) +{ + int i; + + eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport); + eventConflictTuxWithShot(arena->listTux, arena->listShot); + + for( i = 0 ; i < 4 ; i++) + { + eventMoveListShot(arena->listShot); + eventConflictShotWithWall(arena->listWall, arena->listShot); + eventConflictShotWithTeleport(arena->listTeleport, arena->listShot); + eventConflictShotWithPipe(arena->listPipe, arena->listShot); + eventConflictShotWithItem(arena->listItem, arena->listShot); + } + + eventListItem(arena->listItem); + + eventListTux(arena->listTux); +} + void destroyArena(arena_t *p) { destroyListItem(p->listTux, destroyTux); -- cgit v1.2.3