Hello! I've been trying to make a snake game based on this tutorial --> https://simplegametutorials.github.io/love/snake/
Everything works fine except the snake will not die.
I've tried comparing and rewriting the code to match more closely with how the tutorial is formatted but nothing changed.
If someone could tell me where I did wrong, that would be great
Need Help with a Simplegametutorials Snake Game
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Need Help with a Simplegametutorials Snake Game
- Attachments
-
- main.lua
- the main.lua from the site
- (4.63 KiB) Downloaded 195 times
-
- main.lua
- my main.lua
- (3.65 KiB) Downloaded 140 times
-
- examplefromsite_snake.love
- From the website
- (1.2 KiB) Downloaded 170 times
-
- SnakeStillAlive.love
- this one is mine
- (388.6 KiB) Downloaded 165 times
Re: Need Help with a Simplegametutorials Snake Game
Hello!
The problem looks like a typo. You are using "nextXpos" and "nextYpos" instead of "newXpos" and "newYpos".
You need to replace this:
With this:
The problem looks like a typo. You are using "nextXpos" and "nextYpos" instead of "newXpos" and "newYpos".
You need to replace this:
Code: Select all
for segmentIndex, segment in ipairs(snakeSegments) do
if segmentIndex ~= #snakeSegments
and nextXPos == segment.x
and nextYpos == segment.y then
canMove = false
end
end
Code: Select all
for segmentIndex, segment in ipairs(snakeSegments) do
if segmentIndex ~= #snakeSegments
and newXpos == segment.x
and newYpos == segment.y then
canMove = false
end
end
LÖVE-Nuklear - a lightweight immediate mode GUI for LÖVE games
Re: Need Help with a Simplegametutorials Snake Game
I'll try that. Thanks for responding!
EDIT: Ok so, update. I replaced those lines but nothing changed. I appreciate you correcting me on this though.
EDIT 2: I messed up the if nesting like a goober. Thanks for helping!
EDIT: Ok so, update. I replaced those lines but nothing changed. I appreciate you correcting me on this though.
EDIT 2: I messed up the if nesting like a goober. Thanks for helping!
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], scorelessmusic and 11 guests