[FEATURE] bullet shooting

This commit is contained in:
SemvdH
2021-05-20 16:18:18 +02:00
parent bc5ee01ae7
commit 8c7aa08ef7
4 changed files with 72 additions and 13 deletions

View File

@@ -17,3 +17,19 @@ uint8_t timing_get_fps(SceUInt64 dt)
{
return (1 / (dt / 1000.0));
}
void timing_update_timer(timing_timer* timer, SceUInt64 dt)
{
timer->time += dt;
}
uint8_t timing_check_timer_elapsed(timing_timer* timer)
{
if (timer->time > timer->timeout)
{
timer->time = 0;
timer->elapsed = 1;
return 1;
}
return 0;
}

View File

@@ -2,6 +2,14 @@
#define TIMING_H
#include <psp2/kernel/processmgr.h>
#include <sys/types.h>
typedef struct
{
timer_t time;
SceUInt64 timeout;
uint8_t elapsed;
} timing_timer;
/**
* @brief gets the delta time in ms. (the duration since this function was last called)
@@ -9,7 +17,8 @@
* @param sysclock the system kernel clock pointer to use
* @return SceUInt64 the delta time in ms
*/
SceUInt64 timing_get_deltatime(SceKernelSysClock *sysclock);
SceUInt64
timing_get_deltatime(SceKernelSysClock *sysclock);
/**
* @brief calculates the fps based on the given delta time
@@ -18,4 +27,20 @@ SceUInt64 timing_get_deltatime(SceKernelSysClock *sysclock);
* @return uint8_t the fps
*/
uint8_t timing_get_fps(SceUInt64 dt);
/**
* @brief updates a timer with the last frametime
*
* @param timer the timer to update
* @param dt the deltatime
*/
void timing_update_timer(timing_timer* timer, SceUInt64 dt);
/**
* @brief checks if the given timer has elapsed or not
*
* @param timer the timer to check
* @return uint8_t 0 if false, nonzero if true
*/
uint8_t timing_check_timer_elapsed(timing_timer* timer);
#endif