*** EXPERIMENTAL *** Moving Platforms in the metroVania module *** EXPERIMENTAL ***

baardbi

Well-known member
!!! WARNING !!!
This tutorial will change a lot of core files in your NESmaker project. So proceed with caution. I recommend that you try this on a test project.

This will add the ability to have both vertical and horizontal moving platforms in your game. HOWEVER!!!! This has not been tested enough and could cause unexpected behaviour in your game.


This is far from perfect. One issue is that you can not move while on the moving platform. The only way to get off the moving platform is to jump off. Another issue is that the player movement is very jerky while standing on the moving platform.

Before you begin this tutorial you will need to do two other tutorials first. These are included below as step 1 and 2.

PS! Right after posting this tutorial I learned that there is an alternative tutorial for moving platforms. Here it is:


1. Adding Monster Bits

2. Vertical movement in the metrovania module

3. Add a new user variable: onMovingPlatform

4. Create four new AI scripts:


----------- MoveLeft -----------
;;; Move left

STX temp
StartMoving temp, #LEFT


----------- MoveRight -----------
;;; Move right

STX temp
StartMoving temp, #RIGHT


----------- MoveUp -----------
;;; Move up

STX temp
StartMoving temp, #UP


----------- MoveDown -----------
;;; Move down

STX temp
StartMoving temp, #DOWN


5. Assign the new AI scripts in Script Settings. I recommend replacing the original MoveLeft to avoid confusion. I also recommend renaming the AI actions in "Project Settings - Project Labels - Action Types" to appropriate names (MoveUp instead of AI_Behavior05, MoveDown instead of AI_Behavior06 and so on).

6. In the player hurt file add this under +canHurtPlayer:

;;;;;;;;;;;;;;;;;; Moving platform ;;;;;;;;;;;;;;;;;;;;;;;;;

TXA
PHA

LDX otherObject
LDY Object_type,x
LDA MonsterBits,y
AND #%00000001
BEQ +notMovingPlatform
GetActionStep player1_object
CMP #6
BEQ +skipMovingPlatform
LDA Object_v_speed_hi,x
BEQ +skipMovingPlatform
BMI +skipMovingPlatform
GetActionStep player1_object
CMP #6
BEQ +skipMovingPlatform
ChangeActionStep player1_object, #6
+skipMovingPlatform:
PLA
TAX
JMP +skipHurt
+notMovingPlatform:
PLA
TAX

7. Make a new AI script:

----------- CopyMovingPlatformPos -----------
; Copy moving platform position

LDY otherObject

LDA Object_y_hi,y
SEC
SBC #16 ;Height of player
STA Object_y_hi,x

LDA Object_x_hi,y
STA Object_x_hi,x

LDA #1
STA onMovingPlatform

8. Assign the new script in Script Settings and give the action an appropriate name in "Project Labels - Action Types" (CopyMovingPlatformPos instead of AI_Behavior07)

9. In the "Object Details - Actions" for the player objects set up these settings:
*** Action Step 6 *** (Must be action step 6 for this to work)

- Action = CopyMovingPlatformPos
- Check "Ignore Gravity" for this action step
- Animation Speed = 1
- End Animation = Repeat

10. In "Project Settings - Project Labels - Monster Bits" change Bit-0 to Moving Platform

11. Create a new game object. Call it MovingPlatformV (this is the vertical platform)
- Make it 2 tiles wide
- Select the graphics and palette for this object
- Set the bounding box to cover the entire graphics for the platform
- Under "Details - Monsters Bits", check Moving Platform
- Set normal max speed to 8 and acceleration speed to max
- Under "Actions" set the two first action steps like this:

Action Step 0:
- Ignore Gravity
- Action = MoveUp
- Timer = 10
- End Action = Advance

Action Step 1:
- Ignore Gravity
- Action = MoveDown
- Timer = 10
- End Action = GoToFirst

12. Create a new game object. Call it MovingPlatformH (this is the horizontal platform)
- Make it 2 tiles wide
- Select the graphics and palette for this object
- Set the bounding box to cover the entire graphics for the platform
- Under "Details - Monsters Bits", check Moving Platform
- Set normal max speed to 8 and acceleration speed to max
- Under "Actions" set the two first action steps like this:

Action Step 0:
- Ignore Gravity
- Action = MoveLeft
- Timer = 10
- End Action = Advance

Action Step 1:
- Ignore Gravity
- Action = MoveRight
- Timer = 10
- End Action = GoToFirst

13. In the Handle Object Collisions file add this under +isNotPlayerNPCCol:

LDY Object_type,x
LDA MonsterBits,y
AND #%00000001 ;Moving platform
BNE +isPlayerMovingPlatformCol
JMP +isNotPlayerMovingPlatformCol
+isPlayerMovingPlatformCol
JSR getOtherColBox
JSR doCompareBoundingBoxes
BNE +doCollision
JMP +skipCollision
+doCollision
TXA
STA otherObject
;; There was a collision between a player and a moving platform.
;; player is self.
;; moving platform is other.
JSR doHandleHurtPlayer
JMP +done

+isNotPlayerMovingPlatformCol

14. In the Handle Physics file add this right after isSolidSoLand:

LDA #0
STA onMovingPlatform

15. In the jumpThroughPlat file right after SwitchBank #$1C add this:

LDA onMovingPlatform
BEQ +notOnMovingPlatform
LDA #0
STA onMovingPlatform
JMP +doJump
+notOnMovingPlatform

(Optional)
This will prevent the player from jittering if you try to move left or right when standing on the platform. *** IMPORTANT *** The only way to get off the platform is to jump off.

16. In the input script changeActionToMoving add this right after GetActionStep temp:
CMP #$06
BNE +notOnMovingPlatform
RTS
+notOnMovingPlatform

17. In the input script moveLeft add this right after GetActionStep temp:
CMP #$06
BNE +notOnMovingPlatform
RTS
+notOnMovingPlatform

18. In the input script moveRight add this right after GetActionStep temp:
CMP #$06
BNE +notOnMovingPlatform
RTS
+notOnMovingPlatform

19. In the input script changeActionToStop add this right after GetActionStep temp:
CMP #$06
BNE +notOnMovingPlatform
RTS
+notOnMovingPlatform


That's it. If you followed these steps with a project created with an unmodified version of NESmaker you should now have moving platforms. Let me know if I forgot something or if there are some errors in the code.

Have fun!
 
Last edited:

tbizzle

Well-known member
How hard would it be to convert this for an "Adventure Module" style game? Well maybe impossible now that I am reading you have to jump off of it, lol.
 

baardbi

Well-known member
How hard would it be to convert this for an "Adventure Module" style game? Well maybe impossible now that I am reading you have to jump off of it, lol.
It would be very hard. Since the physics in the Adventure module is very different from the platform modules you would have to do this in a completely different way. I guess you could have an object that would move the player up and down (the Y-axis) but the whole thing would have to be programmed from scratch.
 

tbizzle

Well-known member
It would be very hard. Since the physics in the Adventure module is very different from the platform modules you would have to do this in a completely different way. I guess you could have an object that would move the player up and down (the Y-axis) but the whole thing would have to be programmed from scratch.
I had a feeling it might be a tough one to do.
 
Top Bottom