トピック
Scientist Speedy1101

Slithers

How do you make a chain of sprites move around like a snake? I want the chain (worm) to move around like the worms in Slither io.
5そうだね
プレイ済み
返信[1]
親投稿
*J.P.*[P]£ aj2003aj
ive been trying to do the same type of thing but for a tractor beam.
1そうだね
プレイ済み
返信[2]
親投稿
Scientist Speedy1101
I wonder how they do that.
1そうだね
プレイ済み
返信[3]
親投稿
Aaron Krondelo
Good question, I have no idea but thinking about it, I'm guessing you would need an array to store the previous locations. Kind of like storing old velocities, but the really hard part is figuring how to move them again when the snake head pulls the slack. You would also have to move those pieces along a stored vector.
2そうだね
プレイ済み
返信[4]
親投稿
OlOOlOOl pi_r_round
I'm not really sure what you want, but have a look at this program. Each segment's location is stored in an array. On each movement, the old tail segment is erased and a new head segment is drawn, creating the illusion of movement.
1そうだね
プレイ済み
返信[5]
親投稿
Scientist Speedy1101
Aaron>> I'll try that. OIOOIOI>> What I'm trying to do is make the body of the worm follow the head around and have them all as sprites.
1そうだね
プレイ済み
返信[6]
親投稿
Scientist Speedy1101
OIOOIOOI, how do I use that code with sprites without erasing them?
1そうだね
プレイ済み
返信[7]
親投稿
OlOOlOOl pi_r_round
This version uses sprites. You'll have to play around with the formulas that determine where it's going to move. Right now they produce variable distance between segments, which causes a kind of creepy movement - like a centipede in a box trying to get out.
0そうだね
プレイ済み
返信[8]
親投稿
Scientist Speedy1101
I understand most of the program, but how do you get the worm to move in the direction of the circle pad and only move when "told" to?
2そうだね
プレイ済み
返信[9]
親投稿
PChicken NerdChicken
DEG(ATAN(SX,-SY)) <---- Get angle from circle pad Encase his code in an IF statement to stop adding to the array or whatever he's doing.
1そうだね
プレイ済み
返信[10]
親投稿
SıмΞоп SimeonW
Here you go: I just made this for you
1そうだね
プレイ済み
返信[11]
親投稿
SıмΞоп SimeonW
Ignore the 'Randomize Each Point comment, looks better in a spiral So basically whats happening is youre stepping through each body piece, all the way till you get to the tail, and each body piece only keeps track of the angle between it and the body piece before it, and so all you allow is the angle to be changed, not the position Then moving the head will move the body, giving a weird worm feel
1そうだね
プレイ済み
返信[12]
親投稿
SıмΞоп SimeonW
Set XSCREEN to 4 Initialize the radius R[i] to a constant number, 5 And add +1 to the Y[i] to add a form of linear gravity And you'll see how strangely this snake follows the laws of physics If you make a circle loop in the body, the loop will remain active and 'roll' down the snake chain until its released at the tail Its a really interesting programming phenomenon
0そうだね
プレイ済み
返信[13]
親投稿
Scientist Speedy1101
That's weird. Can you recreate this with sprites and make them rotate to make it seem more "natural"? I've been trying to recreate the worms from Terraria with little success.
1そうだね
プレイ済み