Have different gravity on specific screen types (4.5.9)

baardbi

Member
Here's a tutorial for making levels with different gravity on specific screens based on screenType.

This can for example be used to make underwater levels or space type levels.

PS! This tutorial is made for platform type games.

1.
Make a backup of doHandlePhysics_PlatformBase.asm
It's located in ...\BASE_4_5\Game\MOD_PlatformerBase\Subroutines

2.
Comment out the lines about gravity. It's somewhere around line 475

;MAX_FALL_SPEED = #$04
;GRAVITY_LO = #$40
;GRAVITY_HI = #$00

3.
Then add user variables for every one of those constants

gravityConst.PNG

4.
Then remove the # in front of the references to gravity (somewhere around line 710)

ADC GRAVITY_LO
STA Object_v_speed_lo,x
LDA Object_v_speed_hi,x
ADC GRAVITY_HI
STA Object_v_speed_hi,x

LDA Object_v_speed_hi,x
CMP MAX_FALL_SPEED

Just to be sure, we're talking about these three values:

GRAVITY_LO
GRAVITY_HI
MAX_FALL_SPEED

5.
Make a backup of extraScreenLoad_PlatformBase.asm
It's located in ...\BASE_4_5\Game\MOD_PlatformerBase\Game

6.
At the end of the extraScreenLoad_PlatformBase.asm file put this:

LDA screenType
CMP #$01 ;;;; This is the screen type for special gravity
BEQ +specialGravity

JMP +finishedGravityCheck

+specialGravity:

LDA #$02
STA MAX_FALL_SPEED
LDA #$20
STA GRAVITY_LO
LDA #$00
STA GRAVITY_HI

+finishedGravityCheck:

7.
Set screen type to 1 on the screens you want special gravity on. The default here is 1 but can of course be changed.

8.
You should now have screens with low gravity. You can experiment with different values for MAX_FALL_SPEED, GRAVITY_LO and GRAVITY_HI for a different effect.


Let me know if something in this tutorial isn't working.
 
@baardbi this was gold! thank you!
i implemeted it as my gravity change for swimming so it works on my swiming action step! very simple way of doing it!

my doHandlePhysics_PlatformBase.asm looks like this
Code:
            LDA Object_v_speed_lo,x
            CLC
            ADC GRAVITY_LO
            STA Object_v_speed_lo,x
            LDA Object_v_speed_hi,x
            ADC GRAVITY_HI
            STA Object_v_speed_hi,x
            
                LDA Object_v_speed_hi,x
                CMP MAX_FALL_SPEED
                BNE notOverFallSpeed
                    ;; is at least max fall speed.
                    LDA #$00
                    STA Object_v_speed_lo,x
                notOverFallSpeed:
                
            GetActionStep #$00
            CMP #$06
            BEQ +SWIM

            JMP +finishedGravityCheck

            +SWIM:

            LDA #$01
            STA MAX_FALL_SPEED
            LDA #$10
            STA GRAVITY_LO
            LDA #$00
            STA GRAVITY_HI

+finishedGravityCheck:
    
    JMP doneWithGravity
 

baardbi

Member
@baardbi this was gold! thank you!
i implemeted it as my gravity change for swimming so it works on my swiming action step! very simple way of doing it!

my doHandlePhysics_PlatformBase.asm looks like this
Code:
            LDA Object_v_speed_lo,x
            CLC
            ADC GRAVITY_LO
            STA Object_v_speed_lo,x
            LDA Object_v_speed_hi,x
            ADC GRAVITY_HI
            STA Object_v_speed_hi,x
           
                LDA Object_v_speed_hi,x
                CMP MAX_FALL_SPEED
                BNE notOverFallSpeed
                    ;; is at least max fall speed.
                    LDA #$00
                    STA Object_v_speed_lo,x
                notOverFallSpeed:
               
            GetActionStep #$00
            CMP #$06
            BEQ +SWIM

            JMP +finishedGravityCheck

            +SWIM:

            LDA #$01
            STA MAX_FALL_SPEED
            LDA #$10
            STA GRAVITY_LO
            LDA #$00
            STA GRAVITY_HI

+finishedGravityCheck:
   
    JMP doneWithGravity
Cool! You're welcome. Glad to be of help.
 

cramske

Member
I think Im confused now. I am using a combination of scripts. I am a newbie. I would love to do this.
Im using arcade platformer and adventure basescripts. my dohandlePhysics is Arcade platformer and my extra screen load is Adventure base.. ?
Maybe I am doing this wrong?
 

baardbi

Member
I think Im confused now. I am using a combination of scripts. I am a newbie. I would love to do this.
Im using arcade platformer and adventure basescripts. my dohandlePhysics is Arcade platformer and my extra screen load is Adventure base.. ?
Maybe I am doing this wrong?
Sorry. I haven't used those modules much lately. I'm guessing the arcade platformer would be pretty similar. The big thing here is changing the constants to variables. I'll have to look more into those modules you're using, but unfortunately I'm super busy trying to finish Nosey Joe at the moment. I'll let you know if I find out something that can be of any help to you.
 
Top Bottom