baardbi
Well-known member
PS!!!! This tutorial is outdated. I made a new tutorial that is much better:
I DID IT !!! I modified the original code from Joe. It works with a little bug. If you tap the A button really quickly you get infinite jumps. But at least it's a good start. Here's the code:
Double Jump in Platform Games 4.5.9
This tutorial will add the ability to double jump in the platform modules (Arcade Platformer, MetroVania and LR Platformer). 1. Add a new User Variable: jumpCounter 2. In your jump_throughPlat.asm file add this at the top of the file under SwitchBank #$1C : ;;; Double jump check LDA...
www.nesmakers.com
I DID IT !!! I modified the original code from Joe. It works with a little bug. If you tap the A button really quickly you get infinite jumps. But at least it's a good start. Here's the code:
Code:
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only can jump if the place below feet is free.
SwitchBank #$1C
LDY Object_type,x
LDA ObjectBboxTop,y
CLC
ADC ObjectHeight,y
sta temp2
LDA Object_x_hi,x
CLC
ADC ObjectBboxLeft,y
STA temp
JSR getPointColTable
LDA Object_y_hi,x
CLC
ADC #$02
CLC
ADC temp2
STA temp1
CheckCollisionPoint temp, temp1, #$00, tempA ;; check below feet to see if it is NULL (in the air).
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BNE noDoubleJump
LDA gotDoubleJump
CMP #$01
BNE noDoubleJump
LDA doubleJumpCounter
CMP #$02
BEQ noDoubleJump
JMP +doJump
noDoubleJump:
LDA #$00
STA doubleJumpCounter
CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BNE +checkMore
JMP +doJump
+checkMore
CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BNE +checkMore
JMP +doJump
+checkMore
CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is prize block .
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BNE +checkMore
JMP +doJump
+checkMore
CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BNE +dontDoJump
JMP +doJump
+dontDoJump
;; check second point.
LDY Object_type,x
LDA ObjectWidth,y
CLC
ADC temp
STA temp
JSR getPointColTable
CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BEQ +doJump
CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BEQ +doJump
CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is jumpthrough platform.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BEQ +doJump
CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
;;; if it is (equal), can jump.
;;; if not, skips jumping.
BEQ +doJump
JMP +skipJumping
+doJump:
TXA
STA temp ;; assumes the object we want to move is in x.
;PlaySound #sfx_thump
LDY Object_type,x
LDA ObjectJumpSpeedLo,y
EOR #$FF
STA Object_v_speed_lo,x
LDA ObjectJumpSpeedHi,y
EOR #$FF
STA Object_v_speed_hi,x
TXA
STA temp ;; assumes the object we want to move is in x.
; change the object's action so that he is in jump mode.
INC doubleJumpCounter
+skipJumping:
ReturnBank
RTS
Last edited: