From f5974e8699e6e73685d45afec272627d2a637cac Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Tue, 1 Nov 2022 13:44:10 +0100 Subject: [PATCH] Minor changes --- snake.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/snake.py b/snake.py index 6c688b2..85857ab 100755 --- a/snake.py +++ b/snake.py @@ -26,7 +26,7 @@ class Snake: """ Reset game state """ - self.snake=[(0,0)]*self.default_length + self.snake=[(5,5)]*self.default_length self.direction=3 # Like clock (12=up, 3=right, 6=bottom, 9=left) self.new_apple() self.score=0 @@ -95,6 +95,14 @@ class Snake: else: self.draw_pts(elt[0],elt[1],color=(color[0],int(color[1]/2),color[2]),scale=0.86) + def draw_apple(self,radius=None): + if radius==None: + radius=self.grid_pts/2 + #self.draw_pts(self.apple[0],self.apple[1],color=(210,0,0)) + pygame.draw.circle(self.screen, (210,0,0), (self.apple[0]*self.grid_pts+int(self.grid_pts/2),self.apple[1]*self.grid_pts+self.margin+int(self.grid_pts/2)), radius) + pygame.draw.circle(self.screen, (170,0,0), (self.apple[0]*self.grid_pts+int(self.grid_pts/2),self.apple[1]*self.grid_pts+self.margin+int(self.grid_pts/2)), radius/1.5) + + def has_loose(self): """ Return true if the game is loose @@ -117,7 +125,7 @@ class Snake: while True: self.screen.fill((0,0,0)) self.draw_snake() - self.draw_pts(self.apple[0],self.apple[1],color=(210,0,0)) + self.draw_apple() self.draw_infos() # Check for loose if not(ignore_has_loose) and self.has_loose():