From d783595135ca768ae14f08aa4033dea35ed0458b Mon Sep 17 00:00:00 2001 From: oroborus Date: Sun, 10 Feb 2008 19:18:51 +0000 Subject: - 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 --- arena/mapa1.map | 10 ++++++-- image/l1.hut.png | Bin 0 -> 65499 bytes image/l1.peduncle.png | Bin 0 -> 15239 bytes image/l1.tree.png | Bin 0 -> 66388 bytes image/l1.wood.png | Bin 0 -> 14764 bytes include/tux.h | 7 +++--- src/gun.c | 6 +++++ src/item.c | 20 ++++++++++++---- src/music.c | 10 ++++++++ src/net_multiplayer.c | 2 +- src/sound.c | 10 ++++++-- src/tux.c | 65 ++++++++++++++++++++++++++++---------------------- src/wall.c | 2 +- 13 files changed, 91 insertions(+), 41 deletions(-) create mode 100644 image/l1.hut.png create mode 100644 image/l1.peduncle.png create mode 100644 image/l1.tree.png create mode 100644 image/l1.wood.png diff --git a/arena/mapa1.map b/arena/mapa1.map index 25ad60b..2ec49ee 100644 --- a/arena/mapa1.map +++ b/arena/mapa1.map @@ -2,10 +2,16 @@ loadMusic file="noc.ogg" name="noc" loadImage file="l1.grow.png" name="grow" alpha="no" -loadImage file="pokus.png" name="pokus" alpha="no" +loadImage file="l1.hut.png" name="hut" alpha="yes" +loadImage file="l1.peduncle.png" name="peduncle" alpha="yes" +loadImage file="l1.tree.png" name="tree" alpha="yes" +loadImage file="l1.wood.png" name="wood" alpha="yes" background image="grow" playMusic music="noc" -wall x="200" y="100" w="128" h="64" img_x="200" img_y="100" layer="1" image="pokus" +wall x="0" y="0" w="0" h="0" img_x="75" img_y="20" layer="1" image="hut" +wall x="120" y="159" w="180" h="65" img_x="90" img_y="159" layer="0" image="peduncle" +wall x="520" y="260" w="161" h="100" img_x="500" img_y="180" layer="0" image="tree" +wall x="220" y="400" w="110" h="10" img_x="200" img_y="370" layer="0" image="wood" diff --git a/image/l1.hut.png b/image/l1.hut.png new file mode 100644 index 0000000..7e42da6 Binary files /dev/null and b/image/l1.hut.png differ diff --git a/image/l1.peduncle.png b/image/l1.peduncle.png new file mode 100644 index 0000000..258f34c Binary files /dev/null and b/image/l1.peduncle.png differ diff --git a/image/l1.tree.png b/image/l1.tree.png new file mode 100644 index 0000000..5e3995e Binary files /dev/null and b/image/l1.tree.png differ diff --git a/image/l1.wood.png b/image/l1.wood.png new file mode 100644 index 0000000..ae1550a Binary files /dev/null and b/image/l1.wood.png differ diff --git a/include/tux.h b/include/tux.h index 068ed63..e73f934 100644 --- a/include/tux.h +++ b/include/tux.h @@ -102,7 +102,7 @@ extern void initTux(); extern tux_t* newTux(); extern bool_t isTuxAnyGun(tux_t *tux); extern void getCourse(int n, int *x, int *y); -extern void drawTux(tux_t *p); +extern void drawTux(tux_t *tux); extern void drawListTux(list_t *listTux); extern void eventTuxIsDead(tux_t *tux); extern tux_t* isConflictWithListTux(list_t *listTux, int x, int y, int w, int h); @@ -112,8 +112,9 @@ extern void tuxTeleport(tux_t *tux); extern void actionTux(tux_t *tux, int action); extern void eventListTux(list_t *listTux); extern tux_t* getTuxID(list_t *listTux, int id); -extern void getTuxProportion(tux_t *p, int *x,int *y, int *w, int *h); -extern void destroyTux(tux_t *p); +extern void getTuxProportion(tux_t *tux, int *x,int *y, int *w, int *h); +extern void setTuxProportion(tux_t *tux, int x, int y); +extern void destroyTux(tux_t *tux); extern void quitTux(); #endif diff --git a/src/gun.c b/src/gun.c index f7fdc67..9e5fd5d 100644 --- a/src/gun.c +++ b/src/gun.c @@ -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 : diff --git a/src/item.c b/src/item.c index 8167902..188ad5b 100644 --- a/src/item.c +++ b/src/item.c @@ -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) ); } diff --git a/src/tux.c b/src/tux.c index 3ca06b1..1af5f90 100644 --- a/src/tux.c +++ b/src/tux.c @@ -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() diff --git a/src/wall.c b/src/wall.c index bc0a26d..cc2efe4 100644 --- a/src/wall.c +++ b/src/wall.c @@ -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) -- cgit v1.2.3