Merge pull request #55 from hazanjon/snake_improvements

Fix Issue #38 - Reversing direction causes instant game over
sammachin-gprs
Marek Ventur 2018-09-01 18:46:06 +01:00 committed by GitHub
commit 1c06a8bbe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -62,19 +62,19 @@ def one_round():
# disp_body_straight(body_x[i],body_y[i],orient,body_colour)
while keepgoing:
if Buttons.is_pressed(Buttons.JOY_Right) or Buttons.is_pressed(Buttons.BTN_6):
if dir_x != -1 and (Buttons.is_pressed(Buttons.JOY_Right) or Buttons.is_pressed(Buttons.BTN_6)):
dir_x = 1;
dir_y = 0;
orient = 270
elif Buttons.is_pressed(Buttons.JOY_Left) or Buttons.is_pressed(Buttons.BTN_4):
elif dir_x != 1 and (Buttons.is_pressed(Buttons.JOY_Left) or Buttons.is_pressed(Buttons.BTN_4)):
dir_x = -1;
dir_y = 0;
orient = 90
elif Buttons.is_pressed(Buttons.JOY_Down) or Buttons.is_pressed(Buttons.BTN_8):
elif dir_y != -1 and (Buttons.is_pressed(Buttons.JOY_Down) or Buttons.is_pressed(Buttons.BTN_8)):
dir_y = 1;
dir_x = 0;
orient = 180
elif Buttons.is_pressed(Buttons.JOY_Up) or Buttons.is_pressed(Buttons.BTN_0):
elif dir_y != 1 and (Buttons.is_pressed(Buttons.JOY_Up) or Buttons.is_pressed(Buttons.BTN_0)):
dir_y = -1;
dir_x = 0;
orient = 0