summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--control8
-rwxr-xr-xdeb-build.sh2
-rwxr-xr-xinclude/interface.h2
-rw-r--r--include/item.h5
-rw-r--r--include/screen_table.h17
-rwxr-xr-xsrc/Makefile9
-rw-r--r--src/gun.c2
-rw-r--r--src/item.c16
-rw-r--r--src/main.c3
-rw-r--r--src/net_multiplayer.c17
-rw-r--r--src/screen_mainMenu.c5
-rw-r--r--src/screen_setting.c13
-rw-r--r--src/screen_table.c231
-rw-r--r--src/screen_world.c30
-rw-r--r--src/tux.c4
-rw-r--r--src/widget_label.c2
16 files changed, 339 insertions, 27 deletions
diff --git a/control b/control
index 7bdffef..0d006a7 100644
--- a/control
+++ b/control
@@ -1,12 +1,12 @@
Package: tuxanci-ng
-Version: svn11
+Version: svn13
Section: Game
Priority: optional
Depends: libc6 (>= 2.2.4-4), libsdl1.2debian (>= 1.2), libsdl-image1.2 (>= 1.2), libsdl-mixer1.2 (>= 1.2), libsdl-ttf2.0-0 (>= 2.0)
Architecture: i386
-Installed-Size: 4112
+Installed-Size: 4510
Maintainer: Dušan Ďurech <dusan.d@centrum.sk>
-Description: Game tuxanci next generation SVN revision 8
- Game tuxanci next generation SVN revision 8
+Description: Game tuxanci next generation SVN revision 13
+ Game tuxanci next generation SVN revision 13
.
http://www.tuxanci.org
diff --git a/deb-build.sh b/deb-build.sh
index 16f3da2..5e8f0d3 100755
--- a/deb-build.sh
+++ b/deb-build.sh
@@ -23,4 +23,4 @@ md5sum `find ./ -type f | awk '/.\// { print substr($0, 3) }'` > DEBIAN/md5sums
cd ..
rm -rf *.deb
-dpkg -b ./deb tuxanci-ng_svn11-1_i386.deb
+dpkg -b ./deb tuxanci-ng_svn13-1_i386.deb
diff --git a/include/interface.h b/include/interface.h
index 850fe19..929c8bf 100755
--- a/include/interface.h
+++ b/include/interface.h
@@ -23,7 +23,7 @@
#define WINDOW_SIZE_Y 600
//napis na okne
-#define WINDOW_TITLE "Tuxanci next generation SVN revision 11"
+#define WINDOW_TITLE "Tuxanci next generation SVN revision 13"
#define WIN_BPP 0
#define USR_EVT_TIMER 0
diff --git a/include/item.h b/include/item.h
index 49b3173..3f6b6bd 100644
--- a/include/item.h
+++ b/include/item.h
@@ -21,6 +21,7 @@ typedef struct item_struct
int frame; //poradove cislo animacie
int count;
+ tux_t *author;
SDL_Surface *img; //obrazok
} item_t;
@@ -49,8 +50,8 @@ typedef struct item_struct
extern bool_t isItemInicialized();
extern void initItem();
-extern item_t* newItem(int x, int y, int type);
-extern void addNewItem(list_t *listItem);
+extern item_t* newItem(int x, int y, int type, tux_t *author);
+extern void addNewItem(list_t *listItem, tux_t *author);
extern void drawItem(item_t *p);
extern void drawListItem(list_t *listItem);
extern void eventListItem(list_t *listItem);
diff --git a/include/screen_table.h b/include/screen_table.h
new file mode 100644
index 0000000..d16cbbb
--- /dev/null
+++ b/include/screen_table.h
@@ -0,0 +1,17 @@
+
+#ifndef SCREEN_TABLE_H
+
+#define SCREEN_TABLE_H
+
+#define SCREEN_TABLE_MAX_PLAYERS 10
+#define SCREEN_TABLE_FILE_HIGHSCORE_NAME "highscore"
+
+extern void startScreenTable();
+extern void drawScreenTable();
+extern void eventScreenTable();
+extern void stopScreenTable();
+extern int addPlayerInHighScore(char *name, int score);
+extern void initScreenTable();
+extern void quitScreenTable();
+
+#endif
diff --git a/src/Makefile b/src/Makefile
index f96674f..fd17130 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,8 +1,8 @@
CC = gcc
-CFLAGS = -g -O0 -DDISTDIR=\"$(DISTDIR)\" `sdl-config --cflags` -I../include -Wall
-#CFLAGS = -O2 -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
@@ -11,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 screen_credits.o teleport.o pipe.o homeDirector.o
+ widget_buttonimage.o screen_credits.o teleport.o pipe.o homeDirector.o screen_table.o
tuxanci-ng: $(FILES)
$(CC) $(CFLAGS) $(LIBS) -o tuxanci-ng $(FILES)
@@ -142,5 +142,8 @@ pipe.o: pipe.c ../include/pipe.h
homeDirector.o: homeDirector.c ../include/homeDirector.h
$(CC) $(CFLAGS) -o homeDirector.o -c homeDirector.c
+screen_table.o: screen_table.c ../include/screen_table.h
+ $(CC) $(CFLAGS) -o screen_table.o -c screen_table.c
+
clean:
rm -rf *.o *.c~ *.h~ tuxanci-ng
diff --git a/src/gun.c b/src/gun.c
index 6938a88..1fd1bf1 100644
--- a/src/gun.c
+++ b/src/gun.c
@@ -223,7 +223,7 @@ static void putInGunMine(tux_t *tux)
if( isFreeSpace(x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) )
{
- addList(arena->listItem, newItem(x, y, ITEM_MINE) );
+ addList(arena->listItem, newItem(x, y, ITEM_MINE, tux) );
tux->shot[tux->gun]--;
}
}
diff --git a/src/item.c b/src/item.c
index 23c3f52..abfe2c5 100644
--- a/src/item.c
+++ b/src/item.c
@@ -44,7 +44,7 @@ void initItem()
isItemInit = TRUE;
}
-item_t* newItem(int x, int y, int type)
+item_t* newItem(int x, int y, int type, tux_t *author)
{
item_t *new;
@@ -58,6 +58,7 @@ item_t* newItem(int x, int y, int type)
new->frame = 0;
new->count = 0;
new->img = g_item[type];
+ new->author = author;
switch( type )
{
@@ -101,7 +102,7 @@ item_t* newItem(int x, int y, int type)
return new;
}
-void addNewItem(list_t *listItem)
+void addNewItem(list_t *listItem, tux_t *author)
{
arena_t *arena;
item_t *item;
@@ -147,7 +148,7 @@ void addNewItem(list_t *listItem)
}
}while( isSettingItem(type) == FALSE );
- item = newItem(new_x, new_y, type);
+ item = newItem(new_x, new_y, type, author);
addList(listItem, item);
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
@@ -298,7 +299,7 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot)
x = ( thisItem->x + thisItem->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2;
y = ( thisItem->y + thisItem->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2;
- addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION) );
+ addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, NULL) );
j--;
}
break;
@@ -359,8 +360,13 @@ void eventGiveTuxItem(tux_t *tux, list_t *listItem)
case ITEM_MINE :
if( tux->bonus != BONUS_GHOST )
{
+ if( thisItem->author != NULL )
+ {
+ thisItem->author->score++;
+ }
+
delListItem(listItem, i, destroyItem);
- addList(listItem, newItem(x, y, ITEM_EXPLOSION) );
+ addList(listItem, newItem(x, y, ITEM_EXPLOSION, NULL) );
i--;
}
break;
diff --git a/src/main.c b/src/main.c
index 780c4b6..195d6cb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -14,6 +14,7 @@
#include "screen_setting.h"
#include "screen_gameType.h"
#include "screen_choiceArena.h"
+#include "screen_table.h"
#include "screen_credits.h"
#include "homeDirector.h"
#include "wall.h"
@@ -53,6 +54,7 @@ static void init()
initScreenGameType();
initScreenChoiceArena();
initScreenCredits();
+ initScreenTable();
}
void quit()
@@ -77,6 +79,7 @@ void quit()
quitScreenGameType();
quitScreenChoiceArena();
quitScreenCredits();
+ quitScreenTable();
printf("quit..\n");
diff --git a/src/net_multiplayer.c b/src/net_multiplayer.c
index 536474a..3db7572 100644
--- a/src/net_multiplayer.c
+++ b/src/net_multiplayer.c
@@ -340,8 +340,15 @@ void proto_recv_deltux_client(char *msg)
void proto_send_additem_server(item_t *p)
{
char msg[STR_SIZE];
-
- sprintf(msg, "additem %d %d %d %d %d\n", p->type, p->x, p->y, p->count, p->frame);
+ int id = -1;
+
+ if( p->author != NULL )
+ {
+ id = p->author->id;
+ }
+
+ sprintf(msg, "additem %d %d %d %d %d %d\n",
+ p->type, p->x, p->y, p->count, p->frame, id);
sendAllClient(msg);
}
@@ -349,12 +356,12 @@ void proto_send_additem_server(item_t *p)
void proto_recv_additem_client(char *msg)
{
char cmd[STR_SIZE];
- int type, x, y, count, frame;
+ int type, x, y, count, frame, id;
item_t *item;
- sscanf(msg, "%s %d %d %d %d %d\n", cmd, &type, &x, &y, &count, &frame);
+ sscanf(msg, "%s %d %d %d %d %d %d\n", cmd, &type, &x, &y, &count, &frame, &id);
- item = newItem(x, y, type);
+ item = newItem(x, y, type, getTuxID(arena->listTux, id));
if( isConflictWithListItem(arena->listItem, item->x, item->y, item->w, item->h) )
{
diff --git a/src/screen_mainMenu.c b/src/screen_mainMenu.c
index 3e54323..f36a21d 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_table )
+ {
+ setScreen("table");
+ }
+
if( button == button_credits )
{
setScreen("credits");
diff --git a/src/screen_setting.c b/src/screen_setting.c
index 9c4675c..804639b 100644
--- a/src/screen_setting.c
+++ b/src/screen_setting.c
@@ -191,6 +191,8 @@ static void initSettingFile()
loadValueFromConfigFile(configFile, "GUN_DUAL_SIMPLE", val, STR_SIZE, "YES");
check[GUN_DUAL_SIMPLE]->status = isYesOrNO(val);
+ loadValueFromConfigFile(configFile, "GUN_SCATTER", val, STR_SIZE, "YES");
+ check[GUN_SCATTER]->status = isYesOrNO(val);
loadValueFromConfigFile(configFile, "GUN_TOMMY", val, STR_SIZE, "YES");
check[GUN_TOMMY]->status = isYesOrNO(val);
loadValueFromConfigFile(configFile, "GUN_LASSER", val, STR_SIZE, "YES");
@@ -218,15 +220,26 @@ static void initSettingFile()
loadValueFromConfigFile(configFile, "SOUND", val, STR_SIZE, "YES");
check_sound->status = isYesOrNO(val);
+
+ saveTextFile(configFile);
}
static void saveAndDestroyConfigFile()
{
+ if( configFile == NULL )
+ {
+ fprintf(stderr, "i can't save configure, "
+ "because config file not created !\n");
+
+ return;
+ }
+
setValueInConfigFile(configFile, "COUNT_ROUND", textfield_count_cound->text );
setValueInConfigFile(configFile, "NAME_PLAYER_RIGHT", textfield_name_player1->text );
setValueInConfigFile(configFile, "NAME_PLAYER_LEFT", textfield_name_player2->text );
setValueInConfigFile(configFile, "GUN_DUAL_SIMPLE", getYesOrNo(check[GUN_DUAL_SIMPLE]->status) );
+ setValueInConfigFile(configFile, "GUN_SCATTER", getYesOrNo(check[GUN_SCATTER]->status) );
setValueInConfigFile(configFile, "GUN_TOMMY", getYesOrNo(check[GUN_TOMMY]->status) );
setValueInConfigFile(configFile, "GUN_LASSER", getYesOrNo(check[GUN_LASSER]->status) );
setValueInConfigFile(configFile, "GUN_MINE", getYesOrNo(check[GUN_MINE]->status) );
diff --git a/src/screen_table.c b/src/screen_table.c
new file mode 100644
index 0000000..c071572
--- /dev/null
+++ b/src/screen_table.c
@@ -0,0 +1,231 @@
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "main.h"
+#include "interface.h"
+#include "list.h"
+#include "textFile.h"
+#include "homeDirector.h"
+#include "screen.h"
+#include "image.h"
+#include "music.h"
+#include "screen_table.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 *listWidgetLabelNumer;
+static list_t *listWidgetLabelName;
+static list_t *listWidgetLabelScore;
+
+static textFile_t *textFile;
+
+void startScreenTable()
+{
+ playMusic("menu", MUSIC_GROUP_BASE);
+}
+
+void drawScreenTable()
+{
+ int i;
+
+ drawWidgetImage(image_backgorund);
+
+ drawWidgetButton(button_back);
+
+ for( i = 0 ; i < listWidgetLabelNumer->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelNumer->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelName->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelName->list[i];
+ drawWidgetLabel(this);
+ }
+
+ for( i = 0 ; i < listWidgetLabelScore->count ; i++ )
+ {
+ widget_label_t *this;
+ this = (widget_label_t *)listWidgetLabelScore->list[i];
+ drawWidgetLabel(this);
+ }
+}
+
+void eventScreenTable()
+{
+ eventWidgetButton(button_back);
+}
+
+void stopScreenTable()
+{
+}
+
+static void eventWidget(void *p)
+{
+ widget_button_t *button;
+
+ button = (widget_button_t *)(p);
+
+ if( button == button_back )
+ {
+ setScreen("mainMenu");
+ }
+}
+
+static void setWidgetLabel()
+{
+ int i;
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "File %s not loaded !",
+ SCREEN_TABLE_FILE_HIGHSCORE_NAME);
+
+ return;
+ }
+
+ if( listWidgetLabelNumer != NULL ||
+ listWidgetLabelName != NULL ||
+ listWidgetLabelScore != NULL )
+ {
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+ }
+
+ listWidgetLabelNumer = newList();
+ listWidgetLabelName = newList();
+ listWidgetLabelScore = newList();
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ widget_label_t *label;
+ char name[STR_NAME_SIZE];
+ char score[STR_NUM_SIZE];
+ char num[STR_NUM_SIZE];
+ char *line;
+
+ line = (char *) textFile->text->list[i];
+
+ sscanf(line, "%s %s", name, score);
+ sprintf(num, "%2d)", i+1);
+
+ label = newWidgetLabel(num, WINDOW_SIZE_X/2 - 100, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelNumer, label);
+
+ label = newWidgetLabel(name, WINDOW_SIZE_X/2, 200 + i * 20, WIDGET_LABEL_CENTER);
+ addList(listWidgetLabelName, label);
+
+ label = newWidgetLabel(score, WINDOW_SIZE_X/2 + 80, 200 + i * 20, WIDGET_LABEL_LEFT);
+ addList(listWidgetLabelScore, label);
+ }
+}
+
+static void loadHighscoreFile()
+{
+ char path[STR_PATH_SIZE];
+ int i;
+
+ sprintf(path, "%s/" SCREEN_TABLE_FILE_HIGHSCORE_NAME , getHomeDirector());
+ textFile = loadTextFile(path);
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "I can't load %s !\n", path);
+ fprintf(stderr, "I create %s\n", path);
+ textFile = newTextFile(path);
+ }
+ else
+ {
+ return;
+ }
+
+ if( textFile == NULL )
+ {
+ fprintf(stderr, "I can't create %s !\n", path);
+ return;
+ }
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ addList(textFile->text, strdup("no_name 0") );
+ }
+
+ saveTextFile(textFile);
+}
+
+int addPlayerInHighScore(char *name, int score)
+{
+ int i;
+
+ for( i = 0 ; i < SCREEN_TABLE_MAX_PLAYERS ; i++ )
+ {
+ char *line;
+ char thisName[STR_NAME_SIZE];
+ int thisCore;
+
+ line = (char *) textFile->text->list[i];
+ sscanf(line, "%s %d", thisName, &thisCore);
+
+ if( score >= thisCore )
+ {
+ char new[STR_SIZE];
+
+ sprintf(new, "%s %d", name, score);
+ insList(textFile->text, i, strdup(new) );
+ delListItem(textFile->text, SCREEN_TABLE_MAX_PLAYERS, free);
+ setWidgetLabel();
+
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+void initScreenTable()
+{
+ SDL_Surface *image;
+
+
+ image = addImageData("screen_table.png", IMAGE_NO_ALPHA, "screen_table", IMAGE_GROUP_BASE);
+ image_backgorund = newWidgetImage(0, 0, image);
+
+ button_back = newWidgetButton("Back", WINDOW_SIZE_X/2 -WIDGET_BUTTON_WIDTH/2,
+ WINDOW_SIZE_Y-100, eventWidget);
+
+ loadHighscoreFile();
+ listWidgetLabelNumer = NULL;
+ listWidgetLabelName = NULL;
+ listWidgetLabelScore = NULL;
+ setWidgetLabel();
+
+ registerScreen( newScreen("table", startScreenTable, eventScreenTable,
+ drawScreenTable, stopScreenTable) );
+}
+
+void quitScreenTable()
+{
+ destroyWidgetImage(image_backgorund);
+
+ destroyWidgetButton(button_back);
+ destroyListItem(listWidgetLabelNumer, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelName, destroyWidgetLabel);
+ destroyListItem(listWidgetLabelScore, destroyWidgetLabel);
+
+ if( textFile != NULL )
+ {
+ saveTextFile(textFile);
+ destroyTextFile(textFile);
+ }
+}
+
diff --git a/src/screen_world.c b/src/screen_world.c
index 439cefa..b35e82e 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -11,6 +11,7 @@
#include "screen_setting.h"
#include "screen_gameType.h"
#include "screen_choiceArena.h"
+#include "screen_table.h"
#include "list.h"
#include "layer.h"
@@ -135,7 +136,7 @@ void prepareArena()
{
case NET_GAME_TYPE_NONE :
setWorldArena( getChoiceArenaId() );
- addNewItem(arena->listItem);
+ addNewItem(arena->listItem, NULL);
playMusic(arena->music, MUSIC_GROUP_USER);
getSettingCountRound(&max_count);
@@ -152,7 +153,7 @@ void prepareArena()
case NET_GAME_TYPE_SERVER :
setWorldArena( getChoiceArenaId() );
- addNewItem(arena->listItem);
+ addNewItem(arena->listItem, NULL);
playMusic(arena->music, MUSIC_GROUP_USER);
getSettingCountRound(&max_count);
@@ -409,8 +410,33 @@ static void setAnalyze()
endAnalyze();
}
+static void setTable()
+{
+ tux_t *tuxRight;
+ tux_t *tuxLeft;
+
+ if( getSettingGameType() != NET_GAME_TYPE_NONE )
+ {
+ return;
+ }
+
+ tuxRight = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
+ tuxLeft = getControlTux(TUX_CONTROL_KEYBOARD_LEFT);
+
+ if( tuxRight->score > tuxLeft->score )
+ {
+ addPlayerInHighScore(tuxRight->name, tuxRight->score);
+ }
+
+ if( tuxLeft->score > tuxRight->score )
+ {
+ addPlayerInHighScore(tuxLeft->name, tuxLeft->score);
+ }
+}
+
void stoptWorld()
{
+ setTable();
setAnalyze();
delAllImageInGroup(IMAGE_GROUP_USER);
quitNetMultiplayer();
diff --git a/src/tux.c b/src/tux.c
index 8180094..2f8c6fc 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -300,7 +300,7 @@ static void timer_spawnTux(void *p)
setTuxProportion(tux, x, y);
tux->gun = GUN_SIMPLE;
- addNewItem(arena->listItem);
+ addNewItem(arena->listItem, NULL);
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
@@ -365,7 +365,7 @@ void eventTuxIsDead(tux_t *tux)
}
}
-static void eventTuxIsDeadWIthShot(tux_t *tux,shot_t *shot)
+static void eventTuxIsDeadWIthShot(tux_t *tux, shot_t *shot)
{
shot->author->score++;
countRoundInc();
diff --git a/src/widget_label.c b/src/widget_label.c
index 0cb0929..9cb9718 100644
--- a/src/widget_label.c
+++ b/src/widget_label.c
@@ -26,7 +26,7 @@ void drawWidgetLabel(widget_label_t *p)
drawFont(p->text, p->x+p->w, p->y, COLOR_WHITE);
break;
case WIDGET_LABEL_LEFT :
- drawFont(p->text, p->x, p->y+p->h/2, COLOR_WHITE);
+ drawFont(p->text, p->x, p->y, COLOR_WHITE);
break;
case WIDGET_LABEL_CENTER :
drawFont(p->text, p->x-p->w/2, p->y, COLOR_WHITE);