From 601a366b8c665f760463259552fedd7be43e5754 Mon Sep 17 00:00:00 2001 From: oroborus Date: Sat, 2 Feb 2008 20:37:46 +0000 Subject: - zvuky v hre - hudba/zvuky sa daju zapnut/vypnut - tuxovia nemozu ist v arene do nekonecna - oprava chyby, ak bol zaskrknuty iba samopal, hra sa zasekla - do widgetu textfiled sa neda pisat donekonecna - tux ovladany pomocou keyboard_left stiriela a meni zbran - tuxovia nemozu prechadzat cez seba git-svn-id: http://opensvn.csie.org/tuxanci_ng@2 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/tux.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'src/tux.c') diff --git a/src/tux.c b/src/tux.c index 212242f..c143302 100644 --- a/src/tux.c +++ b/src/tux.c @@ -7,6 +7,7 @@ #include "main.h" #include "tux.h" #include "image.h" +#include "sound.h" #include "layer.h" #include "screen_world.h" #include "shot.h" @@ -239,6 +240,40 @@ tux_t* isConflictWithListTux(list_t *listTux, int x, int y, int w, int h) return NULL; } +int isConflictTuxWithListTux(tux_t *tux, list_t *listTux) +{ + tux_t *thisTux; + int tux_x, tux_y, tux_w, tux_h; + int thisTux_x, thisTux_y, thisTux_w, thisTux_h; + int i; + + assert( tux != NULL ); + assert( listTux != NULL ); + + getTuxProportion(tux, &tux_x, &tux_y, &tux_w, &tux_h); + + for( i = 0 ; i < listTux->count ; i++ ) + { + thisTux = (tux_t *)listTux->list[i]; + assert( thisTux != NULL ); + + if( thisTux == tux ) + { + continue; + } + + getTuxProportion(thisTux, &thisTux_x, &thisTux_y, &thisTux_w, &thisTux_h); + + if( conflictSpace(tux_x, tux_y, tux_w, tux_h, + thisTux_x, thisTux_y, thisTux_w, thisTux_h) ) + { + return 1; + } + } + + return 0; +} + static void timer_spawnTux(void *p) { tux_t *tux; @@ -313,6 +348,8 @@ void switchTuxGun(tux_t *tux) return; } + playSound("switch_gun", SOUND_GROUP_BASE); + for( i = tux->gun+1 ; i < GUN_COUNT ; i++ ) { if( tux->shot[i] > 0 ) @@ -343,6 +380,7 @@ void eventTuxIsDead(tux_t *tux) return; } + playSound("dead", SOUND_GROUP_BASE); tux->status = TUX_STATUS_DEAD; if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) @@ -361,6 +399,8 @@ static void eventTuxIsDeadWIthShot(tux_t *tux,shot_t *shot) void tuxTeleport(tux_t *tux) { + playSound("teleport", SOUND_GROUP_BASE); + findFreeSpace(&tux->x, &tux->y, TUX_WIDTH, TUX_HEIGHT); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) @@ -413,7 +453,7 @@ void eventConflictShotWithTux(list_t *listTux, list_t *listShot) } } -void moveTux(tux_t *tux,int n) +void moveTux(tux_t *tux, int n) { int px, py; int zal_x, zal_y; @@ -429,6 +469,26 @@ void moveTux(tux_t *tux,int n) return; } + if( n == TUX_LEFT && tux->x < 0 ) + { + return; + } + + if( n == TUX_RIGHT && tux->x > WINDOW_SIZE_X ) + { + return; + } + + if( n == TUX_UP && tux->y < 0 ) + { + return; + } + + if( n == TUX_DOWN && tux->y > WINDOW_SIZE_Y ) + { + return; + } + arena = getWorldArena(); getCourse(tux->position, &px, &py); @@ -447,7 +507,7 @@ void moveTux(tux_t *tux,int n) getTuxProportion(tux, &x, &y, &w, &h); if( tux->bonus != BONUS_GHOST && ( - isConflictWithListTux(arena->listTux, x, y, w, h) != tux || + isConflictTuxWithListTux(tux, arena->listTux) || isConflictWithListWall(arena->listWall, x, y, w, h) ) ) { tux->x = zal_x; -- cgit v1.2.3