diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-02-10 19:18:51 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-02-10 19:18:51 +0000 |
| commit | d783595135ca768ae14f08aa4033dea35ed0458b (patch) | |
| tree | b653d2b0bc34e6d903902d19a6c3b2f1d1ead176 /src | |
| parent | ec218f423abf60b6e776d7a5a9ebee408de45a60 (diff) | |
- dopisane objekty do prvej areny
- opravy zvuku ( ak sa neinicalizuje, program sa sprava ako keby sa inicalizoval )
- opravy v sietovom multiplayeri
- porgram ma parametre ( zatial nezdokumentovane, je to iba vidiet zo zdrojaka )
git-svn-id: http://opensvn.csie.org/tuxanci_ng@4 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
| -rw-r--r-- | src/gun.c | 6 | ||||
| -rw-r--r-- | src/item.c | 20 | ||||
| -rw-r--r-- | src/music.c | 10 | ||||
| -rw-r--r-- | src/net_multiplayer.c | 2 | ||||
| -rw-r--r-- | src/sound.c | 10 | ||||
| -rw-r--r-- | src/tux.c | 65 | ||||
| -rw-r--r-- | src/wall.c | 2 |
7 files changed, 79 insertions, 36 deletions
@@ -217,11 +217,17 @@ static void putInGunMine(tux_t *tux) if( isFreeSpace(x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) ) { addList(arena->listItem, newItem(x, y, ITEM_MINE) ); + tux->shot[tux->gun]--; } } void shotInGun(tux_t *tux) { + if( tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE ) + { + tux->shot[tux->gun]--; + } + switch( tux->gun ) { case GUN_SIMPLE : @@ -273,6 +273,8 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot) for( i = 0 ; i < listShot->count ; i++ ) { + bool_t isDelShot = FALSE; + thisShot = (shot_t *)listShot->list[i]; assert( thisShot != NULL ); @@ -298,12 +300,19 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot) j--; } break; + case ITEM_EXPLOSION : case ITEM_BIG_EXPLOSION : - delListItem(listShot, i, destroyShot); + isDelShot = TRUE; break; } } + + if( isDelShot ) + { + delListItem(listShot, i, destroyShot); + i--; + } } } @@ -345,9 +354,12 @@ void eventGiveTuxItem(tux_t *tux, list_t *listItem) break; case ITEM_MINE : - delListItem(listItem, i, destroyItem); - addList(listItem, newItem(x, y, ITEM_EXPLOSION) ); - i--; + if( tux->bonus != BONUS_GHOST ) + { + delListItem(listItem, i, destroyItem); + addList(listItem, newItem(x, y, ITEM_EXPLOSION) ); + i--; + } break; case ITEM_EXPLOSION : diff --git a/src/music.c b/src/music.c index 90a8501..c2f3f16 100644 --- a/src/music.c +++ b/src/music.c @@ -98,6 +98,11 @@ static void destroyMusic(music_t *p) void addMusic(char *file, char *name, int group) { + if( isMusicInit == FALSE ) + { + return; + } + addList( listMusic, newMusic(file, name, group) ); } @@ -191,6 +196,11 @@ void delAllMusicInGroup(int group) int i; music_t *this; + if( isMusicInit == FALSE ) + { + return; + } + for( i = 0 ; i < listMusic->count ; i++ ) { this = (music_t *)listMusic->list[i]; diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c index 5e5ab6d..9080d26 100644 --- a/src/net_multiplayer.c +++ b/src/net_multiplayer.c @@ -278,7 +278,7 @@ void proto_recv_newtux_client(char *msg) tux->y = y; tux->position = position; tux->frame = frame; - tux->frame = score; + tux->score = score; strcpy(tux->name, name); tux->gun = myGun; tux->bonus = myBonus; diff --git a/src/sound.c b/src/sound.c index 10f11d4..4d574b8 100644 --- a/src/sound.c +++ b/src/sound.c @@ -26,18 +26,19 @@ void initSound() if( isAudioInicialized() == FALSE ) { isSoundInit = FALSE; + return; } listSound = newList(); isSoundInit = TRUE; var_isSoundActive = TRUE; - if( isParamFlag("--nomusic") ) + if( isParamFlag("--nosound") ) { setSoundActive(FALSE); } - if( isParamFlag("--music") ) + if( isParamFlag("--sound") ) { setSoundActive(TRUE); } @@ -93,6 +94,11 @@ static void destroySound(sound_t *p) void addSound(char *file, char *name, int group) { + if( isSoundInit == FALSE ) + { + return; + } + addList( listSound, newSound(file, name, group) ); } @@ -48,6 +48,7 @@ void initTux() tux_t* newTux() { static int last_id = 0; + int x, y; tux_t *new; new = malloc( sizeof(tux_t) ); @@ -59,7 +60,9 @@ tux_t* newTux() new->status = TUX_STATUS_ALIVE; new->control = TUX_CONTROL_NONE; - findFreeSpace(&new->x, &new->y, TUX_WIDTH, TUX_HEIGHT); + findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT); + setTuxProportion(new, x, y); + new->position = TUX_DOWN; new->gun = GUN_SIMPLE; new->shot[ new->gun ] = GUN_MAX_SHOT; @@ -125,20 +128,20 @@ void getCourse(int n, int *x, int *y) } } -void drawTux(tux_t *p) +void drawTux(tux_t *tux) { SDL_Surface *g_image = NULL; - assert( p != NULL ); + assert( tux != NULL ); - if( p->bonus == BONUS_HIDDEN && + if( tux->bonus == BONUS_HIDDEN && getNetTypeGame() != NET_GAME_TYPE_NONE && - p->control == TUX_CONTROL_NET ) + tux->control == TUX_CONTROL_NET ) { return; } - switch( p->position ) + switch( tux->position ) { case TUX_UP : g_image = g_tux_up; @@ -161,13 +164,13 @@ void drawTux(tux_t *p) break; } - if( p->status == TUX_STATUS_DEAD ) + if( tux->status == TUX_STATUS_DEAD ) { g_image = g_cross; addLayer(g_cross, - p->x - g_cross->w / 2, - ( p->y + g_cross->h / 2 ) - g_cross->h, + tux->x - g_cross->w / 2, + ( tux->y + g_cross->h / 2 ) - g_cross->h, 0, 0, g_cross->w, g_cross->h, TUX_LAYER); @@ -175,9 +178,9 @@ void drawTux(tux_t *p) } addLayer(g_image, - p->x - TUX_IMG_WIDTH / 2, - ( p->y + TUX_HEIGHT / 2 ) - TUX_IMG_HEIGHT, - p->frame * TUX_IMG_WIDTH, 0, + tux->x - TUX_IMG_WIDTH / 2, + ( tux->y + TUX_HEIGHT / 2 ) - TUX_IMG_HEIGHT, + tux->frame * TUX_IMG_WIDTH, 0, TUX_IMG_WIDTH, TUX_IMG_HEIGHT, TUX_LAYER); } @@ -279,6 +282,7 @@ static void timer_spawnTux(void *p) { tux_t *tux; arena_t *arena; + int x, y; int id; id = * ((int *)p); @@ -290,7 +294,8 @@ static void timer_spawnTux(void *p) if( tux == NULL )return; tux->status = TUX_STATUS_ALIVE; - findFreeSpace(&tux->x, &tux->y, TUX_WIDTH, TUX_HEIGHT); + findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT); + setTuxProportion(tux, x, y); tux->gun = GUN_SIMPLE; addNewItem(arena->listItem); @@ -362,14 +367,16 @@ static void eventTuxIsDeadWIthShot(tux_t *tux,shot_t *shot) shot->author->score++; countRoundInc(); eventTuxIsDead(tux); - } void tuxTeleport(tux_t *tux) { + int x, y; + playSound("teleport", SOUND_GROUP_BASE); - findFreeSpace(&tux->x, &tux->y, TUX_WIDTH, TUX_HEIGHT); + findFreeSpace(&x, &y, TUX_WIDTH, TUX_HEIGHT); + setTuxProportion(tux, x, y); if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { @@ -409,7 +416,6 @@ void eventConflictShotWithTux(list_t *listTux, list_t *listShot) continue; } - eventTuxIsDeadWIthShot(thisTux, thisShot); } @@ -534,11 +540,6 @@ void shotTux(tux_t *tux) shotInGun(tux); - if( tux->bonus != BONUS_SHOT ) - { - tux->shot[tux->gun]--; - } - tux->isCanShot = FALSE; addTimer(timer_tuxCanShot, newInt(tux->id), TUX_TIME_CAN_SHOT ); @@ -636,20 +637,28 @@ void eventListTux(list_t *listTux) } } -void getTuxProportion(tux_t *p, int *x,int *y, int *w, int *h) +void getTuxProportion(tux_t *tux, int *x,int *y, int *w, int *h) { - assert( p != NULL ); + assert( tux != NULL ); - if( x != NULL ) *x = p->x - TUX_WIDTH / 2; - if( y != NULL ) *y = p->y - TUX_HEIGHT / 2; + if( x != NULL ) *x = tux->x - TUX_WIDTH / 2; + if( y != NULL ) *y = tux->y - TUX_HEIGHT / 2; if( w != NULL ) *w = TUX_WIDTH; if( h != NULL ) *h = TUX_HEIGHT; } -void destroyTux(tux_t *p) +void setTuxProportion(tux_t *tux, int x, int y) { - assert( p != NULL ); - free(p); + assert( tux != NULL ); + + tux->x = x + TUX_WIDTH / 2; + tux->y = y + TUX_WIDTH / 2; +} + +void destroyTux(tux_t *tux) +{ + assert( tux != NULL ); + free(tux); } void quitTux() @@ -33,7 +33,7 @@ void drawWall(wall_t *p) { assert( p != NULL ); - addLayer(p->img, p->x, p->y, 0, 0, p->img->w, p->img->h, p->layer); + addLayer(p->img, p->img_x, p->img_y, 0, 0, p->img->w, p->img->h, p->layer); } void drawListWall(list_t *listWall) |