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 -----------
----------- MoveRight -----------
----------- MoveUp -----------
----------- MoveDown -----------
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:
7. Make a new AI script:
----------- CopyMovingPlatformPos -----------
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:
14. In the Handle Physics file add this right after isSolidSoLand:
15. In the jumpThroughPlat file right after SwitchBank #$1C add this:
(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:
17. In the input script moveLeft add this right after GetActionStep temp:
18. In the input script moveRight add this right after GetActionStep temp:
19. In the input script changeActionToStop add this right after GetActionStep temp:
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!
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:
[4.5.6] A fully fonctonnal moving platform ?
Hello there, for my game I need a fully fonctionnal moving platform. By fully fonctionnal I mean a platform that carries along the player with its movements and not one wherethe player stay perfectly still while the platform moves away. Right I got a moving platform by creating a monster. Then...
www.nesmakers.com
1. Adding Monster Bits
[4.5.9] Adding Monster Bits back in
If you've seen the "Monster Bits" panel in the monster setup window you've probably wondered what to do with them or how to use them. They can work as another set of monster flags, but they're not included in your game by default. NES Maker exports them when you compile but you have to bring...
www.nesmakers.com
2. Vertical movement in the metrovania module
Vertical movement AI for enemies in metroidvania project
Hi! (first post on this forum) Just downloaded NesMaker a few days ago. I'm using the metroidvania template to try and get some hands-on experience with this tool, but I'm having trouble getting enemies to move vertically (while ignoring gravity). I found the "MoveLeft" asm, which is as...
www.nesmakers.com
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: