diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-02 19:41:48 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-03-02 19:41:48 +0000 |
| commit | 44404eb5063bd5f040c7a4d8605aa3d43e3a968a (patch) | |
| tree | d9b4fceb80a2abf6103fd6022de80dd3286caaf0 /src | |
| parent | 8a14d60d2078b4bcdfc789b1b9794e2008979f02 (diff) | |
- par uprav
- dopisany credits
git-svn-id: http://opensvn.csie.org/tuxanci_ng@8 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src')
| -rwxr-xr-x | src/Makefile | 9 | ||||
| -rw-r--r-- | src/item.c | 2 | ||||
| -rw-r--r-- | src/main.c | 3 | ||||
| -rw-r--r-- | src/net_multiplayer.c | 20 | ||||
| -rw-r--r-- | src/screen_choiceArena.c | 13 | ||||
| -rw-r--r-- | src/screen_credits.c | 125 | ||||
| -rw-r--r-- | src/screen_mainMenu.c | 5 | ||||
| -rw-r--r-- | src/screen_setting.c | 8 | ||||
| -rw-r--r-- | src/screen_world.c | 40 | ||||
| -rw-r--r-- | src/widget_label.c | 2 |
10 files changed, 193 insertions, 34 deletions
diff --git a/src/Makefile b/src/Makefile index 31f3393..2d5921b 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,9 @@ CC = gcc -CFLAGS = -g -O0 -DDISTDIR=\"$(DISTDIR)\" `sdl-config --cflags` -I../include -Wall +#CFLAGS = -g -O0 -DDISTDIR=\"$(DISTDIR)\" `sdl-config --cflags` -I../include -Wall +CFLAGS = -O2 -DDISTDIR=\"$(DISTDIR)\" `sdl-config --cflags` -I../include -Wall + LIBS = `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o main.o \ @@ -9,7 +11,7 @@ FILES = interface.o font.o list.o image.o layer.o director.o configFile.o tux.o buffer.o dynamicInt.o arena.o arenaFile.o textFile.o sound.o audio.o music.o gun.o \ item.o widget_label.o screen_mainMenu.o widget_button.o screen_analyze.o widget_textfield.o \ widget_check.o widget_image.o screen_setting.o screen_gameType.o screen_choiceArena.o \ - widget_buttonimage.o + widget_buttonimage.o screen_credits.o tuxanci-ng: $(FILES) @@ -111,6 +113,9 @@ screen_gameType.o: screen_gameType.c ../include/screen_gameType.h screen_choiceArena.o: screen_choiceArena.c ../include/screen_choiceArena.h $(CC) $(CFLAGS) -o screen_choiceArena.o -c screen_choiceArena.c +screen_credits.o: screen_credits.c ../include/screen_credits.h + $(CC) $(CFLAGS) -o screen_credits.o -c screen_credits.c + widget_label.o: widget_label.c ../include/widget_label.h $(CC) $(CFLAGS) -o widget_label.o -c widget_label.c @@ -117,6 +117,8 @@ void addNewItem(list_t *listItem) arena = getWorldArena(); findFreeSpace(&new_x, &new_y, ITEM_GUN_WIDTH, ITEM_GUN_HEIGHT); + type = GUN_DUAL_SIMPLE; + do{ switch( random() % 11 ) { @@ -14,6 +14,7 @@ #include "screen_setting.h" #include "screen_gameType.h" #include "screen_choiceArena.h" +#include "screen_credits.h" #include "wall.h" #include "shot.h" #include "panel.h" @@ -48,6 +49,7 @@ static void init() initScreenSetting(); initScreenGameType(); initScreenChoiceArena(); + initScreenCredits(); } void quit() @@ -71,6 +73,7 @@ void quit() quitScreenSetting(); quitScreenGameType(); quitScreenChoiceArena(); + quitScreenCredits(); printf("quit..\n"); diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c index 786e1b9..536474a 100644 --- a/src/net_multiplayer.c +++ b/src/net_multiplayer.c @@ -78,13 +78,13 @@ static void sendServer(char *msg) if ( ret == 0 ) { fprintf(stderr, "server uzatvoril sietovy socket\n"); - setScreen("analyze"); + setWorldEnd(); } if ( ret < 0 ) { fprintf(stderr, "nastala chyba pri poslani spravy serveru\n"); - setScreen("analyze"); + setWorldEnd(); } } @@ -179,16 +179,18 @@ void proto_recv_init_client(char *msg) char arena_name[STR_SIZE]; tux_t *tux; int id; - int n; + int x, y, n; sscanf(msg, "%s %d %d %d %d %s\n", - cmd, &id, &tux->x, &tux->y, &n, arena_name); + cmd, &id, &x, &y, &n, arena_name); setWorldArena( getArenaIdFormNetName(arena_name) ); setMaxCountRound(n); tux = newTux(); tux->id = id; + tux->x = x; + tux->y = y; tux->control = TUX_CONTROL_KEYBOARD_RIGHT; getSettingNameRight(tux->name); @@ -457,7 +459,7 @@ static void eventClientBuffer(client_t *client) while( getBufferLine(client->buffer, line, STR_SIZE) >= 0 ) { - printf("dostal som %s", line); + //printf("dostal som %s", line); if( strncmp(line, "event", 5) == 0 )proto_recv_event_server(client, line); if( strncmp(line, "context", 7) == 0 )proto_recv_context_server(client, line); @@ -538,21 +540,21 @@ static void eventServerSelect(int sock) if( ret == 0 ) { fprintf(stderr, "server uzatovril sietovy socket\n"); - setScreen("analyze"); + setWorldEnd(); return; } if( ret < 0 ) { fprintf(stderr, "chyba, spojenie prerusene \n"); - setScreen("analyze"); + setWorldEnd(); return; } if( addBuffer(clientBuffer, buffer, ret) != 0 ) { fprintf(stderr, "chyba, nemozem zapisovat do mojho buffera !\n"); - setScreen("analyze"); + setWorldEnd(); return; } } @@ -570,7 +572,7 @@ static void eventServerBuffer() while ( getBufferLine(clientBuffer, line, STR_SIZE) >= 0 ) { - printf("dostal som %s", line); + //printf("dostal som %s", line); if( strncmp(line, "init", 4) == 0 )proto_recv_init_client(line); if( strncmp(line, "event", 5) == 0 )proto_recv_event_client(line); diff --git a/src/screen_choiceArena.c b/src/screen_choiceArena.c index c3637f1..0b36ca5 100644 --- a/src/screen_choiceArena.c +++ b/src/screen_choiceArena.c @@ -118,17 +118,12 @@ void initScreenChoiceArena() SDL_Surface *image; int i; - image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_main", IMAGE_GROUP_BASE); + image = getImage(IMAGE_GROUP_BASE, "screen_main"); image_backgorund = newWidgetImage(0, 0, image); button_back = newWidgetButton("Back", 100, WINDOW_SIZE_Y-100, eventWidget); button_play = newWidgetButton("Play", WINDOW_SIZE_X-200, WINDOW_SIZE_Y-100, eventWidget); - addMusic("menu.ogg", "menu", MUSIC_GROUP_BASE); - - registerScreen( newScreen("chiceArena", startScreenChoiceArena, eventScreenChoiceArena, - drawScreenChoiceArena, stopScreenChoiceArena) ); - listWidgetButtonimage = newList(); choiceArenaId = 0; @@ -153,6 +148,9 @@ void initScreenChoiceArena() addList( listWidgetButtonimage, widget_buttonimage); } + + registerScreen( newScreen("chiceArena", startScreenChoiceArena, eventScreenChoiceArena, + drawScreenChoiceArena, stopScreenChoiceArena) ); } void quitScreenChoiceArena() @@ -161,5 +159,6 @@ void quitScreenChoiceArena() destroyWidgetButton(button_play); destroyWidgetButton(button_back); -} + destroyListItem(listWidgetButtonimage, destroyWidgetButtonimage); +} diff --git a/src/screen_credits.c b/src/screen_credits.c new file mode 100644 index 0000000..17c1bfe --- /dev/null +++ b/src/screen_credits.c @@ -0,0 +1,125 @@ + +#include <stdio.h> +#include <assert.h> + +#include "main.h" +#include "interface.h" +#include "list.h" +#include "textFile.h" +#include "screen.h" +#include "image.h" +#include "music.h" +#include "screen_credits.h" + +#include "widget_image.h" +#include "widget_label.h" +#include "widget_button.h" + +static widget_image_t *image_backgorund; +static widget_button_t *button_back; +static list_t *listWidgetLabel; +static textFile_t *textFile; +static int offset; + +void startScreenCredits() +{ + playMusic("menu", MUSIC_GROUP_BASE); + offset = 0; +} + +void drawScreenCredits() +{ + int i; + + drawWidgetImage(image_backgorund); + + drawWidgetButton(button_back); + + for( i = 0 ; i < listWidgetLabel->count ; i++ ) + { + int z; + + widget_label_t *this; + this = (widget_label_t *)listWidgetLabel->list[i]; + + z = this->y; + this->y += offset; + + if( this->y > SCREEN_CREDITS_OFFSET_MIN && this->y < SCREEN_CREDITS_OFFSET_MAX ) + { + drawWidgetLabel(this); + } + + this->y = z; + } + +} + +void eventScreenCredits() +{ + eventWidgetButton(button_back); + + offset -= SCREEN_CREDITS_OFFSET_SPEED; + + if( offset < SCREEN_CREDITS_OFFSET_RESTART ) + { + offset = 0; + } + + //printf("offset = %d\n", offset); +} + +void stopScreenCredits() +{ +} + +static void eventWidget(void *p) +{ + widget_button_t *button; + + button = (widget_button_t *)(p); + + if( button == button_back ) + { + setScreen("mainMenu"); + } +} + +void initScreenCredits() +{ + SDL_Surface *image; + int i; + + image = getImage(IMAGE_GROUP_BASE, "screen_main"); + image_backgorund = newWidgetImage(0, 0, image); + + button_back = newWidgetButton("Back", WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2, WINDOW_SIZE_Y-100, eventWidget); + + listWidgetLabel = newList(); + textFile = loadTextFile(PATH_DATA SCREEN_CREDITS_FILE); + + for( i = 0 ; i < textFile->text->count ; i++ ) + { + widget_label_t *label; + char *line; + + line = (char *)textFile->text->list[i]; + label = newWidgetLabel(line, WINDOW_SIZE_X/2, (WINDOW_SIZE_Y-100)+i*20, + WIDGET_LABEL_CENTER); + + addList(listWidgetLabel, label); + } + + registerScreen( newScreen("credits", startScreenCredits, eventScreenCredits, + drawScreenCredits, stopScreenCredits) ); +} + +void quitScreenCredits() +{ + destroyWidgetImage(image_backgorund); + + destroyWidgetButton(button_back); + destroyListItem(listWidgetLabel, destroyWidgetLabel); + destroyTextFile(textFile); +} + diff --git a/src/screen_mainMenu.c b/src/screen_mainMenu.c index db503b6..3e54323 100644 --- a/src/screen_mainMenu.c +++ b/src/screen_mainMenu.c @@ -69,6 +69,11 @@ static void eventWidget(void *p) setScreen("setting"); } + if( button == button_credits ) + { + setScreen("credits"); + } + if( button == button_end ) { quit(); diff --git a/src/screen_setting.c b/src/screen_setting.c index f54625b..6d8248d 100644 --- a/src/screen_setting.c +++ b/src/screen_setting.c @@ -183,8 +183,8 @@ void initScreenSetting() for( i = GUN_DUAL_SIMPLE ; i <= GUN_BOMBBALL ; i++ ) { - int x; - int y; + int x = 0; + int y = 0; if( i >= GUN_DUAL_SIMPLE && i <= GUN_TOMMY ) { @@ -203,8 +203,8 @@ void initScreenSetting() for( i = BONUS_SPEED ; i <= BONUS_HIDDEN ; i++ ) { - int x; - int y; + int x = 0; + int y = 0; if( i >= BONUS_SPEED && i <= BONUS_TELEPORT ) { diff --git a/src/screen_world.c b/src/screen_world.c index 1f91cc6..b7895e6 100644 --- a/src/screen_world.c +++ b/src/screen_world.c @@ -33,6 +33,7 @@ static int count; static int max_count; static bool_t isScreenWorldInit = FALSE; +static bool_t isEndWorld; bool_t isScreenWorldInicialized() { @@ -41,14 +42,22 @@ bool_t isScreenWorldInicialized() void setGameType() { + int ret = 0; + if( getSettingGameType() == NET_GAME_TYPE_SERVER ) { - initServer( getSettingPort() ); + ret = initServer( getSettingPort() ); } if( getSettingGameType() == NET_GAME_TYPE_CLIENT ) { - initClient( getSettingPort() , getSettingIP() ); + ret = initClient( getSettingPort() , getSettingIP() ); + } + + if( ret != 0 ) + { + fprintf(stderr, "Chyba inicalizacie sieti !\n"); + setWorldEnd(); } } @@ -68,11 +77,16 @@ void setMaxCountRound(int n) max_count = n; } +void setWorldEnd() +{ + isEndWorld = TRUE; +} + static void timer_endArena() { if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) { - setScreen("analyze"); + setWorldEnd(); return; } } @@ -287,23 +301,26 @@ static void control_keyboard_left(tux_t *tux) if( mapa[(SDLKey)SDLK_TAB] == SDL_PRESSED )actionTux(tux, TUX_SWITCH_GUN); } -static void eventEnd() +static void eventEsc() { Uint8 *mapa; mapa = SDL_GetKeyState(NULL); if( mapa[(SDLKey)SDLK_ESCAPE] == SDL_PRESSED ) { - setScreen("analyze"); + isEndWorld = TRUE; + setWorldEnd(); return; } -/* - if( count >= max_count && getNetTypeGame() != NET_GAME_TYPE_CLIENT ) +} + +static void eventEnd() +{ + if( isEndWorld == TRUE ) { setScreen("analyze"); return; } -*/ } void tuxControl(tux_t *p) @@ -339,23 +356,24 @@ void eventWorld() return; } - eventListTux(arena->listTux); - eventConflictShotWithTux(arena->listTux, arena->listShot); eventConflictShotWithWall(arena->listWall, arena->listShot); eventMoveListShot(arena->listShot); eventListItem(arena->listItem); eventConflictShotWithItem(arena->listItem, arena->listShot); - eventTimer(); + eventListTux(arena->listTux); + eventTimer(); eventNetMultiplayer(); + eventEsc(); eventEnd(); } void startWorld() { arena = NULL; + isEndWorld = FALSE; count = 0; diff --git a/src/widget_label.c b/src/widget_label.c index c01fa6b..0cb0929 100644 --- a/src/widget_label.c +++ b/src/widget_label.c @@ -29,7 +29,7 @@ void drawWidgetLabel(widget_label_t *p) drawFont(p->text, p->x, p->y+p->h/2, COLOR_WHITE); break; case WIDGET_LABEL_CENTER : - drawFont(p->text, p->x+p->w/2, p->y, COLOR_WHITE); + drawFont(p->text, p->x-p->w/2, p->y, COLOR_WHITE); break; } } |