|
Post by Minilop on Mar 28, 2020 17:17:29 GMT
Hi, sorry if this has been answered before, I searched but couldn't find anything. Is it possible to have moving platforms in MPAGD?, the kind the player can jump on and off?
Many thanks!
|
|
|
Post by Jonathan Cauldwell on Mar 31, 2020 14:37:27 GMT
Yes, of course. If you want a good example download John Blythe's Circuitry from here and import the .TAP file. The sprite at the bottom right of the second screen is a moving platform and the code for it is located in sprite event 1. Take a look at that and you'll soon see how it works
|
|
|
Post by Minilop on Apr 1, 2020 19:53:57 GMT
Thanks Jonathan, I've been had a look at John Blythe's code for the vertical moving platform and have it working in my game, I've also adapted it for horizontal moving platforms, although it needs some work as the Player sprite isn't moving as smoothly as the platform yet. Plenty for me to work on!
|
|
dvader
Wacky Amoebatron
Posts: 30
|
Post by dvader on Apr 4, 2020 20:44:23 GMT
Hi. I've just been trying to add a moving platform myself. I've grabbed the code mentioned above and it works reasonably well. However I was wanting it to move left and right rather than up and down, at least for now. I've altered the code and it now moves left to right. But I'm not quite sure how to get the player to move left and right with it. The P variable confuses me here. Here's the code so far.
SPRITEINK 71 IF DIRECTION = 0 SUBTRACT 16 FROM X IF CANGOLEFT ADD 15 TO X ELSE ADD 16 TO X LET DIRECTION = 1 ENDIF ELSE IF CANGORIGHT ADD 1 TO X ELSE LET DIRECTION = 0 ENDIF ENDIF IF COLLISION 0 LET P = Y OTHER IF P > Y SUBTRACT Y FROM P IF P > 8 ADD Y TO P LET Y = P SUBTRACT 16 FROM Y STOPFALL ENDIF IF KEY FIRE TABLEJUMP ENDIF ENDSPRITE ENDIF ENDIF IF A 2 ANIMATE ENDIF SPRITEINK 70
Any ideas? Oh and also is there a way to rem lines out rather than just deleting them? I don't think I need the ink changes as I'm doing this on Amstrad.
|
|
|
Post by Minilop on Apr 4, 2020 22:31:50 GMT
Hi dvader
First, have to say I am a total novice with this, but this is what I have so far with a platform that moves left to right. As I understand it the OTHER command switches the code after to be applicable to the Other sprite in the collision - so your code above is in your platform sprite event but the part between OTHER and ENDSPRITE is affecting the player (since your player has collided with the platform. So LET P = Y grabs the Y co-ord of your platform and stores it - then after the OTHER command the Y variable relates to your player so the LET Y = P is now relating to the Y co-ord of your player.
So this is what I have at the moment (note it is far from perfect - but it does kinda work for a horizontal (left to right) moving platform:
IF DIRECTION = 0 SUBTRACT 16 FROM X IF CANGOLEFT ADD 15 TO X ELSE ADD 16 TO X LET DIRECTION = 1 ENDIF ELSE IF CANGORIGHT ADD 1 TO X ELSE LET DIRECTION = 0 ENDIF ENDIF IF COLLISION 0 LET P = Y LET R = X OTHER IF P > Y SUBTRACT Y FROM P IF P > 8 ADD Y TO P LET Y = P SUBTRACT 16 FROM Y STOPFALL ENDIF IF KEY FIRE TABLEJUMP ENDIF LET X = R ENDSPRITE ENDIF
; check which way player is travelling and change sprite if required, also check if player is moving left or right IF DIRECTION = 0 OTHER LET IMAGE = 1 IF KEY LEFT SUBTRACT 10 FROM X ENDIF ENDSPRITE ELSE OTHER LET IMAGE = 0 IF KEY RIGHT ADD 10 TO X ENDIF ENDSPRITE ENDIF ENDIF
|
|
dvader
Wacky Amoebatron
Posts: 30
|
Post by dvader on Apr 5, 2020 14:43:24 GMT
Hi waverleys. Thanks for the help. I've had a look at it and have got it smoother if you press in the direction as the platform is moving. More luck than knowledge, Assembly is a little weird for me, I sort of get it, yet I don't. I can post the code if you want it. Edit - Actually I may as well paste it here anyway. There's a small video of it working below the code. If you rem out LET X = R then it works better but you don't quite match the platforms speed. Still works if you want a slightly slippy platform. Edit - Wow, been at this for 5 hours at least and still no closer. I got it to work once smoothly, but only underneath the platform! Jump up and it went jerky again but it worked fine under the platform Changed so many things now I can't even get it to do that again. IF DIRECTION = 0 SUBTRACT 16 FROM X IF CANGOLEFT ADD 15 TO X ELSE ADD 16 TO X LET DIRECTION = 1 ENDIF ELSE IF X< 140 ADD 1 TO X ELSE LET DIRECTION = 0 ENDIF ENDIF IF COLLISION 0 LET P = Y LET R = X OTHER IF P > Y SUBTRACT Y FROM P IF P > 8 ADD Y TO P LET Y = P SUBTRACT 16 FROM Y STOPFALL ENDIF IF KEY FIRE TABLEJUMP ENDIF LET X = R ENDSPRITE ENDIF ; check which way player is travelling and change sprite if required, also check if player is moving left or right IF DIRECTION = 0 OTHER LET IMAGE = 1 SUBTRACT 16 FROM X IF P > Y ADD 15 TO X ELSE ADD 16 TO X ENDIF ENDSPRITE ENDIF IF DIRECTION = 1 OTHER LET IMAGE = 0 IF P > Y ADD 1 TO X ENDIF ENDSPRITE ENDIF ENDIF platform_test.mp4 (371.64 KB)
|
|