Skip to content

Commit

Permalink
Only AI missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Matthes committed Jul 23, 2014
1 parent c487c1a commit 2200289
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ SDL = `sdl-config --cflags`

SPARROW_FOLDER = ../sparrow3d

#TARGET = nativ
TARGET = nativ

ifdef TARGET
include $(SPARROW_FOLDER)/target-files/$(TARGET).mk

#TARGET = pandora
TARGET = pandora

BUILD = ./build/$(TARGET)/hase
SPARROW_LIB = $(SPARROW_FOLDER)/build/$(TARGET)/sparrow3d
Expand Down
1 change: 0 additions & 1 deletion ToDo
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
1 bessere AI
2 Was, wenn er einfach abhaut? Abstürzt?

http://pastebin.com/P0q6QE86
Binary file added data/keyboard320.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/keyboardShift320.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion hase.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ int hase(void ( *resize )( Uint16 w, Uint16 h ),pGame game,pPlayer me_list)

int result = spLoop(draw,calc,10,resize,NULL);
stop_thread();
if (result)
if (result == 2)
{
int i;
for (i = 0; i < player_count; i ++)
Expand Down
2 changes: 2 additions & 0 deletions lobby.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ void resize( Uint16 w, Uint16 h )
spFontAddButton( font, 'w', SP_BUTTON_UP_NAME, 65535, spGetRGB(127,127,127) ); // w == up button
spFontAddButton( font, 's', SP_BUTTON_DOWN_NAME, 65535, spGetRGB(127,127,127) ); // s == down button
spFontMulWidth(font,spFloatToFixed(0.9f));

spSetVirtualKeyboard(SP_VIRTUAL_KEYBOARD_IF_NEEDED,0,h-w*48/320,w,w*48/320,spLoadSurface("./data/keyboard320.png"),spLoadSurface("./data/keyboardShift320.png"));
}

