Python Forum
[PyGame] Problem With Entering Game Loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Problem With Entering Game Loop
#4
On 137 AND on 149 you set snakePos = [100, 50]. This is also the same as your snakeBody, so
 for block in snakeBody[1:]:
            if snakePos == block:
will always be the case. And your snake can't move because every frame you set snakePos and snakeBody to the same thing. So the first thing to fix would be to not do this. I've never made a snake game, but my first impulse is to define these variables before the game loop starts, and not have your snake's head in the snakeBody list. The head can't collide with itself anyway, so there is no need for it there. As long as it's in there you'll trigger game over. I'm a newb to all this too, so the solution isn't immediately obvious to me, but I'm pretty sure this is the problem to solve.
Reply


Messages In This Thread
Problem With Entering Game Loop - by ElevenDecember - Jan-18-2020, 05:15 AM
RE: Problem With Entering Game Loop - by michael1789 - Jan-19-2020, 08:25 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  If 2nd input in the game is correct, replace with 1st input and loop the game tylerdurdane 11 4,128 Jul-17-2022, 04:55 AM
Last Post: deanhystad
  [PyGame] Problem when moving game window michael1789 15 8,845 Jan-17-2020, 01:40 PM
Last Post: metulburr
  Snake Game - obstacle problem Samira 3 5,646 Oct-31-2019, 02:58 PM
Last Post: Samira
  [PyGame] Game Logic problem with a "The Game of Life" Replication Coda 2 3,146 Dec-24-2018, 09:26 AM
Last Post: Coda
  [PyGame] Pong game key.event problem erickDarko 2 4,198 Dec-12-2018, 03:17 PM
Last Post: erickDarko
  [Tkinter] Loop help in game Kgranulo1 1 3,293 Feb-28-2017, 08:02 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020