Gravity-Changing Air Blocks

DanielT1985

Member
This might be impossible, but I was just curious to ask. Is there a way to make a block that, when the player stands in an area covered in the block, would make them jump higher or have less gravity? I'm working on a game that has a space arena that makes the player jump like they were on the moon, so that's why I was asking.
 

WillElm

New member
I was also thinking about how you would go about changing gravity. It's a constant. I guess maybe you could make a variable, and then find everywhere in the code where it references the gravity constant and make it reference your variable(s) instead. It's probably not that simple, but maybe it is.
 

Mugi

Member
it is that simple. but the workload on doing that is a bit of a pita.
In my game, i only use altered gravity in a very limited fashion and i just went around it by modifying the player physics instead but it's not really a particularly efficient way to deal with things.

another issue is that if you wish to have a real "floaty" physics, you will also need to gain access to altering the acceleration of the objects, and the acceleration is neither a variable, nor a constant, it is stored per-object in the OAM table.
there is a thread somewhere around the forum where this was discussed, and it is possible to tap into the part of the code that calculates the acceleration of objects, and change it there, but again, that's just another workaround.
 

WillElm

New member
Mugi said:
it is that simple. but the workload on doing that is a bit of a pita.

In order to make a script reference a user variable instead of a constant, do you just delete the "#"?

I found the gravity macro, which uses the gravity constant, but I couldn't find anywhere else that does.

Here's the part that uses the constant. I just deleted the # and of course that didn't give the desired effect. there must be other places in the code.

Code:
dontSkipGravity:
	;LDA Object_physics_byte,x
	;AND #%00000001
	;BNE ignoreGravity
	LDA Object_v_speed_lo,x
	CLC
	ADC #GRAVITY_LO
	STA Object_v_speed_lo,x ;temp
	LDA Object_v_speed_hi,x
	ADC #GRAVITY_HI
	STA Object_v_speed_hi,x ;temp1
 
Top Bottom