CHGame 0.3.0
Libraries for the CHGame handheld
Loading...
Searching...
No Matches
Particles, banners and floating texts

fx:: particles (sparks, confetti, coins ...), the pop-up banner and floating texts, configured per game. More...

Namespaces

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

Detailed Description

fx:: particles (sparks, confetti, coins ...), the pop-up banner and floating texts, configured per game.

The library is compiled apart from a sketch and sees none of its defines, and the twenty games differ in what they need (how many particles, which kinds, which banner, floats or not) and in the size tuning of the file that holds the code. So a game configures it in its own src/fx/Fx.h and the bodies are compiled in the game's src/fx/Fx.cpp:

// src/fx/Fx.h
#pragma once
#include <CHGame.h>
#define SIZZLE_CONFIGURED 1
#define SIZZLE_POOL 64 // only what differs from the defaults below
#include <chgame/Sizzle.h>
namespace fx { void explode(int x, int y, uint8_t n); } // the game's own extras, if any
// src/fx/Fx.cpp
#pragma GCC optimize("Os") // line 1: it governs the bodies included below
#include "Fx.h"
#include <chgame/Sizzle.inl>
The one include for a CHGame sketch.
Motion maths and the screen shake: easing, integer sine, randomness.
Sizzle: the particle pool, the pop-up banner and the floating "+$15" texts the games share,...
Effects: motion maths, the screen shake, and (chgame/Sizzle.h) particles, banners and floating texts.
Definition Fx.h:25

Every call site stays fx::burst(), fx::banner() and so on. Each frame: fx::update() once per logic tick; when drawing, fx::drawParticles(), fx::drawFloats() and fx::drawBanner() on top of the scene.

Positions are pixels; particle velocities are in 1/16 px per tick. This page documents the default configuration (the kinds SPARK, CONFETTI, STAR and DUST; the five banner styles; floats on).

The switches (the games' own are listed in docs/chgame-library.md):

Switch Default Meaning
SIZZLE_POOL 48 particles in the pool
SIZZLE_KIND_SPARK / _STAR / _DUST 1 the kinds that exist (CONFETTI always does)
SIZZLE_KIND_COIN 0 bouncing coins; also fountain(Kind, ...) instead of fountain(x, y, n)
SIZZLE_KIND_RAIN 0 falling drops, named SIZZLE_RAIN_KIND_NAME (RAIN_DROP; RAIN in the card games, whose hue table is then not exported under that name)
SIZZLE_KIND_GOO 0 CHBingo's ink blobs
SIZZLE_KIND_ORDER - the enumerators in another order (CHBoardwalk: COIN last)
SIZZLE_BURST 1 burst() exists
SIZZLE_COLOUR_INLINE 0 (code shape) drawParticles() reads p.colour in place instead of a local
SIZZLE_COIN_LATE 0 (code shape) the COIN case comes after DUST and STAR, as in CHBoardwalk
SIZZLE_DUST 3 how DUST draws: 1 one pixel, 2 a puff of size 2, 3 a puff of the size drawParticles(dust) is given (default 2)
SIZZLE_FOUNTAIN_GOLD_COINS = COIN fountain(COIN, ...) spawns gold coins (else confetti colours)
SIZZLE_COIN_FLOOR 122 the row coins bounce on; SIZZLE_COIN_FLOOR_RUNTIME 1 adds setFloor()
SIZZLE_HUES {RED, GOLD, FELT_LT, CYAN, BLUE} the casino rainbow
SIZZLE_HUES_EXPORT 1 exported as extern const uint8_t SIZZLE_HUES_NAME[5] (RAIN)
SIZZLE_CONFETTI_COLOURS {RED, GOLD, FELT_LT, CYAN, BLUE, WHITE} confetti's colours
SIZZLE_NO_PARTICLES 0 1: spawn(), burst(), fountain() and drawParticles() do nothing (a game's device debug build sets it to make room)
SIZZLE_FLOATS 1 floatText()/drawFloats(); SIZZLE_FLOAT_CHARS 8 (the text, with its 0), SIZZLE_FLOAT_CLAMP 0 (keep it on screen), SIZZLE_FLOAT_BLINK_FIRST 0
SIZZLE_BANNER_DROP 0 0: letters of the 3x5 font pop in at 2x, 4x, 3x (maskText35); 1: the game's display font, letters dropping in one by one (the game provides maskFont(), fontWidth() and FONT_H, or SIZZLE_FONT_MASK/SIZZLE_FONT_WIDTH/SIZZLE_FONT_H)
SIZZLE_BANNER_CHARS 14 the banner's text, with its 0
SIZZLE_BANNER_ROWS_UP / _DOWN 18/18 (drop: 30/12) rows around the centre activeRows() reports
SIZZLE_STYLES RAINBOW|GOLD|RED|CYAN|WHITE the BannerStyle enumerators (SIZZLE_BLACK, SIZZLE_GREEN too)
SIZZLE_STYLE_RAMPS = STYLES the styles with a colour ramp of their own (the rest draw as the default)
SIZZLE_CYAN_INK CYAN (drop) the B_CYAN ink
SIZZLE_BANNER_FILL 0 the mask's fill (unused under a ramp; kept per game for identical code)
SIZZLE_HOLD_BANNER 1 holdBanner()
SIZZLE_BANNER_WRAP 1 the dance phase wraps to 128 (kept per game for identical code)
SIZZLE_SHAKE 1 the screen shake joins activeRows(), update() and clear()
SIZZLE_BANNER_AFTER(x, y, dy, gap) - (drop) a pass after the banner is drawn (CHDominoes' half ink)