LDX player1_object
;;; get to bank with lut tables
;; so we can read bottom of player
LDA onGround
BEQ cantJump
;;; if you want a *double jump*, need a variable
;;; that keeps track if we've jumped once as well.
;;; if we've already done a double jump, skips passed this too.
;;; on ground is factored in AccAndSpeed_Platform_Simple.
;;; you could also check to see if the player is hurt, if you dont
;;; want the player able to jump if he's hurt.
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$6
STA Object_v_speed_hi,x
cantJump:
LDA Object_x_hi,x
STA tileX
LDA Object_y_hi,x
CLC
ADC #$18 ;; the height of the player + however far you want to check beneath the player
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
CMP #$09 ;; the bounce tile type
BEQ JumpingOnTrampoline
LDA tileX
CLC
ADC #$10 ;; object width
STA tileX
JSR GetTileAtPosition
LDA collisionTable,y
CMP #$09
BEQ JumpingOnTrampoline
JMP notJumpingOnTrampolineTile
JumpingOnTrampoline:
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$09
STA Object_v_speed_hi,x
notJumpingOnTrampolineTile:
RTS