|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: single.c,v 1.37 2003/07/24 01:47:48 stpohle Exp $ */
|
|
|
|
|
/* $Id: single.c,v 1.38 2003/07/25 12:28:50 stpohle Exp $ */
|
|
|
|
|
/* single player */
|
|
|
|
|
|
|
|
|
|
#include "basic.h"
|
|
|
|
@ -60,7 +60,9 @@ single_game_new ()
|
|
|
|
|
inline int
|
|
|
|
|
ai_checkfield (int x, int y)
|
|
|
|
|
{
|
|
|
|
|
return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire || map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb ) && map.bfield[x][y] == 0);
|
|
|
|
|
return ((map.field[x][y].type == FT_nothing || map.field[x][y].type == FT_fire
|
|
|
|
|
|| map.field[x][y].type == FT_shoe || map.field[x][y].type == FT_bomb)
|
|
|
|
|
&& map.bfield[x][y] == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -290,7 +292,9 @@ ai_bombpoints (_point pos, int range)
|
|
|
|
|
p.y += m.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (map.field[p.x][p.y].type != FT_nothing && (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe || map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire))
|
|
|
|
|
if (map.field[p.x][p.y].type != FT_nothing
|
|
|
|
|
&& (map.field[p.x][p.y].type != FT_block || map.field[p.x][p.y].type == FT_shoe
|
|
|
|
|
|| map.field[p.x][p.y].type == FT_bomb || map.field[p.x][p.y].type == FT_fire))
|
|
|
|
|
points++;
|
|
|
|
|
if (map.field[p.x][p.y].type == FT_shoe || map.field[p.x][p.y].type == FT_bomb ||
|
|
|
|
|
map.field[p.x][p.y].type == FT_fire)
|
|
|
|
@ -352,8 +356,7 @@ ai_findbestbombdir (_point pos, int dir, int range)
|
|
|
|
|
if (d < 4) {
|
|
|
|
|
p[d].x += m[d].x;
|
|
|
|
|
p[d].y += m[d].y;
|
|
|
|
|
if (p[d].x > 0 && p[d].y > 0 && p[d].x < map.size.x - 1
|
|
|
|
|
&& p[d].y < map.size.y - 1) {
|
|
|
|
|
if (p[d].x > 0 && p[d].y > 0 && p[d].x < map.size.x - 1 && p[d].y < map.size.y - 1) {
|
|
|
|
|
if (ai_checkfield (p[d].x, p[d].y)) {
|
|
|
|
|
/* we are opn a empty field go on with the test */
|
|
|
|
|
done = 0;
|
|
|
|
@ -568,7 +571,10 @@ ai_checknewpos (_point pos, int d)
|
|
|
|
|
void
|
|
|
|
|
single_create_ai (int players)
|
|
|
|
|
{
|
|
|
|
|
int p, count, gfx_sel, i = 0;
|
|
|
|
|
int p,
|
|
|
|
|
count,
|
|
|
|
|
gfx_sel,
|
|
|
|
|
i = 0;
|
|
|
|
|
_player *pl;
|
|
|
|
|
|
|
|
|
|
for (count = 0; count < players; count++) {
|
|
|
|
@ -595,7 +601,8 @@ single_create_ai (int players)
|
|
|
|
|
void
|
|
|
|
|
single_playergame ()
|
|
|
|
|
{
|
|
|
|
|
int p, done = 0;
|
|
|
|
|
int p,
|
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
|
|
/* delete player from the game */
|
|
|
|
|
for (p = 0; p < MAX_PLAYERS; p++) {
|
|
|
|
@ -690,7 +697,9 @@ single_loop ()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* singleplayer menü with some options you can make */
|
|
|
|
|
void single_menu () {
|
|
|
|
|
void
|
|
|
|
|
single_menu ()
|
|
|
|
|
{
|
|
|
|
|
int menuselect = 0;
|
|
|
|
|
_menu menu[] = {
|
|
|
|
|
{1, "Start Game"},
|
|
|
|
@ -729,6 +738,201 @@ void single_menu () {
|
|
|
|
|
|
|
|
|
|
/* single player selection
|
|
|
|
|
return value the gfx of the player or -1 for escape */
|
|
|
|
|
int single_select_player () {
|
|
|
|
|
return 0;
|
|
|
|
|
int
|
|
|
|
|
single_select_player ()
|
|
|
|
|
{
|
|
|
|
|
int selgfx = 0,
|
|
|
|
|
done = 0,
|
|
|
|
|
x,
|
|
|
|
|
y,
|
|
|
|
|
keypressed = 0,
|
|
|
|
|
frame = 0,
|
|
|
|
|
d = 0,
|
|
|
|
|
dto = 2,
|
|
|
|
|
newplayer = -1,
|
|
|
|
|
pos = 0,
|
|
|
|
|
i;
|
|
|
|
|
SDL_Rect dest,
|
|
|
|
|
src;
|
|
|
|
|
char text[255];
|
|
|
|
|
SDL_Event event;
|
|
|
|
|
Uint8 *keys;
|
|
|
|
|
Uint32 timeloop1, timediff;
|
|
|
|
|
|
|
|
|
|
menu_displaytext ("Loading..", "Please Wait", 32, 128, 32);
|
|
|
|
|
|
|
|
|
|
dest.x = dest.y = 0;
|
|
|
|
|
dest.w = gfx.res.x;
|
|
|
|
|
dest.h = gfx.res.y;
|
|
|
|
|
|
|
|
|
|
gfx_load_players (64, 64);
|
|
|
|
|
gfx_blitupdaterectclear ();
|
|
|
|
|
|
|
|
|
|
draw_logo ();
|
|
|
|
|
|
|
|
|
|
strcpy (text, "Select your Player");
|
|
|
|
|
x = (gfx.res.x - (font[2].size.x * strlen (text)) - 64) / 2;
|
|
|
|
|
y = (gfx.res.y - font[2].size.y - 64 - 128) / 2;
|
|
|
|
|
font_setcolor (128, 128, 0, 2);
|
|
|
|
|
font_draw (x - 2, y, text, 2);
|
|
|
|
|
font_draw (x + 2, y, text, 2);
|
|
|
|
|
font_draw (x, y - 2, text, 2);
|
|
|
|
|
font_draw (x, y + 2, text, 2);
|
|
|
|
|
font_setcolor (255, 255, 128, 2);
|
|
|
|
|
font_draw (x, y, text, 2);
|
|
|
|
|
|
|
|
|
|
gfx_blitupdaterectadd (&dest);
|
|
|
|
|
|
|
|
|
|
while (!done) {
|
|
|
|
|
|
|
|
|
|
/* draw selected player */
|
|
|
|
|
frame++;
|
|
|
|
|
if (frame >= gfx.players[selgfx].ani.frames) {
|
|
|
|
|
frame = 0;
|
|
|
|
|
if (dto-- <= 0 && newplayer == -1) {
|
|
|
|
|
dto = 5;
|
|
|
|
|
if (d == up)
|
|
|
|
|
d = left;
|
|
|
|
|
else if (d == left)
|
|
|
|
|
d = down;
|
|
|
|
|
else if (d == down)
|
|
|
|
|
d = right;
|
|
|
|
|
else
|
|
|
|
|
d = up;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (newplayer != -1) {
|
|
|
|
|
SDL_Rect dest1,
|
|
|
|
|
src1;
|
|
|
|
|
|
|
|
|
|
pos += 8;
|
|
|
|
|
|
|
|
|
|
if (d == left) {
|
|
|
|
|
/* image 1 */
|
|
|
|
|
src.h = dest.h = gfx.players[selgfx].ani.h;
|
|
|
|
|
src.w = dest.w = gfx.players[selgfx].ani.w;
|
|
|
|
|
src.x = gfx.players[selgfx].ani.w * d;
|
|
|
|
|
src.y = gfx.players[selgfx].ani.h * frame;
|
|
|
|
|
dest.x = ((gfx.res.x - gfx.players[selgfx].ani.w) / 2) - pos;
|
|
|
|
|
dest.y = y + font[0].size.y + 64;
|
|
|
|
|
|
|
|
|
|
/* image 2 */
|
|
|
|
|
src1.h = dest1.h = gfx.players[newplayer].ani.h;
|
|
|
|
|
src1.w = dest1.w = gfx.players[newplayer].ani.w;
|
|
|
|
|
src1.x = gfx.players[newplayer].ani.w * d;
|
|
|
|
|
src1.y = gfx.players[newplayer].ani.h * frame;
|
|
|
|
|
dest1.x = ((gfx.res.x - gfx.players[newplayer].ani.w) / 2) + ((gfx.res.x / 2)+ 128) - pos;
|
|
|
|
|
dest1.y = y + font[0].size.y + 64;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* image 1 */
|
|
|
|
|
src.h = dest.h = gfx.players[selgfx].ani.h;
|
|
|
|
|
src.w = dest.w = gfx.players[selgfx].ani.w;
|
|
|
|
|
src.x = gfx.players[selgfx].ani.w * d;
|
|
|
|
|
src.y = gfx.players[selgfx].ani.h * frame;
|
|
|
|
|
dest.x = ((gfx.res.x - gfx.players[selgfx].ani.w) / 2) + pos;
|
|
|
|
|
dest.y = y + font[0].size.y + 64;
|
|
|
|
|
|
|
|
|
|
/* image 2 */
|
|
|
|
|
src1.h = dest1.h = gfx.players[newplayer].ani.h;
|
|
|
|
|
src1.w = dest1.w = gfx.players[newplayer].ani.w;
|
|
|
|
|
src1.x = gfx.players[newplayer].ani.w * d;
|
|
|
|
|
src1.y = gfx.players[newplayer].ani.h * frame;
|
|
|
|
|
dest1.x = ((gfx.res.x - gfx.players[newplayer].ani.w) / 2) - ((gfx.res.x / 2)+ 128) + pos;
|
|
|
|
|
dest1.y = y + font[0].size.y + 64;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
redraw_logo (0, y + font[0].size.y + 64, gfx.res.x, 128);
|
|
|
|
|
|
|
|
|
|
if (dest.x + dest.w > 0)
|
|
|
|
|
gfx_blit (gfx.players[selgfx].ani.image, &src, gfx.screen, &dest, 0);
|
|
|
|
|
if (dest1.x + dest1.w > 0)
|
|
|
|
|
gfx_blit (gfx.players[newplayer].ani.image, &src1, gfx.screen, &dest1, 0);
|
|
|
|
|
|
|
|
|
|
if (pos > (gfx.res.x / 2)+ 128) {
|
|
|
|
|
selgfx = newplayer;
|
|
|
|
|
newplayer = -1;
|
|
|
|
|
pos = 0;
|
|
|
|
|
}
|
|
|
|
|
frame++;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
src.h = dest.h = gfx.players[selgfx].ani.h;
|
|
|
|
|
src.w = dest.w = gfx.players[selgfx].ani.w;
|
|
|
|
|
src.x = gfx.players[selgfx].ani.w * d;
|
|
|
|
|
src.y = gfx.players[selgfx].ani.h * frame;
|
|
|
|
|
dest.x = (gfx.res.x - gfx.players[selgfx].ani.w) / 2;
|
|
|
|
|
dest.y = y + font[0].size.y + 64;
|
|
|
|
|
redraw_logo (dest.x, dest.y, dest.w, dest.h);
|
|
|
|
|
gfx_blit (gfx.players[selgfx].ani.image, &src, gfx.screen, &dest, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gfx_blitdraw ();
|
|
|
|
|
|
|
|
|
|
/* do the keyboard handling */
|
|
|
|
|
if (SDL_PollEvent (&event) != 0)
|
|
|
|
|
switch (event.type) {
|
|
|
|
|
case (SDL_QUIT):
|
|
|
|
|
bman.state = GS_quit;
|
|
|
|
|
bman.p_nr = -1;
|
|
|
|
|
done = 1;
|
|
|
|
|
selgfx = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keys = SDL_GetKeyState (NULL);
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_ESCAPE] && event.type == SDL_KEYDOWN) {
|
|
|
|
|
/* we want to quit */
|
|
|
|
|
done = 1;
|
|
|
|
|
bman.p_nr = -1;
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
bman.state = GS_startup;
|
|
|
|
|
selgfx = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_LEFT] && (!keypressed) && newplayer == -1) {
|
|
|
|
|
newplayer = selgfx - 1;
|
|
|
|
|
if (newplayer < 0)
|
|
|
|
|
newplayer = MAX_PLAYERS - 1;
|
|
|
|
|
d = left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_RIGHT] && (!keypressed) && newplayer == -1) {
|
|
|
|
|
newplayer = selgfx + 1;
|
|
|
|
|
if (newplayer >= MAX_PLAYERS)
|
|
|
|
|
newplayer = 0;
|
|
|
|
|
d = right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (keys[SDLK_RETURN] && (!keypressed) && (event.type = SDL_KEYDOWN) && newplayer == -1) {
|
|
|
|
|
done = 1;
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
// d_printf("return pressed - done=1\n");
|
|
|
|
|
}
|
|
|
|
|
if (event.type == SDL_KEYUP)
|
|
|
|
|
keypressed = 0;
|
|
|
|
|
else if (event.type == SDL_KEYDOWN)
|
|
|
|
|
keypressed = 1;
|
|
|
|
|
|
|
|
|
|
// calculate time sync.
|
|
|
|
|
timeloop1 = SDL_GetTicks ();
|
|
|
|
|
timediff = timeloop1 - timestamp; // only for debugging needed
|
|
|
|
|
|
|
|
|
|
if (newplayer != -1)
|
|
|
|
|
i = 17;
|
|
|
|
|
else
|
|
|
|
|
i = 25;
|
|
|
|
|
|
|
|
|
|
while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < i) {
|
|
|
|
|
s_delay (i - (timeloop1 - timestamp) - 1);
|
|
|
|
|
timeloop1 = SDL_GetTicks ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timestamp = timeloop1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gfx_free_players ();
|
|
|
|
|
|
|
|
|
|
return selgfx;
|
|
|
|
|
};
|
|
|
|
|