Doing a trampoline in scrolling platformer

User avatar
dale_coop
Posts: 5611
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Doing a trampoline in scrolling platformer

Post by dale_coop » Sat Jan 11, 2020 9:05 pm

With that script? interesting... I'll check later...
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
dale_coop
Posts: 5611
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Doing a trampoline in scrolling platformer

Post by dale_coop » Sat Jan 11, 2020 9:15 pm

I tested the script... I just changed the:

Code: Select all

	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: Select all

	ADC #$04 ;; <-- HERE: however far you want to check beneath the player
And seems like it works well, for player 1 and player 2.

Image
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
TolerantX
Posts: 68
Joined: Fri Jan 18, 2019 7:58 am

Re: Doing a trampoline in scrolling platformer

Post by TolerantX » Tue Jan 14, 2020 5:53 pm

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


Code: Select all

    ;; 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
User avatar
dale_coop
Posts: 5611
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Doing a trampoline in scrolling platformer

Post by dale_coop » Tue Jan 14, 2020 9:19 pm

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.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
Dirk
Posts: 589
Joined: Fri Mar 09, 2018 5:30 am

Re: Doing a trampoline in scrolling platformer

Post by Dirk » Sat Mar 21, 2020 6:41 pm

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
TrampolineTile.png (1.11 KiB) Viewed 861 times
-----
Disclaimer: English is not my first language, so mistakes are bound to happen.
User avatar
Dirk
Posts: 589
Joined: Fri Mar 09, 2018 5:30 am

Re: Doing a trampoline in scrolling platformer

Post by Dirk » Mon Mar 23, 2020 1:32 am

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: Select all

;;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:
-----
Disclaimer: English is not my first language, so mistakes are bound to happen.
Post Reply