summaryrefslogtreecommitdiff
path: root/snake/snake.py
diff options
context:
space:
mode:
Diffstat (limited to 'snake/snake.py')
-rwxr-xr-xsnake/snake.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/snake/snake.py b/snake/snake.py
new file mode 100755
index 0000000..fe8883b
--- /dev/null
+++ b/snake/snake.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+import sys, pygame
+
+
+class Snake:
+
+ def __init__(self, grid_width=50,grid_height=50, grid_pts=15):
+ self.grid_width=grid_width
+ self.grid_height=grid_height
+ self.grid_pts=grid_pts
+ pygame.init()
+ self.screen=pygame.display.set_mode((grid_width*grid_pts,grid_height*grid_pts))
+
+ def draw_pts(self,x,y,color=(255,255,255)):
+ rect=pygame.Rect(self.grid_pts*x, self.grid_pts*y, self.grid_pts, self.grid_pts)
+ pygame.draw.rect(self.screen,color,rect, 0)
+
+ def run(self):
+ while True:
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ pygame.quit()
+ sys.exit()
+
+ self.screen.fill((0,0,0))
+ self.draw_pts(1,1)
+ self.draw_pts(0,0,color=(95,1,255))
+ pygame.display.flip()
+
+
+game=Snake()
+game.run() \ No newline at end of file