snake new control: don't allow snake to go to opposite direction

This commit is contained in:
kju 2010-01-14 01:06:10 +00:00
parent 782c0f4439
commit 12db75f1b1
1 changed files with 4 additions and 0 deletions

View File

@ -62,6 +62,10 @@ void snake_game() {
#ifdef GAME_SNAKE_NEWCONTROL #ifdef GAME_SNAKE_NEWCONTROL
if (joy_cmd != 0xff) if (joy_cmd != 0xff)
{ {
if ( (dir == left && joy_cmd != right) ||
(dir == right && joy_cmd != left) ||
(dir == up && joy_cmd != down) ||
(dir == down && joy_cmd != up) )
dir = joy_cmd; dir = joy_cmd;
} }
#else #else