pit.baldriz
New member
Hi guys! Is there a way to create a trampoline on a scrolling platformer game? I just want to add one to my game.
;;BOUNCY TRAMPOLINE
;; trampoline
CPX player1_object
BNE notAPlayer_trampoline
LDA Object_v_speed_hi
BPL keepCheckingForTrampoline
;; should behave like solid.
notAPlayer_trampoline:
;;LDA #TILE_SOLID
;;STA tile_solidity
JMP doneWithTrampoline
keepCheckingForTrampoline:
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$02
STA Object_v_speed_hi,x
doneWithTrampoline:
;; check if on trampoline:
LDA Object_x_hi,x
STA tileX
LDA Object_y_hi,x
CLC
ADC Object_bottom,x
CLC
ADC #$08 ;; the height of the player + however far you want to check beneath the player
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
CMP #COL_TRAMPOLINE ;; the bounce tile type
BEQ JumpingOnTrampoline
LDA tileX
CLC
ADC #$10 ;; object width
STA tileX
JSR GetTileAtPosition
LDA collisionTable,y
CMP #COL_TRAMPOLINE ;; the bounce tile type
BEQ JumpingOnTrampoline
JMP notJumpingOnTrampolineTile
JumpingOnTrampoline:
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$08 ;; <-- HERE, the TRAMPOLINE JUMP value
STA Object_v_speed_hi,x
notJumpingOnTrampolineTile:
;; check if on trampoline:
LDA Object_x_hi,x
CLC
ADC Object_left,x
STA tileX
LDA Object_y_hi,x
CLC
ADC Object_bottom,x
CLC
ADC #$0E ;; <-- HERE: however far you want to check beneath the player
STA tileY
JSR GetTileAtPosition
LDA Object_scroll,x
AND #%00000001
BNE +
LDA collisionTable,y
JMP ++
+
LDA collisionTable2,y
++
CLC
CMP #COL_TRAMPOLINE ;; the bounce tile type
BEQ JumpingOnTrampoline
; LDA tileX
; CLC
; ADC #$10 ;; object width
; STA tileX
; JSR GetTileAtPosition
; LDA Object_scroll,x
; AND #%00000001
; BNE +
; LDA collisionTable,y
; JMP ++
; +
; LDA collisionTable2,y
; ++
; CLC
; CMP #COL_TRAMPOLINE ;; the bounce tile type
; BEQ JumpingOnTrampoline
JMP notJumpingOnTrampolineTile
JumpingOnTrampoline:
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$08 ;; <-- HERE, the TRAMPOLINE JUMP value
STA Object_v_speed_hi,x
notJumpingOnTrampolineTile:
;; check if on trampoline:
LDA Object_x_hi,x
CLC
ADC Object_left,x
STA tileX
LDA Object_y_hi,x
CLC
ADC Object_bottom,x
CLC
ADC #$0E ;; <-- HERE: however far you want to check beneath the player
STA tileY
JSR GetTileAtPosition
LDA collisionTable,y
CLC
CMP #COL_TRAMPOLINE ;; the bounce tile type
BEQ JumpingOnTrampoline
JMP notJumpingOnTrampolineTile
JumpingOnTrampoline:
ChangeObjectState #$02, #$02
LDA #$00
SEC
SBC #$08 ;; <-- HERE, the TRAMPOLINE JUMP value
STA Object_v_speed_hi,x
notJumpingOnTrampolineTile: