Doing a trampoline in scrolling platformer

dale_coop

Moderator
Staff member
I tested the script... I just changed the:
Code:
	ADC #$0E ;; <-- HERE: however far you want to check beneath the player

To something smaller, I think for that module 04 would be enough...
Code:
	ADC #$04 ;; <-- HERE: however far you want to check beneath the player

And seems like it works well, for player 1 and player 2.

jump.gif
 

TolerantX

Active member
This is my current jump input code.... the player 2 currently still falls through.



Code:
    ;; checking the current state of the player:
    GetCurrentActionType player1_object
    CMP #$07	;; if in "invisible" state
    BNE +
    ;; skip the script:
    RTS
    +
    
    ;; from here the rest of the script:

; load the playerX_object (current inputs):
JSR PlayerXobjectInputs

goJump:
    ;; if on a cutscene:
    LDA screenFlags
    AND #%00000010
    BEQ +
    RTS
    +
    LDA isPaused
    BEQ +
    RTS
    +

    ; a jumps
 
   ;LDX player1_object
   ;;; 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 screenFlags
    AND #%00100000 ;; does it use gravity?
    BNE usingGravity
    JMP dontJump
usingGravity:
   LDA Object_physics_byte,x
   AND #%00001000
   BEQ notStandingOnJumpThroughPlatform

   CPX player2_object
   BNE +
   LDA gamepad2
   AND #%00100000   ;; pressing Down?
   BEQ notStandingOnJumpThroughPlatform
   JMP ++
   +
   LDA gamepad
   AND #%00100000   ;; pressing Down?
   BEQ notStandingOnJumpThroughPlatform
   ++

   LDA Object_y_hi,x
   CLC
   ADC #$09
   STA Object_y_hi,x
   JMP dontJump
notStandingOnJumpThroughPlatform:
   
   LDA Object_physics_byte,x
   AND #%00000001
   BNE canJump
   LDA Object_physics_byte,x
   AND #%00000100   ;; solid under player's feet ?
   BNE canJump
   JMP dontJump
   
   
   ;; jump on walls
    ; LDA collisionPoint2 
    ; ORA collisionPoint3
    ; AND #%10000000
    ; BNE canJump
    ; LDA collisionPoint1
    ; ORA collisionPoint4
    ; AND #%10000000
    ; BNE canJump

   ;;JMP dontJump
    
canJump:
    ;PlaySound #SND_JUMP
canJumpAgain:
    ;;; 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
    CPX player1_object
    BEQ +
        GetCurrentActionType player2_object
        JMP ++
    +
        GetCurrentActionType player1_object
    ++
    CMP #$03 ;; attack
    BEQ +
    ChangeObjectState #$02, #$04
    +
    ;PlaySound #SND_JUMP
dontJump:
;; 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 #$04 ;; <-- 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:
    RTS
 

dale_coop

Moderator
Staff member
The 7 lines at the beginning of your script should not be here.
Those are not compatible with the 2 player module.

Try without those lines.
 

Dirk

Member
Hi Dale!

I tried your trampoline script and it works, but sadly with a slight issue.
When I try to walk past a trampoline my player gets "sucked up" to the top of it.There he keeps jumping a few pixels up and down. Maybe this picture helps illustrating what I mean:



TrampolineTile.png
 

Dirk

Member
Okay, I managed to stop getting sucked up and the mini jumps.
I added two User Variables (Project -> Project Settings):

  1. autoJumpTrampoline: either '0' or '1'; moves the player to the top of the trampoline and auto bounces him
  2. autoJumpHeightTrampoline: e.g. '4'; how far the trampoline bounces the player without controller input

This is my changed TrampolineTile.asm file:

Code:
;;BOUNCY TRAMPOLINE
;; trampoline

;; create two user variables:
;;	*) autoJumpTrampoline
;;	*) autoJumpHeightTrampoline
;;
;; If you want the player to jump without controller input
;; set autoJumpTrampoline to '1'
;; Set jump height in autoJumpHeightTrampoline (e.g. '4')

	CPX player1_object
	BNE notAPlayer_trampoline
	LDA Object_v_speed_hi
	BPL keepCheckingForTrampoline
notAPlayer_trampoline:
	JMP doneWithTrampoline
keepCheckingForTrampoline:
	LDA #%00000100  ; Trampoline should act like One Way Tile
	STA tile_solidity
	LDA autoJumpTrampoline
	AND #$01
	BEQ +
	ChangeObjectState #$02, #$02
	LDA #$00
	SEC
	SBC autoJumpHeightTrampoline
	STA Object_v_speed_hi,x
+
doneWithTrampoline:
 
Top Bottom