Double Jump ability (simple/scrolling platformer module 4.1.5)
Because some of you asked me several times, here's a small tutorial for having a double-jump, unlockable as a powerup (from the "initial data" or given from a NPC or on Pickup object, ...) based on WolfMerrik's great scripts.
1) Create a new constant "didDoubleJump" in your "Project Settings > User Constants", with an initial value "0":
2) Create a new "a_double_jump.asm" script in your "Routines\Basic\ModuleScripts\InputScripts\SimplePlatformer\" folder, with that code:
3) Add the new "a_double_jump.asm" in your "Scripts > Input Scripts" (also, make you you added the "varJump.asm", we need that one too):
Note: If you have the a_simple_jump.asm in your input script, remove it, you will not need it anymore (right click -> remove)
4) In the "Input Editor", assign the "a_double_jump.asm" script to the "A" "Press" button for "MainGame":
(also, make sure to have assigned the "varJump.asm" to the "A" "Release" button)
Note: If you have the a_simple_jump.asm assigned in your input editor, remove it, you will not need it anymore (right click -> remove)
Now that we have the Double Jump feature unlockable, we can implement how/when we want to give it to the player... depending of your needs:
Possiblity A)
From the start, if you want the player would be able to double-jump, just open the project "Info" (Initial Data) and set the "Wepaon 3 unlocked":
Possiblity B)
From an NPC, if you want the player get that ability from an NPC, set your End of Text Action to "NPC Gives Item" and set the "MAGIC-Magic Type 3":
Possiblity C)
From a Pickup object, if you want the player get that ability when collecting a speical pickup item...
1) Create a new script "Powerup_DoubleJump.asm" in your "Routines\Basic\ModuleScripts\PowerUpCode\" folder, with that code:
2) In the "Project Settings > Script Settings", assign that "Powerup_DoubleJump.asm" to the PowerUp XX element you want to use:
For example here, I will use my "Charge pickup" object, so I assign the script to the "Power Up 01" element.
(the PowerUp script will trigger the screen, don't forget to set a unique screen-type value in your screen infos).
Voilà, it's not perfect but it it should work
Don't hesitate if you have issues, comments, modifications you want to share.
Because some of you asked me several times, here's a small tutorial for having a double-jump, unlockable as a powerup (from the "initial data" or given from a NPC or on Pickup object, ...) based on WolfMerrik's great scripts.
1) Create a new constant "didDoubleJump" in your "Project Settings > User Constants", with an initial value "0":
2) Create a new "a_double_jump.asm" script in your "Routines\Basic\ModuleScripts\InputScripts\SimplePlatformer\" folder, with that code:
Code:
;;;;; Double Jump
LDX player1_object
LDA screenFlags
AND #%00100000 ;; does it use gravity?
BNE +
JMP dontPlayerJump
+
;;; let's check for if we are standing on a Jumpthrough platform,
;;; for which "down and Jump" will Jump downwards through
;;; comment this out if you do not want that functionality
LDA Object_physics_byte,x
AND #%00001000
BEQ notStandingOnPlayerJumpThroughPlatform
LDA gamepad
AND #%00100000 ;; checking if down is pressed
BEQ notStandingOnPlayerJumpThroughPlatform
LDA Object_y_hi,x
CLC
ADC #$09
STA Object_y_hi,x
JMP dontPlayerJump
notStandingOnPlayerJumpThroughPlatform:
LDA Object_physics_byte,x
AND #%00000001
BNE canPlayerJump
LDA Object_physics_byte,x
AND #%00000100
BNE canPlayerJump
;; Double Jump ?:
LDA weaponsUnlocked
AND #%00000100 ;; is "MAGIC-Magic Type 2" / "Weapon 3" unlocked?
BEQ dontPlayerJump
LDA didDoubleJump
BNE +
LDA #$01
STA didDoubleJump
JMP canPlayerJumpAgain
+
JMP dontPlayerJump
canPlayerJump:
LDA #$00
STA didDoubleJump
canPlayerJumpAgain:
;;; TURN OFF "STANDING ON JumpTHROUGH PLATFORM" if it is on
LDA Object_physics_byte,x
AND #%11110111
STA Object_physics_byte,x
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LDA #$00
SEC
SBC #JUMP_SPEED_LO
STA Object_v_speed_lo,x
LDA #$00
SEC
SBC #JUMP_SPEED_HI
STA Object_v_speed_hi,x
GetCurrentActionType player1_object
CMP #$03 ;; attack
BEQ +
ChangeObjectState #$02, #$04
+
PlaySound #SND_JUMP
dontPlayerJump:
RTS
3) Add the new "a_double_jump.asm" in your "Scripts > Input Scripts" (also, make you you added the "varJump.asm", we need that one too):
Note: If you have the a_simple_jump.asm in your input script, remove it, you will not need it anymore (right click -> remove)
4) In the "Input Editor", assign the "a_double_jump.asm" script to the "A" "Press" button for "MainGame":
(also, make sure to have assigned the "varJump.asm" to the "A" "Release" button)
Note: If you have the a_simple_jump.asm assigned in your input editor, remove it, you will not need it anymore (right click -> remove)
Now that we have the Double Jump feature unlockable, we can implement how/when we want to give it to the player... depending of your needs:
Possiblity A)
From the start, if you want the player would be able to double-jump, just open the project "Info" (Initial Data) and set the "Wepaon 3 unlocked":
Possiblity B)
From an NPC, if you want the player get that ability from an NPC, set your End of Text Action to "NPC Gives Item" and set the "MAGIC-Magic Type 3":
Possiblity C)
From a Pickup object, if you want the player get that ability when collecting a speical pickup item...
1) Create a new script "Powerup_DoubleJump.asm" in your "Routines\Basic\ModuleScripts\PowerUpCode\" folder, with that code:
Code:
;;; Double Jump powerup code
LDA weaponsUnlocked
ORA #%00000100 ;; "MAGIC-Magic Type 2" / "Weapon 3" unlocked
STA weaponsUnlocked
TriggerScreen screenType
PlaySound #SND_POWERUP
2) In the "Project Settings > Script Settings", assign that "Powerup_DoubleJump.asm" to the PowerUp XX element you want to use:
For example here, I will use my "Charge pickup" object, so I assign the script to the "Power Up 01" element.
(the PowerUp script will trigger the screen, don't forget to set a unique screen-type value in your screen infos).
Voilà, it's not perfect but it it should work
Don't hesitate if you have issues, comments, modifications you want to share.