summaryrefslogtreecommitdiff
path: root/src/tux.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-04-15 19:28:48 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-04-15 19:28:48 +0000
commita8bec57e7a9be7b1fa36ef8be618db4e46cbd599 (patch)
tree1af5e651f4ff628f99393109e3352dbd7b1f39f4 /src/tux.c
parentc8223ce77a4dbf57be272d10c4e1d31f69bd516e (diff)
- oprava chyby #0007 #0006 #0005
- nova zbran bombball - client dostava svoju vlastnu poziciu od servera kazdych 5000 ms git-svn-id: http://opensvn.csie.org/tuxanci_ng@45 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/tux.c')
-rw-r--r--src/tux.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/src/tux.c b/src/tux.c
index 3b14427..5d94fbe 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -292,7 +292,7 @@ int isConflictTuxWithListTux(tux_t *tux, list_t *listTux)
getTuxProportion(thisTux, &thisTux_x, &thisTux_y, &thisTux_w, &thisTux_h);
- if( conflictSpace(tux_x, tux_y, tux_w, tux_h,
+ if( thisTux->bonus != BONUS_GHOST && conflictSpace(tux_x, tux_y, tux_w, tux_h,
thisTux_x, thisTux_y, thisTux_w, thisTux_h) )
{
return 1;
@@ -449,6 +449,24 @@ void tuxTeleport(tux_t *tux)
}
}
+static void bombBallExplosion(shot_t *shot)
+{
+ item_t *item;
+ int x, y;
+
+ x = ( shot->x + shot->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2;
+ y = ( shot->y + shot->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2;
+
+ item = newItem(x, y, ITEM_BIG_EXPLOSION, shot->author);
+ addList(getCurrentArena()->listItem, item );
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_delshot_server(PROTO_SEND_ALL, NULL, shot);
+ proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
+ }
+}
+
void eventConflictTuxWithShot(list_t *listTux, list_t *listShot)
{
shot_t *thisShot;
@@ -481,6 +499,18 @@ void eventConflictTuxWithShot(list_t *listTux, list_t *listShot)
continue;
}
+ if( thisShot->gun == GUN_BOMBBALL )
+ {
+ if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
+ {
+ bombBallExplosion(thisShot);
+ delListItem(listShot, i, destroyShot);
+ i--;
+ }
+
+ continue;
+ }
+
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
eventTuxIsDeadWIthShot(thisTux, thisShot);
@@ -552,22 +582,22 @@ void moveTux(tux_t *tux, int n)
return;
}
- if( n == TUX_LEFT && tux->x < 0 )
+ if( n == TUX_LEFT && tux->x-TUX_STEP <= 0 )
{
return;
}
- if( n == TUX_RIGHT && tux->x > WINDOW_SIZE_X )
+ if( n == TUX_RIGHT && tux->x+TUX_STEP >= WINDOW_SIZE_X )
{
return;
}
- if( n == TUX_UP && tux->y < 0 )
+ if( n == TUX_UP && tux->y-TUX_STEP <= 0 )
{
return;
}
- if( n == TUX_DOWN && tux->y > WINDOW_SIZE_Y )
+ if( n == TUX_DOWN && tux->y+TUX_STEP >= WINDOW_SIZE_Y )
{
return;
}
@@ -673,6 +703,7 @@ void shotTux(tux_t *tux)
shotInGun(tux);
tux->isCanShot = FALSE;
+
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanShot,
newInt(tux->id), TUX_TIME_CAN_SHOT );
@@ -713,9 +744,13 @@ static void pickUpGun(tux_t *tux)
if( isTuxAnyGun(tux) == FALSE )
{
tux->gun = GUN_SIMPLE;
- tux->pickup_time++;
+
+ if( tux->pickup_time < TUX_MAX_PICKUP )
+ {
+ tux->pickup_time++;
+ }
- if( tux->pickup_time == TUX_MAX_PICKUP )
+ if( tux->pickup_time == TUX_MAX_PICKUP && getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
#ifndef PUBLIC_SERVER
char msg[STR_SIZE];
@@ -727,6 +762,11 @@ static void pickUpGun(tux_t *tux)
tux->gun = GUN_SIMPLE;
tux->shot[ tux->gun ] = GUN_MAX_SHOT;
tux->pickup_time = 0;
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
+ }
}
}
}
@@ -751,8 +791,13 @@ static void eventBonus(tux_t *tux)
int x, y, w, h;
getTuxProportion(tux, &x, &y, &w, &h);
- if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) )
+ tux->bonus = BONUS_NONE;
+
+ if ( isConflictWithListWall(getCurrentArena()->listWall, x, y, w, h) ||
+ isConflictWithListPipe(getCurrentArena()->listPipe, x, y, w, h) ||
+ isConflictTuxWithListTux(tux, getCurrentArena()->listTux) )
{
+ tux->bonus = BONUS_GHOST;
return;
}
}