Hey there! I'm fairly new to LOVE and lua. To get started I've been following a tutorial on how to create the game 'snake'. I tweaked the code here and there to change the properties of the game more in my liking. Following that tutorial I added a collision detection if the snake is still alive or has died. However after adding the collision detection the snake refuses to move which it did before. Since I'm new to LOVE and lua I coulnd't figure out what's wrong with my code.
What is wrong with my code so that the snake doesn't move? I would be grateful if you could look into the code and tell me what I have to edit in order for the code to work properly
Thanks in advance!
(the (German) tutorial I followed along: https://www.youtube.com/playlist?list=P ... YPtfBVTFT8)
the main.lua file containing the code should be attached to this thread
problem with my code
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Sat Mar 07, 2020 9:36 am
problem with my code
- Attachments
-
- main.lua
- the snake program
- (2.54 KiB) Downloaded 180 times
Re: problem with my code
You initialize the snake with one head and four tail elements. All of them in on the same spot. In the first update the head then collides with all four of its tails, triggering the death of the snake with its fourth tail element.
You can initialize the snake with 3 tail elements, initialize the snake in a row (like it was already moving) or start the collision detection in the second update round
You can initialize the snake with 3 tail elements, initialize the snake in a row (like it was already moving) or start the collision detection in the second update round
-
- Prole
- Posts: 2
- Joined: Sat Mar 07, 2020 9:36 am
Re: problem with my code
That makes sense. I think I'll be able to fix that then.
Thanks a lot for the help!
Thanks a lot for the help!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests