1
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
Super-Mario-Sunshine-C-Kit/examples/DoubleJump/doublejump.c
miluaces 646811b83c Updated library and linker with more functions
Added tools to patch Start.dol
Added more examples
2016-09-25 11:50:37 -07:00

27 lines
No EOL
903 B
C

#include "sms.h"
int doublejumped;
int preva;
int OnUpdate(MarDirector* director) {
int (*GameUpdate)(MarDirector* director) = GetObjectFunction(director, Director_GameUpdate);
//Update
MarioActor* mario = (MarioActor*)*gpMarioAddress;
//Check if mario is in the air
if (mario->status & STATE_AIRBORN)
{
//Check if mario has a double jump available and also if the user just pressed the A button this frame
if (!doublejumped && ControllerOne->buttons & PRESS_A && !preva)
{
doublejumped = 1;
**gpMarioSpeedY = 60.0f;
}
}
else //if mario isn't in the air give him another double jump to use.
doublejumped = 0;
//Save the current A press so it can be used to check if its pressed next frame (think of this as a 0.5 A press)
preva = ControllerOne->buttons & PRESS_A;
return GameUpdate(director);
}