From da85e88878251f6a980fef95bd47109169a3cf7c Mon Sep 17 00:00:00 2001 From: oroborus Date: Sat, 8 Mar 2008 20:19:05 +0000 Subject: - hra si vytvara domovskt adresar - moznost ulozit konfiguraciu - lasserove streli boli lepsie posunute git-svn-id: http://opensvn.csie.org/tuxanci_ng@12 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/gun.c | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'src/gun.c') diff --git a/src/gun.c b/src/gun.c index 3ad1bac..6938a88 100644 --- a/src/gun.c +++ b/src/gun.c @@ -44,16 +44,40 @@ static void modificiationCopuse(int courser, int right_x, int right_y, int *dest } } -static void addShot(tux_t *tux,int x, int y, int px, int py) +static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) { - int dest_x, dest_y; - int dest_px, dest_py; + int dest_x = 0, dest_y = 0; + int dest_px = 0, dest_py = 0; arena_t *arena; shot_t *shot; - int gun; arena = getWorldArena(); + modificiationCopuse(tux->position, px, py, &dest_px, &dest_py); + modificiationCopuse(tux->position, x, y, &dest_x, &dest_y); + + switch( tux->position ) + { + case TUX_UP : + dest_y -= TUX_WIDTH; + break; + case TUX_RIGHT : + break; + case TUX_LEFT : + dest_x -= TUX_WIDTH; + break; + case TUX_DOWN : + break; + } + + shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux); + addList( arena->listShot, shot ); +} + +static void addShot(tux_t *tux,int x, int y, int px, int py) +{ + int gun; + if( tux->gun == GUN_LASSER ) { gun = GUN_LASSER; @@ -80,22 +104,14 @@ static void addShot(tux_t *tux,int x, int y, int px, int py) case 3 : tux->position = TUX_DOWN; break; } - modificiationCopuse(tux->position, x, y, &dest_x, &dest_y); - modificiationCopuse(tux->position, px, py, &dest_px, &dest_py); - - shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux); - addList( arena->listShot, shot ); + addShotTrivial(tux, x, y, px, py, gun); } tux->position = zal; } else { - modificiationCopuse(tux->position, x, y, &dest_x, &dest_y); - modificiationCopuse(tux->position, px, py, &dest_px, &dest_py); - - shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux); - addList( arena->listShot, shot ); + addShotTrivial(tux, x, y, px, py, gun); } } @@ -162,6 +178,7 @@ static void timer_addLaserTimer(void *p) if( tux == NULL )return; + gun = tux->gun; tux->gun = GUN_LASSER; addShot(tux, 0, 0, +25, 0); -- cgit v1.2.3