#Snake, how do i add segments?
1 messages · Page 2 of 1
A signal tutorial will help you
i think i should watch one and then get back?
But honestly, the growth delay doesn't seem like a big deal
The signal thing is just to fix the growth delay
well if youre really big it kinda is
Oh wait, that's the problem you were describing in the first place llmao
nonono
two problems
one i dont really care actually
and one its kinda important
first one is the little extra time it takes for a segment to die, which i dont care
and the other is the long time it takes for the new segment to appear if youre big
Because eating the apple increases the score, which only increases time on the death timer of the newly spawned segments, yes?
elaborate
it because
suppose
you eat an apple at 10, 10
a segment is spawned at 10, 10
that segment will only be visible when theres NOT another segment at 10, 10
which takes a while if youre big
The segment at 10,10 will be visible when there's not a segment at 10,10
?
Oh
Let me ask this
You eat the apple at 10, 10
Do 30 frames pass between then and when you create a new segment?
sorry the 30 frames is just an imaginary number for example?
yeah, that's like, movespeed
ok, no, when you eat the apple the new segment gets created instantly
oh i saw the problem wrongly
you saw it correctly
Yeah, there's no reason to do that
Just only create segments when you move
So that there aren't overlapping segments in the first place
yeyeyeyeyeyey
yes there arent*]
:o
so instead of changing death timer for the next segment it should change for all the segments death timers?
I don't understand what the problem is anymore
iunno
I just use obs lol
Describe everything that happens in steps
you move, you eat the apple
then what
ok
lets say you only move in 1 dimention so its easier to visualize
lets say you also need 1 second to move
k
yeah
you have score 5 which means theres 5 segments + the head
last segment at 0 and you at 5
yaeh move timer * segments
okedoke
you move to six
all the segments lose 1 second of their life
segment at 0 dies
that continues, when you eat the apple instead of having 5 segments you have 6
????
everytime you eat an apple you grow
Where do you grow
nonono go back to 9
okay
the head is at 9
yes
segments on 8,7,6,5,4
yep
continue
ye
then the head moves again, to 11, but instead of making all the segments 9,8,7,6,5 gain +1 seconds on their life only the segment created on 10 has +1 second, so in the same tick segment at 5 dies instead of living for 1 more second
So you have segments on 10,9,8,7,6
yes
and you still visualy have 5 segments
BUT
the times look like this:
10: 6
9: 4
8: 3
7: 2
6: 1
5: dead
so you visually have 5 segments
next tick:
11: 6
10: 5
9: 3
8: 2
7: 1
6: dead
still visually 5 segments
12: 6
11: 5
10: 4
9: 2
8: 1
7: dead
5 visual segments
13: 6
12: 5
11: 4
10: 3
9: 1
8: dead
5 visual segments
14: 6
13: 5
12: 4
11: 3
10: 2
9: dead
5 visual segments
only NOW
15: 6
14: 5
13: 4
12: 3
11: 2
10: 1
now theres 6 visual segments
yeah, makes sense
it took x seconds for x ammount of segments for it to make a visual difference
Not a glitch, but I can see how that might be undesirable
yes, not a glitch
understanding the error fully now makes it more easibly understandable
Show me where you're increasing the score
still dont quite know how to fix
function called eaten_apple
on head.gd
Perfect, that makes this easier
oh i think we didnt talk about that call deferred right?
lol what is call_deferred
used a little bit of chat gpt, for some reason the function add segment and start death timer werent working inside the function eaten apple
call deferred makes x function execute instantly when declared
i just realised that happened because the functions werent declared when eaten apple is ran, probably
That's how functions usually work
Oh
Depends on how you're using declared
I forget what that means in coding
fixed it lol
This is wild because your start death timer function should be causing errors
Oh, cause you're declaring segment at the top?
i am
okedoke
uhmm
logically something like
you add 1 second to all the segment timers when you eat an apple
Ok, so timers and buttons both use signals
You have a timer, it goes off, it sends a signal to the thing it's attached to to do something
You have a button, player clicks it, it sends a signal to whatever it should to do some stuff
maybe like this?
You should not add a segment when you eat an apple
You add segments when you move
You might also just put _start_death_timer() inside _add_segment()
because you start the death timer when you add the segment
ok got overwhelmed
first thing
remembered why i used call deferred
because this error shows up otherwise: (although it still works)
secondly eating apple should just change the death timer if i understood it?
Yeah, with a signal, but we're not quite there yet
wanna see the codes?
Cause you should delete lines 25 and 26 prolly
Ye sure
Ok cool, probably purge 25 and 26 from the face of this earth
Then watch a tutorial on signals
I think the gist is that you create a signal at the top,
connect the signal to each segment you create,
write a function inside segment to add time to it's death timer
signal_name.emit() inside _apple_eaten()
I don't remember how to connect signals
But the tutorial will prolly tell you all about it
ok, wanna continue tomorrow?
k, getting kinda sleepy now
Godot main menu tutorial, can be controlled by either mouse and keyboard. Basics Main Menu in Godot. Be good to your mother.
Join Discord Server:
https://discord.gg/bczjXGf
Music by Wintergatan
ok nigh nigh
GINORMOUS GIGANTIC BIG STRONDOWS EPILEPTIC thank you, bro you putting so many lumps in my smooth brain
yah
@wooden maple BROOOO I MAY ACTUALLY HAVE DONE IT DID DADTADDI DONT KNOW GRAMMAR
the visual ammount of segments get changed the next tick after eating an apple, i even felt a cool in my body when i did it, it does though kinda glitch after but stabilizes im gonna record a video and show
@wooden maple please i have no idea why this is happening
Oh my bad
help please 😭