

I just don't know how to get the pellet to actually appear on the screen.
#ON SCREEN SNAKE GAME CODE#
Start_menu = Menu(screen, start_menu_stuff)Īny help or direction would be greatly appreciated, this is my first CS class so the code is very, very basic. #runs options at the start and end of gameįor name, label, (width, height), (pos_x, pos_y) in ems: Pos_y = (self.screen_height / 2) - (lol / 2) + (index * height) Pos_x = (self.screen_width / 2) - (width / 2) Running off the map or into your own vehicle will end the game. #enumerate makes loop clearer, returns an iterator Self.screen_height = screen.get_rect().height Self.screen_width = screen.get_rect().width #determines if snake collides with itselfĭef _init_(self, screen, items, background_color = (bla), font_size = 32, font_color = (whi)): Return + self.speed, current + self.speed]Įlif abs(self.speed) != abs(speed): #sets the position as long as the snake hasn't collided (.pop() removes and then returns)ĭef update(self, speed, pelletCollision = False): Return head_pos_x self.size - self.bit or head_pos_y self.size - self.bitĭef _init_(self, position, speed = ):

Return random.randint(-500, 500) * self.bit #return random.randint(bit, max_size / bit) * self.bitĪmount_bits = (self.size / self.bit - 1) #amount_bits = (self.size / self.bit - 1) / Everything is ready for the joke Main features of application: - high quality of graphics and realistic movement of a snake.
#ON SCREEN SNAKE GAME DOWNLOAD#
Neither def randomPosition 's will draw a pellet on the game screen though. Download a free snake screen to your phone. I rewrote it and somehow managed to get that one to not mess up the game display. This following 3 lines of code doesn't work and I want it to. #gives pellet random position and avoids overlap with snake #redraws pellet if appears where snake currently is Self.pellet = Pellet(self.newPelletPosition()) #sets snake in initial position and put pellet in random position import sys, pygame, random, itertools, time I would love any advice on how to fix this problem, or how to improve the game. You can move the snake body around in any direction but the pellet or apple that it is supposed to eat won't draw on the screen. Since all key input would be detected through the UserInterface class, I had to bind all the handler methods so they could be used through the Game class.The following code works to a certain extent.
