mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Prevent edge warping in Snake minigame
This commit is contained in:
parent
10fbaaf781
commit
7c9ce1faee
1 changed files with 18 additions and 4 deletions
|
@ -1252,18 +1252,32 @@ static void CL_HandleSnake(void)
|
|||
switch (snake->snakedir)
|
||||
{
|
||||
case 1:
|
||||
x = x > 0 ? x - 1 : SNAKE_NUM_BLOCKS_X - 1;
|
||||
if (x > 0)
|
||||
x--;
|
||||
else
|
||||
snake->gameover = true;
|
||||
break;
|
||||
case 2:
|
||||
x = x < SNAKE_NUM_BLOCKS_X - 1 ? x + 1 : 0;
|
||||
if (x < SNAKE_NUM_BLOCKS_X - 1)
|
||||
x++;
|
||||
else
|
||||
snake->gameover = true;
|
||||
break;
|
||||
case 3:
|
||||
y = y > 0 ? y - 1 : SNAKE_NUM_BLOCKS_Y - 1;
|
||||
if (y > 0)
|
||||
y--;
|
||||
else
|
||||
snake->gameover = true;
|
||||
break;
|
||||
case 4:
|
||||
y = y < SNAKE_NUM_BLOCKS_Y - 1 ? y + 1 : 0;
|
||||
if (y < SNAKE_NUM_BLOCKS_Y - 1)
|
||||
y++;
|
||||
else
|
||||
snake->gameover = true;
|
||||
break;
|
||||
}
|
||||
if (snake->gameover)
|
||||
return;
|
||||
|
||||
// Check collision with snake
|
||||
for (i = 1; i < snake->snakelength - 1; i++)
|
||||
|
|
Loading…
Reference in a new issue