Skip to content

Commit

Permalink
port: measure nbomb age based on timestamps
Browse files Browse the repository at this point in the history
makes them last the same amount of time regardless of fps
  • Loading branch information
fgsfdsfgs committed Nov 26, 2023
1 parent 523e6ba commit 4a3c3a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/game/nbomb.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ void nbombReset(struct nbomb *nbomb)
#if VERSION >= VERSION_PAL_BETA
nbomb->radius = 0;
#endif
#ifndef PLATFORM_N64
nbomb->spawnframe240 = g_Vars.lvframe240;
#endif
}

/**
Expand Down Expand Up @@ -523,9 +526,14 @@ void nbombTick(struct nbomb *nbomb)
{
if (nbomb->age240 >= 0) {
s32 age60;
#ifdef PLATFORM_N64
s32 increment = (g_Vars.lvupdate240 + 2) >> 2;

nbomb->age240 += increment;
#else
s32 oldage240 = nbomb->age240;
nbomb->age240 = (g_Vars.lvframe240 - nbomb->spawnframe240) >> 2;
s32 increment = nbomb->age240 - oldage240;
#endif

if (nbomb->age240 < TICKS(80)) {
nbomb->radius = nbomb->age240 / (PAL ? 66.0f : 80.0f);
Expand Down
3 changes: 3 additions & 0 deletions src/include/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5510,6 +5510,9 @@ struct nbomb {
struct prop *ownerprop;
struct sndstate *audiohandle20;
struct sndstate *audiohandle24;
#ifndef PLATFORM_N64
s32 spawnframe240; // spawned on this frame
#endif
};

struct roomacousticdata {
Expand Down

0 comments on commit 4a3c3a2

Please sign in to comment.