int main(int argc, char **argv)
Expand Down
33 changes: 23 additions & 10 deletions lobbyGame.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ void lg_draw(void)
//Informations
int w = screen->w-8-l_w;
spFontDrawMiddle(screen->w-2-w/2, 1*lg_font->maxheight, 0, "Game Info", lg_font );
sprintf(buffer,"Sec. per turn: %i",lg_game->seconds_per_turn);
sprintf(buffer,"Seconds per turn: %i",lg_game->seconds_per_turn);
spFontDraw(screen->w-w, 2*lg_font->maxheight, 0, buffer, lg_font );
sprintf(buffer,"Max. players: %i",lg_game->max_player);
sprintf(buffer,"Maximum players: %i",lg_game->max_player);
spFontDraw(screen->w-w, 3*lg_font->maxheight, 0, buffer, lg_font );
spFontDraw(screen->w-w, 4*lg_font->maxheight, 0, "Players:", lg_font );
//player block
Expand All @@ -54,19 +54,26 @@ void lg_draw(void)
if (lg_block)
spFontDrawTextBlock(middle,screen->w-w-4, 5*lg_font->maxheight-1, 0,lg_block,h,0,lg_font);
//Instructions on the right
spFontDrawMiddle(screen->w-2-w/2, h+5*lg_font->maxheight, 0, "[w]Add pl. [s]Rem. pl.", lg_font );
#ifdef PANDORA
spFontDrawMiddle(screen->w-2-w/2, h+5*lg_font->maxheight, 0, "[w]Add player [s]Remove player", lg_font );
#else
spFontDrawMiddle(screen->w-2-w/2, h+5*lg_font->maxheight, 0, "[w]Add player [s]Remove pl.", lg_font );
#endif
if (lg_game->admin_pw == 0)
{
spFontDrawMiddle(screen->w-2-w/2, h+6*lg_font->maxheight, 0, "The game master will", lg_font );
spFontDrawMiddle(screen->w-2-w/2, h+7*lg_font->maxheight, 0, "start the game soon™.", lg_font );
}
else
{
spFontDrawMiddle(screen->w-2-w/2, h+6*lg_font->maxheight, 0, "[d]New level [a]Start", lg_font );
spFontDrawMiddle(screen->w-2-w/2, h+7*lg_font->maxheight, 0, "[q]Add AI [e]Rem. all AI", lg_font );
spFontDrawMiddle(screen->w-2-w/2, h+6*lg_font->maxheight, 0, "[q]Add AI [e]Remove all AIs", lg_font );
spFontDrawMiddle(screen->w-2-w/2, h+7*lg_font->maxheight, 0, "[a]Start game [d]New level", lg_font );
}
//Chat
spRectangle(screen->w/2, l_w+(4+CHAT_LINES)*lg_font->maxheight/2+4, 0,screen->w-4,CHAT_LINES*lg_font->maxheight,LL_FG);
if (lg_game->local)
spFontDrawMiddle(screen->w/2, l_w+(3+CHAT_LINES)*lg_font->maxheight/2+4, 0,"No chat in local game",lg_font);
else
if (lg_chat_block)
spFontDrawTextBlock(left,4, l_w+2*lg_font->maxheight+4, 0,lg_chat_block,CHAT_LINES*lg_font->maxheight,lg_scroll,lg_font);
//Footline
Expand All @@ -77,6 +84,9 @@ void lg_draw(void)
}
else
{
if (lg_game->local)
spFontDraw( 2, screen->h-lg_font->maxheight, 0, "[B]Leave and close game", lg_font );
else
if (lg_game->admin_pw == 0)
spFontDraw( 2, screen->h-lg_font->maxheight, 0, "[R]Chat [B]Leave game", lg_font );
else
Expand Down Expand Up @@ -221,7 +231,7 @@ int lg_calc(Uint32 steps)
if (lg_chat_block->line_count > CHAT_LINES)
lg_scroll = SP_ONE;
}
if (spGetInput()->button[SP_BUTTON_START])
if (!lg_game->local && spGetInput()->button[SP_BUTTON_START])
{
spGetInput()->button[SP_BUTTON_START] = 0;
char m[256] = "";
Expand Down Expand Up @@ -345,7 +355,8 @@ int lg_calc(Uint32 steps)
spGetInput()->button[SP_BUTTON_RIGHT] = 0;
create_level_string(lg_game->level_string,1536,1536,3,3,3);
spDeleteSurface(lg_level);
lg_level = create_level(lg_game->level_string,spGetWindowSurface()->h-3*lg_font->maxheight,spGetWindowSurface()->h-3*lg_font->maxheight,LL_BG);
int l_w = spGetWindowSurface()->h-(4+CHAT_LINES)*lg_font->maxheight;
lg_level = create_level(lg_game->level_string,l_w,l_w,LL_BG);
sprintf(lg_level_string,"%s",lg_game->level_string);
set_level(lg_game,lg_level_string);
}
Expand Down Expand Up @@ -409,7 +420,7 @@ int lg_reload()
}
if (lg_block)
spDeleteTextBlock(lg_block);
int l_w = spGetWindowSurface()->h-7*lg_font->maxheight;
int l_w = spGetWindowSurface()->h-(4+CHAT_LINES)*lg_font->maxheight;
lg_block = spCreateTextBlock(temp,spGetWindowSurface()->w-8-l_w,lg_font);
if (lg_level == NULL || strcmp(lg_level_string,lg_game->level_string))
{
Expand Down Expand Up @@ -451,9 +462,11 @@ void start_lobby_game(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h )
lg_chat_block = NULL;
lg_last_chat = NULL;
lg_chat_text[0] = 0;
start_chat_listener(lg_player);
if (!lg_game->local)
start_chat_listener(lg_player);
int res = spLoop(lg_draw,lg_calc,10,resize,NULL);
stop_chat_listener(lg_player);
if (!lg_game->local)
stop_chat_listener(lg_player);
if (lg_block)
spDeleteTextBlock(lg_block);
if (res == -1)
Expand Down
15 changes: 13 additions & 2 deletions message.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ void message_draw(void)
spSetAlphaPattern4x4(196,0);
spRectangle(screen->w/2,screen->h/2,0,screen->w,screen->h,LL_BG);
spDeactivatePattern();

if (spIsKeyboardPolled() && spGetVirtualKeyboardState() == SP_VIRTUAL_KEYBOARD_ALWAYS)
spBlitSurface(screen->w/2,screen->h-spGetVirtualKeyboard()->h/2,0,spGetVirtualKeyboard());

char buffer[256];
if (mg_button_count < 0)
{
Expand All @@ -27,6 +31,10 @@ void message_draw(void)
spRectangleBorder(screen->w/2,screen->h/2,0,screen->w/2+2*meow,screen->h/2+2*meow,meow,meow,LL_FG);
spFontDrawMiddle( screen->w/2, 6*screen->h/23, 0, "Create game", mg_font );
sprintf(buffer,"Name: %s",mg_name);
int x = (screen->w+spFontWidth(buffer,mg_font))/2;
if (mg_sel == 1 && mg_pos == 0 && (SDL_GetTicks() >> 9) & 1)
spLine(x,8*screen->h/23-0*mg_font->maxheight/2, 0,
x,8*screen->h/23+2*mg_font->maxheight/2, 0,65535);
spFontDrawMiddle( screen->w/2, 8*screen->h/23, 0, buffer, mg_font );
sprintf(buffer,"Maximum players: %i",*mg_players);
spFontDrawMiddle( screen->w/2,10*screen->h/23, 0, buffer, mg_font );
Expand Down Expand Up @@ -67,7 +75,10 @@ void message_draw(void)
}
}
else
spFontDrawMiddle( screen->w/2,16*screen->h/23, 0, "[a]Select [w]Create [d]Cancel", mg_font );
if (*mg_online == -1 && mg_pos == 3)
spFontDrawMiddle( screen->w/2,16*screen->h/23, 0, "[w]Create [d]Cancel", mg_font );
else
spFontDrawMiddle( screen->w/2,16*screen->h/23, 0, "[a]Select [w]Create [d]Cancel", mg_font );
spFlip();
}
else
Expand Down Expand Up @@ -114,7 +125,7 @@ int message_calc(Uint32 steps)
spGetInput()->button[SP_BUTTON_UP] = 0;
return 1;
}
if (spGetInput()->button[SP_BUTTON_LEFT])
if (spGetInput()->button[SP_BUTTON_LEFT] && (*mg_online != -1 || mg_pos != 3))
{
spGetInput()->button[SP_BUTTON_LEFT] = 0;
mg_sel = 1-mg_sel;
Expand Down
4 changes: 2 additions & 2 deletions trace.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define TRACE_LENGTH 20
#define TRACE_STEP 100
#define TRACE_LENGTH 10
#define TRACE_STEP 150
#define TRACE_UPDATE 5
int trace_count = TRACE_UPDATE-1;
typedef struct sTrace
Expand Down

0 comments on commit 2200289

Please sign in to comment.