summaryrefslogtreecommitdiff
path: root/src/gun.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-08 20:19:05 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-03-08 20:19:05 +0000
commitda85e88878251f6a980fef95bd47109169a3cf7c (patch)
tree83b8b61c4afad0f6ccbb7940176a03f3ad4d2dc5 /src/gun.c
parentf8bc51b580a5b9a8445f38b614a87209c074143a (diff)
- 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
Diffstat (limited to 'src/gun.c')
-rw-r--r--src/gun.c45
1 files changed, 31 insertions, 14 deletions
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);