Skip to content

Commit 655ac30

Browse files
committed
added snake.py
1 parent 746aee1 commit 655ac30

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

snake.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
33
# Original Author : Sanchit Gangwar
44
# Modified by : Rayan Dutta
5+
# Minor changes made to keep the game working.
56

67
import curses
78
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
@@ -28,7 +29,7 @@
2829
win.border(0)
2930
win.addstr(0, 2, 'Score : ' + str(score) + ' ') # Printing 'Score' and
3031
win.addstr(0, 27, ' SNAKE ') # 'SNAKE' strings
31-
win.timeout(150 - (len(snake)/5 + len(snake)/10)%120) # Increases the speed of Snake as its length increases
32+
win.timeout(int(150 - (len(snake)/5 + len(snake)/10)%120)) # Increases the speed of Snake as its length increases
3233

3334
prevKey = key # Previous key pressed
3435
event = win.getch()
@@ -59,8 +60,9 @@
5960
#if snake[0][0] == 0 or snake[0][0] == 19 or snake[0][1] == 0 or snake[0][1] == 59: break
6061

6162
# If snake runs over itself
62-
if snake[0] in snake[1:]: break
63-
63+
if snake[0] in snake[1:]:
64+
print('Game Over')
65+
break;
6466

6567
if snake[0] == food: # When snake eats the food
6668
food = []

0 commit comments

Comments
 (0)