As a drawing it is very cool but I wouldn’t go with the choice of drawing everything with so many formulas because it can easily become a nightmare when you have to move the snake.
I would suggest to draw the snake with very simple desmos geometry objects (some circles and a rectangle) … this way it would be easier to make it move and grow.
Not sure about @Guzman_Tierno, but it can also be a convenient habit for possibly using mod or floor functions, or even for placement of objects (e.g. (N*o_{ffset},0)+c_{enter}
would place points starting at the point c_{enter}
and incrementally placing every o_{ffset}
units to the right).
Is this better?
Huh? Isn’t it more intuitive to have the last element of the list be the number of elements it has, or do you like the 0
index other coding languages have?
Why is it so distorted when I go onto the main graph?
Wonder if you guys can check this out:
CL question
the drawing is really nice but I would go with something simpler so that you can work on the engine of the game:
https://www.desmos.com/geometry/ukucozzj8l
yes, I prefer indices starting from zero so, as Daniel pointed out, the mod function works smoothly.
Here’s my idea for the engine (to try it out activate the ticker):
https://www.desmos.com/geometry/yqbbdlssjt
and here’s a possible idea to steer the snake …
https://www.desmos.com/geometry/6qwd8gemd9
and here’s a different idea …
https://www.desmos.com/geometry/6kqyqom7ol
I was thinking a wasd
control, using lists and mod:
WASD graph
Also, @Guzman_Tierno, I think you should make a list like pos = [x, y]
that contains the head’s x
and y
coordinates.
I have a question: What’s d_dir
? And how did you make it so the snake body can follow the head?
Yes we can define the position of the head (that’s just a point).
d_dir represents the direction the snake is moving.
I added the possibility to steer the snake with asdw (but I’m not a fan of this method that is really prone to errors and breaks the code easily).
I explained how the snake moves in the code.
https://www.desmos.com/geometry/de244cbcf3
What about this idea to steer the snake?
https://www.desmos.com/geometry/fudvmpcxpi
Oh ok. So if d_dir = (1, 0)
the snake would be moving right?
That’s really good! I think you can make the 2 triangles that steer the up and down have 0
opacitiy so the player doesn’t seen the polygon. Also the snake dies ‘outside’ the map, but instead it’s supposed to stay inside the map and just stop moving. I couldn’t find a way to fix it… I set distance({...}) = 1 : {...}
and it still died outside.
PS: Is @Martin_staples even making the game anymore? It seems like it’s all you (not saying it in a mean way)
yes d_dir=(1,0) means you’re moving right … etc …
yes, many things can be improved … these are just ideas …
Okay. Got it… I was just thinking too. I wanted you to add the head pos
so we could see when the snake got to a fruit or whatever the collectable is.
To make random spawning I would do something like this:
random gen
here’s a working version with apples …
https://www.desmos.com/geometry/fmp1wfwz5d
That’s a lot more complicated than what I would’ve done, I would’ve just used my example (I did it as a list to allow multiple apples).
I think the most difficult part is spawning the apples outside the body of the snake …
you don’t want an apple to appear on top of the snake … (or maybe that is ok) …
that’s why my code it’s more complex.
But in any case you have to check if you eat the apple … and make the snake grow …
so it takes a bit of logic.
Don’t you have a list of the points where the snake are (L
)? Just check if the point of the apple is in the snake, then move it elsewhere (I think you already did that, though)
Add a element to it L
that’s exactly what the code does …