summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/Makefile5
-rw-r--r--src/client.c5
-rw-r--r--src/item.c140
-rwxr-xr-xsrc/modules.c3
-rw-r--r--src/proto.c192
-rw-r--r--src/screen_setting.c56
-rw-r--r--src/screen_world.c9
-rw-r--r--src/server.c2
-rw-r--r--src/tux.c23
-rw-r--r--src/widget_select.c99
10 files changed, 258 insertions, 276 deletions
diff --git a/src/Makefile b/src/Makefile
index d730826..29273cb 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -14,7 +14,7 @@ FILES = interface.o space.o idManager.o storage.o font.o list.o modules.o\
screen.o screen_world.o shot.o myTimer.o panel.o net_multiplayer.o \
buffer.o arena.o arenaFile.o textFile.o audio.o sound.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_check.o widget_image.o widget_select.o screen_setting.o screen_gameType.o screen_choiceArena.o \
widget_buttonimage.o screen_credits.o homeDirector.o screen_table.o \
sdl_udp.o proto.o server.o client.o term.o keytable.o language.o game.o
@@ -171,6 +171,9 @@ widget_check.o: widget_check.c ../include/widget_check.h
widget_image.o: widget_image.c ../include/widget_image.h
$(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_image.o -c widget_image.c
+widget_select.o: widget_select.c ../include/widget_select.h
+ $(CC) $(CFLAGS) -o $(BUILD_DIR)/widget_select.o -c widget_select.c
+
#teleport.o: teleport.c ../include/teleport.h
# $(CC) $(CFLAGS) -o $(BUILD_DIR)/teleport.o -c teleport.c
diff --git a/src/client.c b/src/client.c
index 0009909..2210a3a 100644
--- a/src/client.c
+++ b/src/client.c
@@ -156,13 +156,10 @@ void eventServerBuffer()
if( strncmp(line, "init", 4) == 0 )proto_recv_init_client(line);
if( strncmp(line, "event", 5) == 0 )proto_recv_event_client(line);
if( strncmp(line, "newtux", 6) == 0 )proto_recv_newtux_client(line);
- if( strncmp(line, "deltux", 6) == 0 )proto_recv_deltux_client(line);
+ if( strncmp(line, "del", 3) == 0 )proto_recv_del_client(line);
if( strncmp(line, "additem", 7) == 0 )proto_recv_additem_client(line);
- if( strncmp(line, "item", 4) == 0 )proto_recv_item_client(line);
if( strncmp(line, "shot", 4) == 0 )proto_recv_shot_client(line);
- if( strncmp(line, "delshot", 7) == 0 )proto_recv_delshot_client(line);
if( strncmp(line, "kill", 4) == 0 )proto_recv_kill_client(line);
- if( strncmp(line, "score", 5) == 0 )proto_recv_score_client(line);
if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_client(line);
if( strncmp(line, "end", 3) == 0 )proto_recv_end_client(line);
diff --git a/src/item.c b/src/item.c
index 171ac76..7100e5c 100644
--- a/src/item.c
+++ b/src/item.c
@@ -348,38 +348,8 @@ void eventListItem(space_t *spaceItem)
}
}
-/*
-int isConflictWithListItem(list_t *listItem, int x, int y, int w, int h)
-{
- item_t *thisItem;
- int i;
-
- assert( listItem != NULL );
-
- for( i = 0 ; i < listItem->count ; i++ )
- {
- thisItem = (item_t *)listItem->list[i];
- assert( thisItem != NULL );
-
- if( conflictSpace(x, y, w, h,
- thisItem->x, thisItem->y, thisItem->w, thisItem->h) )
- {
- return 1;
- }
- }
-
- return 0;
-}
-*/
-
void mineExplosion(space_t *spaceItem, item_t *item)
{
-/*
- x = ( item->x + item->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2;
- y = ( item->y + item->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2;
- addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, item->author_id) );
-*/
-
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
int x, y;
@@ -398,78 +368,13 @@ void mineExplosion(space_t *spaceItem, item_t *item)
addObjectToSpace(spaceItem, item_explosion );
}
- delObjectFromSpaceWithObject(spaceItem, item, destroyItem);
-}
-
-/*
-void eventConflictShotWithItem(list_t *listItem, list_t *listShot)
-{
- shot_t *thisShot;
- item_t *thisItem;
- int i, j;
-
- if( getNetTypeGame() == NET_GAME_TYPE_CLIENT )
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- return;
+ proto_send_del_server(PROTO_SEND_ALL, NULL, item->id);
}
- assert( listItem != NULL );
- assert( listShot != NULL );
-
- for( i = 0 ; i < listShot->count ; i++ )
- {
- bool_t isDelShot;
-
- isDelShot = FALSE;
- thisShot = (shot_t *)listShot->list[i];
- assert( thisShot != NULL );
-
- for( j = 0 ; j < listItem->count ; j++ )
- {
- thisItem = (item_t *)listItem->list[j];
- assert( thisItem != NULL );
-
- if( conflictSpace(thisShot->x, thisShot->y, thisShot->w, thisShot->h,
- thisItem->x, thisItem->y, thisItem->w, thisItem->h) )
- {
- switch( thisItem->type )
- {
- case ITEM_MINE :
-
- if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
- {
- if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
- {
- proto_send_item_server(PROTO_SEND_ALL, NULL, NULL, thisItem);
- }
-
- mineExplosion(listItem, thisItem);
- j--;
- }
- break;
-
- case ITEM_EXPLOSION :
- case ITEM_BIG_EXPLOSION :
- isDelShot = TRUE;
-
- break;
- }
- }
- }
-
- if( isDelShot )
- {
- if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
- {
- proto_send_delshot_server(PROTO_SEND_ALL, NULL, thisShot);
- }
-
- delListItem(listShot, i, destroyShot);
- i--;
- }
- }
+ delObjectFromSpaceWithObject(spaceItem, item, destroyItem);
}
-*/
void eventConflictShotWithItem(arena_t *arena)
{
@@ -503,11 +408,6 @@ void eventConflictShotWithItem(arena_t *arena)
case ITEM_MINE :
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
- if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
- {
- proto_send_item_server(PROTO_SEND_ALL, NULL, NULL, thisItem);
- }
-
mineExplosion(arena->spaceItem, thisItem);
}
break;
@@ -523,10 +423,10 @@ void eventConflictShotWithItem(arena_t *arena)
{
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- proto_send_delshot_server(PROTO_SEND_ALL, NULL, thisShot);
+ proto_send_del_server(PROTO_SEND_ALL, NULL, thisShot->id);
}
- delObjectFromSpaceWithObject(arena->spaceShot, thisItem, destroyShot);
+ delObjectFromSpaceWithObject(arena->spaceShot, thisShot, destroyShot);
i--;
}
}
@@ -557,7 +457,7 @@ static void eventTuxIsDeadWithItem(tux_t *tux, item_t *item)
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- proto_send_score_server(PROTO_SEND_ALL, NULL, author);
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, author);
}
}
}
@@ -579,6 +479,11 @@ static void tuxGiveBonus(tux_t *tux, item_t *item)
sprintf(msg, "tux with id %d bonus enabled\n", tux->id);
appendTextInTerm(msg);
#endif
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
+ }
}
static void tuxGiveGun(tux_t *tux, item_t *item)
@@ -597,6 +502,10 @@ static void tuxGiveGun(tux_t *tux, item_t *item)
appendTextInTerm(msg);
#endif
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
+ }
}
void eventGiveTuxItem(tux_t *tux, item_t *item, space_t *spaceItem)
@@ -610,6 +519,12 @@ void eventGiveTuxItem(tux_t *tux, item_t *item, space_t *spaceItem)
case GUN_MINE :
case GUN_BOMBBALL :
tuxGiveGun(tux, item);
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_del_server(PROTO_SEND_ALL, NULL, item->id);
+ }
+
delObjectFromSpaceWithObject(spaceItem, item, destroyItem);
break;
@@ -632,6 +547,12 @@ void eventGiveTuxItem(tux_t *tux, item_t *item, space_t *spaceItem)
case BONUS_4X :
case BONUS_HIDDEN :
tuxGiveBonus(tux, item);
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_del_server(PROTO_SEND_ALL, NULL, item->id);
+ }
+
delObjectFromSpaceWithObject(spaceItem, item, destroyItem);
break;
}
@@ -666,12 +587,13 @@ void eventGiveTuxListItem(tux_t *tux, space_t *spaceItem)
thisItem = (item_t *)listHelp->list[i];
assert( thisItem != NULL );
+ eventGiveTuxItem(tux, thisItem, spaceItem);
+
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- proto_send_item_server(PROTO_SEND_ALL, NULL, tux, thisItem);
+ //proto_send_item_server(PROTO_SEND_ALL, NULL, tux, thisItem);
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
}
-
- eventGiveTuxItem(tux, thisItem, spaceItem);
}
}
diff --git a/src/modules.c b/src/modules.c
index bf7eec6..34224a4 100755
--- a/src/modules.c
+++ b/src/modules.c
@@ -39,6 +39,9 @@ static export_fce_t export_fce =
.fce_getTuxProportion = getTuxProportion,
.fce_setTuxProportion = setTuxProportion,
//.fce_getTuxID = getTuxID,
+ .fce_actionTux = actionTux,
+
+ .fce_getMyTime = getMyTime,
.fce_getCurrentArena = getCurrentArena,
.fce_conflictSpace = conflictSpace,
diff --git a/src/proto.c b/src/proto.c
index 72e8f16..f33f74f 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -341,8 +341,6 @@ void proto_send_event_server(int type, client_t *client, tux_t *tux, int action)
{
char msg[STR_PROTO_SIZE];
- assert( tux != NULL );
-
sprintf(msg, "event %d %d\n", tux->id, action);
proto_send(type, client, msg);
@@ -524,80 +522,66 @@ void proto_recv_kill_client(char *msg)
#endif
-void proto_send_score_server(int type, client_t *client, tux_t *tux)
+void proto_send_del_server(int type, client_t *client, int id)
{
char msg[STR_PROTO_SIZE];
-
- assert( tux != NULL );
+ int check_id;
- sprintf(msg, "score %d %d\n", tux->id, tux->score);
-
- proto_send(type, client, msg);
+ check_id = getNewID();
+
+ sprintf(msg, "del %d %d\n",
+ id, check_id);
+
+ proto_check(type, client, msg, check_id);
}
#ifndef PUBLIC_SERVER
-void proto_recv_score_client(char *msg)
+void proto_recv_del_client(char *msg)
{
char cmd[STR_PROTO_SIZE];
- int id, score;
+ int id, check_id;
tux_t *tux;
+ shot_t *shot;
+ item_t *item;
assert( msg != NULL );
- sscanf(msg, "%s %d %d", cmd, &id, &score);
+ sscanf(msg, "%s %d %d",
+ cmd, &id, &check_id);
+
+ proto_send_check_client(check_id);
tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id);
if( tux != NULL )
{
char term_msg[STR_SIZE];
- sprintf(term_msg, "tux with id %d set score to %d\n", tux->id, score);
+
+ //printf("delete tux..\n");
+ sprintf(term_msg, "tux with id %d is disconnect\n", tux->id);
appendTextInTerm(term_msg);
- tux->score = score;
+ delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux);
+ return;
}
- countRoundInc();
-}
-
-#endif
-
-void proto_send_deltux_server(int type, client_t *client, client_t *client2)
-{
- char msg[STR_PROTO_SIZE];
-
- assert( client2 != NULL );
-
- sprintf(msg, "deltux %d\n", client2->tux->id);
-
- proto_send(type, client, msg);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_deltux_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int id;
- tux_t *tux;
-
- assert( msg != NULL );
+ shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, id);
- sscanf(msg, "%s %d", cmd, &id);
+ if( shot != NULL )
+ {
+ //printf("delete shot..\n");
+ delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot);
+ return;
+ }
- tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id);
+ item = getObjectFromSpaceWithID(getCurrentArena()->spaceItem, id);
- if( tux != NULL )
+ if( item != NULL )
{
- char term_msg[STR_SIZE];
- //int index;
-
- sprintf(term_msg, "tux with id %d is disconnect\n", tux->id);
- appendTextInTerm(term_msg);
-
- //index = searchListItem(getCurrentArena()->listTux, tux);
- delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux);
+ //printf("delete item..\n");
+ delObjectFromSpaceWithObject(getCurrentArena()->spaceItem, item, destroyItem);
+ return;
}
}
@@ -645,13 +629,7 @@ void proto_recv_additem_client(char *msg)
}
item = newItem(x, y, type, author_id);
-/*
- if( isConflictWithListItem(getCurrentArena()->listItem, item->x, item->y, item->w, item->h) )
- {
- destroyItem(item);
- return;
- }
-*/
+
replaceItemID(item, id);
item->count = count;
item->frame = frame;
@@ -661,68 +639,6 @@ void proto_recv_additem_client(char *msg)
#endif
-void proto_send_item_server(int type, client_t *client, tux_t *tux, item_t *item)
-{
- char msg[STR_PROTO_SIZE];
- int tux_id = -1;
- int check_id;
-
- assert( item != NULL );
-
- if( tux != NULL )
- {
- tux_id = tux->id;
- }
-
- check_id = getNewID();
-
- sprintf(msg, "item %d %d %d\n",
- tux_id, item->id, check_id);
-
- //proto_send(type, client, msg);
- proto_check(type, client, msg, check_id);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_item_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- int tux_id, item_id, check_id;
- arena_t *arena;
-
- item_t *item;
- tux_t *tux;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d %d",
- cmd, &tux_id, &item_id, &check_id);
-
- proto_send_check_client(check_id);
-
- arena = getCurrentArena();
-
- item = getObjectFromSpaceWithID(arena->spaceItem, item_id);
- tux = getObjectFromSpaceWithID(arena->spaceTux, tux_id);
-
- if( item == NULL)
- {
- return;
- }
-
- if( tux != NULL )
- {
- eventGiveTuxItem(tux, item, arena->spaceItem);
- }
- else
- {
- mineExplosion(arena->spaceItem, item);
- }
-}
-
-#endif
-
void proto_send_shot_server(int type, client_t *client, shot_t *p)
{
char msg[STR_PROTO_SIZE];
@@ -776,46 +692,6 @@ void proto_recv_shot_client(char *msg)
#endif
-void proto_send_delshot_server(int type, client_t *client, shot_t *shot)
-{
- char msg[STR_PROTO_SIZE];
- int check_id;
-
- assert( shot != NULL );
-
- check_id = getNewID();
-
- sprintf(msg, "delshot %d %d\n",
- shot->id, check_id);
-
- proto_check(type, client, msg, check_id);
-}
-
-#ifndef PUBLIC_SERVER
-
-void proto_recv_delshot_client(char *msg)
-{
- char cmd[STR_PROTO_SIZE];
- shot_t *shot;
- int id, check_id;
-
- assert( msg != NULL );
-
- sscanf(msg, "%s %d %d",
- cmd, &id, &check_id);
-
- proto_send_check_client(check_id);
-
- shot = getObjectFromSpaceWithID(getCurrentArena()->spaceShot, id);
-
- if( shot != NULL )
- {
- delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot);
- }
-}
-
-#endif
-
#ifndef PUBLIC_SERVER
void proto_send_ping_client()
diff --git a/src/screen_setting.c b/src/screen_setting.c
index 92e88e0..5a42135 100644
--- a/src/screen_setting.c
+++ b/src/screen_setting.c
@@ -19,12 +19,14 @@
#include "tux.h"
#include "textFile.h"
#include "configFile.h"
+#include "director.h"
#include "widget_label.h"
#include "widget_button.h"
#include "widget_image.h"
#include "widget_textfield.h"
#include "widget_check.h"
+#include "widget_select.h"
static widget_image_t *image_backgorund;
@@ -33,6 +35,7 @@ static widget_button_t *button_back;
static widget_label_t *label_count_round;
static widget_label_t *label_name_player1;
static widget_label_t *label_name_player2;
+static widget_label_t *label_ai;
#ifndef NO_SOUND
static widget_label_t *label_music;
@@ -63,6 +66,8 @@ static widget_textfield_t *textfield_count_cound;
static widget_textfield_t *textfield_name_player1;
static widget_textfield_t *textfield_name_player2;
+static widget_select_t *select_ai;
+
static textFile_t *configFile;
void startScreenSetting()
@@ -79,6 +84,8 @@ void drawScreenSetting()
drawWidgetLabel(label_count_round);
drawWidgetLabel(label_name_player1);
drawWidgetLabel(label_name_player2);
+ drawWidgetLabel(label_ai);
+
#ifndef NO_SOUND
drawWidgetLabel(label_music);
drawWidgetLabel(label_sound);
@@ -117,13 +124,24 @@ void drawScreenSetting()
drawWidgetCheck(check[i]);
}
+ drawWidgetSelect(select_ai);
+
drawWidgetButton(button_back);
}
void eventScreenSetting()
{
int i;
+/*
+ int x, y;
+
+ getMousePosition(&x, &y);
+ if( isMouseClicked() )
+ {
+ printf("x = %d y = %d\n", x, y);
+ }
+*/
eventWidgetTextfield(textfield_count_cound);
eventWidgetTextfield(textfield_name_player1);
eventWidgetTextfield(textfield_name_player2);
@@ -143,6 +161,8 @@ void eventScreenSetting()
eventWidgetCheck(check[i]);
}
+ eventWidgetSelect(select_ai);
+
eventWidgetButton(button_back);
}
@@ -279,6 +299,29 @@ static void saveAndDestroyConfigFile()
destroyTextFile(configFile);
}
+static void findModulesAI()
+{
+ director_t *listModules;
+ int i;
+
+ listModules = loadDirector(PATH_MODULES);
+
+ for( i = 0 ; i < listModules->list->count ; i++)
+ {
+ char *line;
+
+ line = (char *)listModules->list->list[i];
+
+ if( strstr(line,"AI") != NULL &&
+ strstr(line,".so") != NULL )
+ {
+ addToWidgetSelect(select_ai, line);
+ }
+ }
+
+ destroyDirector(listModules);
+}
+
void initScreenSetting()
{
SDL_Surface *image;
@@ -292,6 +335,7 @@ void initScreenSetting()
label_count_round = newWidgetLabel(getMyText("COUNT_ROUND"), 100, WINDOW_SIZE_Y-200, WIDGET_LABEL_LEFT);
label_name_player1 = newWidgetLabel(getMyText("NAME_PLAYER1"), 100, WINDOW_SIZE_Y-160, WIDGET_LABEL_LEFT);
label_name_player2 = newWidgetLabel(getMyText("NAME_PLAYER2"), 100, WINDOW_SIZE_Y-120, WIDGET_LABEL_LEFT);
+ label_ai = newWidgetLabel("AI :", 430, 400, WIDGET_LABEL_LEFT);
textfield_count_cound = newWidgetTextfield(getParamElse("--count", "15"), 110+label_count_round->w, WINDOW_SIZE_Y-200);
@@ -367,6 +411,10 @@ void initScreenSetting()
initSettingFile();
+ select_ai = newWidgetSelect(label_ai->x, label_ai->y+40, eventWidget);
+ addToWidgetSelect(select_ai, "none");
+ findModulesAI();
+
#ifndef NO_SOUND
eventWidget(check_music);
eventWidget(check_sound);
@@ -388,6 +436,11 @@ void getSettingCountRound(int *n)
*n = atoi( textfield_count_cound->text );
}
+char* getSettingAI()
+{
+ return (char *) select_ai->list->list[ select_ai->select ];
+}
+
bool_t isSettingAnyItem()
{
int i;
@@ -427,6 +480,7 @@ void quitScreenSetting()
destroyWidgetLabel(label_count_round);
destroyWidgetLabel(label_name_player1);
destroyWidgetLabel(label_name_player2);
+ destroyWidgetLabel(label_ai);
#ifndef NO_SOUND
destroyWidgetLabel(label_music);
@@ -466,6 +520,8 @@ void quitScreenSetting()
destroyWidgetCheck(check[i]);
}
+ destroyWidgetSelect(select_ai);
+
destroyWidgetButton(button_back);
}
diff --git a/src/screen_world.c b/src/screen_world.c
index 077153f..a5fdc1c 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -103,6 +103,7 @@ void countRoundInc()
}
count++;
+ printf("count %d/%d\n", count, max_count);
if( count >= max_count )
{
@@ -116,6 +117,8 @@ void prepareArena()
{
tux_t *tux;
+ //printf("getSettingAI = %s\n", getSettingAI());
+
switch( getNetTypeGame() )
{
case NET_GAME_TYPE_NONE :
@@ -134,6 +137,12 @@ void prepareArena()
tuxWithControlLeftKeyboard = tux;
getSettingNameLeft(tux->name);
addObjectToSpace(arena->spaceTux, tux);
+
+ if( strcmp(getSettingAI(), "none") != 0 )
+ {
+ loadModule( getSettingAI() );
+ tux->control = TUX_CONTROL_AI;
+ }
break;
case NET_GAME_TYPE_SERVER :
diff --git a/src/server.c b/src/server.c
index 3b06a3f..bda983a 100644
--- a/src/server.c
+++ b/src/server.c
@@ -77,7 +77,7 @@ static void delZombieCLient(void *p_nothink)
{
if( thisClient->tux != NULL )
{
- proto_send_deltux_server(PROTO_SEND_ALL, NULL, thisClient);
+ proto_send_del_server(PROTO_SEND_ALL, NULL, thisClient->tux->id);
}
delListItem(listClient, i, destroyClient);
diff --git a/src/tux.c b/src/tux.c
index 710b253..c9d5ff2 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -356,7 +356,7 @@ static void eventTuxIsDeadWIthShot(tux_t *tux, shot_t *shot)
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- proto_send_score_server(PROTO_SEND_ALL, NULL, author);
+ proto_send_newtux_server(PROTO_SEND_ALL, NULL, author);
}
}
@@ -407,7 +407,7 @@ static void bombBallExplosion(shot_t *shot)
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
- proto_send_delshot_server(PROTO_SEND_ALL, NULL, shot);
+ proto_send_del_server(PROTO_SEND_ALL, NULL, shot->id);
proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
}
}
@@ -470,6 +470,22 @@ void eventConflictTuxWithShot(arena_t *arena)
}
}
+static void interval()
+{
+ static my_time_t lastEvent = 0;
+ my_time_t curentTime;
+
+ if( lastEvent == 0 )
+ {
+ lastEvent = getMyTime();
+ }
+
+ curentTime = getMyTime();
+
+ printf("time = %d\n", curentTime - lastEvent);
+
+ lastEvent = getMyTime();
+}
void moveTux(tux_t *tux, int n)
{
@@ -482,6 +498,7 @@ void moveTux(tux_t *tux, int n)
assert( tux != NULL );
arena = getCurrentArena();
+ //interval();
if( tux->position != n )
{
@@ -623,7 +640,7 @@ void actionTux(tux_t *tux, int action)
{
return;
}
-
+
switch( action )
{
case TUX_UP :
diff --git a/src/widget_select.c b/src/widget_select.c
new file mode 100644
index 0000000..dbd6fa9
--- /dev/null
+++ b/src/widget_select.c
@@ -0,0 +1,99 @@
+
+#include <stdlib.h>
+
+#include "main.h"
+#include "interface.h"
+#include "font.h"
+#include "widget_select.h"
+#include "image.h"
+
+/*
+typedef struct widget_select
+{
+ int x, y;
+ int w, h;
+ list_t *list;
+ void (*fce_event)(void *);
+} widget_select_t;
+*/
+
+widget_select_t* newWidgetSelect(int x, int y, void (*fce_event)(void *))
+{
+ widget_select_t *new;
+
+ new = malloc( sizeof(widget_select_t) );
+ new->x = x;
+ new->y = y;
+ new->select = 0;
+ new->fce_event = fce_event;
+ new->list = newList();
+
+ return new;
+}
+
+void addToWidgetSelect(widget_select_t *p, char *s)
+{
+ addList(p->list, strdup(s) );
+}
+
+void drawWidgetSelect(widget_select_t *p)
+{
+ int x, y, w, h;
+ int i;
+
+ getMousePosition(&x, &y);
+
+ for( i = 0 ; i < p->list->count ; i++ )
+ {
+ char *line;
+
+ line = (char *)p->list->list[i];
+
+ getTextSize(line, &w, &h);
+
+ if( x > p->x && y > p->y + i*20 && x < p->x+w && y < p->y + i*20 + h )
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_YELLOW);
+ }
+ else
+ {
+ if( p->select == i )
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_RED);
+ }
+ else
+ {
+ drawFont(line, p->x, p->y + i*20, COLOR_WHITE);
+ }
+ }
+ }
+}
+
+void eventWidgetSelect(widget_select_t *p)
+{
+ int x, y, w, h;
+ int i;
+
+ getMousePosition(&x, &y);
+
+ for( i = 0 ; i < p->list->count ; i++ )
+ {
+ char *line;
+
+ line = (char *)p->list->list[i];
+
+ getTextSize(line, &w, &h);
+
+ if( x > p->x && y > p->y + i*20 && x < p->x+w && y < p->y + i*20 + h && isMouseClicked() )
+ {
+ p->select = i;
+ p->fce_event(p);
+ }
+ }
+}
+
+void destroyWidgetSelect(widget_select_t *p)
+{
+ destroyListItem(p->list, free);
+ free(p);
+}