How To

Sprite Movement

1

Benimo12 2021-04-30 20:40

How does one get two moving sprites to appear and move at the same time?

Basic Platformer.nx | Open in app
2021-04-30 20:40

was8bit 2021-05-01 03:32 (Edited)

Check these out :)

https://lowresnx.inutilis.com/topic.php?id=726

https://lowresnx.inutilis.com/topic.php?id=676

https://lowresnx.inutilis.com/topic.php?id=226

https://lowresnx.inutilis.com/topic.php?id=1073

https://lowresnx.inutilis.com/topic.php?id=1338


Benimo12 2021-05-03 20:40

To understand this, I have to put all sprites I want to use in the same loop?


Benimo12 2021-05-03 20:40

To understand this, I have to put all sprites I want to use in the same loop?


was8bit 2021-05-04 00:05

Not really, just use seperate variables unique to each sprite...

Give me some time and i will redo your code to do what i think you are wanting it to do :)


was8bit 2021-05-04 01:10

Ok, check this out... my demo code is at top ...p


was8bit 2021-05-04 01:18

And this is with a random computer player...


was8bit 2021-05-04 01:20 (Edited)

Animation requires a timing control system, and an animation frame system... all kept within one main game DO LOOP

Your approach will work for one sprite, but if you want to animate several sprites at the same time, your approach will cause all other sprites to freeze until the animation is finished for one sprite.....


was8bit 2021-05-04 01:31

One last comment... if you want to use numbers and or letters, you MUST leave page 4 of your character pages empty, as NX secretly uses page 4 to hold the secret character set.... try PRINT "HELLO 12345" and see what happens ;)


Benimo12 2021-05-05 20:51

Figured that out on the first week. Thanks tho


Benimo12 2021-05-05 20:57

Thanks. Reading through the demo code, all animation has to be tied to the loop if I’m not mistaken.


was8bit 2021-05-06 03:08 (Edited)

Your entire game (or if it is a big game, each main section or level) should be kept within a DO, WAIT VBL, LOOP... this sets the timing of the loop to 60 loops per second, or each loop is precisely 1/60 of a second...

Therefore, this code...

TICK=(TICK+1) MOD 5 IF TICK=0 THEN ADD FRAME,1,1 TO 4

Means that each frame is advanced at a rate of 5/60 of a second (from MOD 5)

It takes awhile to get used to handling animation... to simplify the code, you can standardize then animation frame in sequential order, even if some frames are identical... let me show a simpler approach...


was8bit 2021-05-06 03:20

You can see the difference in the code, yet when playing the game the animation is the same... if your animation images for each sequence is put all together in order, and are standardized to a set length, it then makes the code SO much easier :)


Benimo12 2021-05-06 18:19

Thanks.


was8bit 2021-05-07 02:45

:)


Log in to reply.