How To

How do I make a sprite follow another sprite?

0

DJMoffinz 2019-10-27 09:31

I am currently working on a Slither.io style game but I don’t know how to make the sections of body follow each other so I can move the snake/worm. If anyone knows how please reply with the code.


Timo 2019-10-27 11:41

Better start simple, just make the moving head. Then share your code. It's easier to help with existing code. Do you have some programming experience already or did you just start?


was8bit 2019-10-27 17:49

Are you going for full animation, as in using sprites, or just wanting a "bare bones" quick and easy approach such as just using CELL command to "jump" each piece into the next cell space...

In the second event, you need only to move the head and tail... as the head moves out of its cell into a new cell, it leaves behind a body segment... as the tail moves it leave behind an empty cell and moves into the next body segment... to track location so use DIM XSNAKE(99),YSNAKE(99) with (0) always that head, and use ITAIL to keep track of the tail index... with body length at zero, ITAIL would be 1.. at body length 1, ITAIL is 2.... at body length 10, ITAIL would be 11... you update the data in reverse... from tail to head, then update the head data last..

For full animation, you still need DIM XSNAKE,YSNAKE, but rather than representing CELL coordinates, they will represent SPRITE coordinates (see my CELL VS SPRITE) and your approach to handling them will be more complicated ... you will need to process the head first then work your way to the tail... you will need to use the math to keep the direction and distance consistent all along the length of the snake...


DJMoffinz 2019-10-27 21:51

@Timo
Okay, first things first, I’ll just make the head move, then share it. And yes I do have some experience with BASIC... but thanks anyways!


DJMoffinz 2019-10-27 22:10

@was8bit
Yeah, I’m going for a fairly smooth animation, not too seamless –still want it to look 8 bit– but not too blocky, so cell command probably won’t work for me. I have an idea of what I want it to look like, but I can’t upload screenshots for some reason, keeps telling me to use the recommended size, but there’s actually no size specified. Anyways thanks so much for your help!


DJMoffinz 2019-10-27 22:25 (Edited)

@Timo
Okay here’s the game so far:

https://lowresnx.inutilis.com/uploads/EQQsuNjfHp_Untitled.io_wip.nx

(Sorry it’s a link, I don’t know how to attach projects)


was8bit 2019-10-28 04:19

Are you using Apple IOS device, or windows ??


DJMoffinz 2019-10-28 05:13 (Edited)

@was8bit
IOS lol


was8bit 2019-10-28 12:20

Technically, iOS...


DJMoffinz 2019-10-29 01:12

Yeeeees?


was8bit 2019-10-29 06:38 (Edited)

With ios you can select in the app you can click the "square with arrow" and select "share with community" and update your existing game as you have an upgrade to share :)


DJMoffinz 2019-10-29 06:47

Ik


DJMoffinz 2019-10-29 06:51

But I meant that I can’t attach NX files like how you can press “attach” at the bottom of the comment. It doesn’t work because I can’t create .nx files on iOS.


was8bit 2019-10-29 06:56

Um are you using an ipad or iphone... or are you using a computer....


DJMoffinz 2019-10-29 07:09

iPad!


was8bit 2019-10-29 07:20 (Edited)

Well, it should let you update your existing program while you are in your program looking at your code...

... you also may need to set iCloud up for lowresNX.... when you update from here I think it requires iCloud...

You can update your program from here, but it is easier to do while you are in lowres and seeing your code...


Timo 2019-10-29 07:21

On iOS Safari you can explore files in iCloud Drive. All your nx files are there.


DJMoffinz 2019-10-29 07:36

Ok


Log in to reply.