CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
Fx.h File Reference

Motion maths and the screen shake: easing, integer sine, randomness. More...

#include <stdint.h>

Go to the source code of this file.

Namespaces

namespace  fx
 Effects: motion maths, the screen shake, and (chgame/Sizzle.h) particles, banners and floating texts.
 

Enumerations

enum  fx::Ease : uint8_t {
  fx::LINEAR ,
  fx::OUT_CUBIC ,
  fx::OUT_BACK ,
  fx::IN_OUT ,
  fx::OUT_BOUNCE
}
 Easing curves for ease(). More...
 

Functions

int fx::easeCurve (const int16_t *curve, int t, int n)
 Ease through a curve table.
 
int fx::ease (Ease e, int t, int n)
 Ease: progress through a curve.
 
int fx::bounce (int t, int n)
 The OUT_BOUNCE curve.
 
int fx::isin (int a)
 Integer sine.
 
int fx::icos (int a)
 Integer cosine.
 
uint32_t fx::rnd ()
 A random number for presentation (xorshift32).
 
int fx::rndRange (int lo, int hi)
 A random number in a range, for presentation.
 
void fx::reseed ()
 Restart rnd() from its fixed seed.
 
void fx::shake (uint8_t frames, uint8_t amplitude)
 Start a screen shake.
 
bool fx::shaking ()
 Whether a shake is running.
 
void fx::applyShake (int y0, int y1, int fill=-1)
 Shake the finished framebuffer: call after drawing, before the flush.
 
void fx::shakeTick ()
 Count the shake down one tick: once per logic tick.
 
void fx::shakeStop ()
 Stop the shake at once.
 

Variables

const int16_t fx::EASE_CUBIC [17]
 The curves' tables (17 points, 0..256), for easeCurve().
 

Detailed Description

Motion maths and the screen shake: easing, integer sine, randomness.

Integer maths only: soft-float trig once cost a demo on this chip 8.5 KB of flash and half its frame rate.

A game's own effects (its particle kinds, banners, floating texts) live in the same namespace in the game's code, built from these (see chgame/Sizzle.h).