#pragma once #include "anm2.h" #include struct Game; struct Particle { Color color; Vec2 position; Vec2 velocity; float fill; float gravity; float life; float lifeMax; float size; }; void particle_draw(Renderer& renderer, Particle& particle, Vec2 position); // Text that hops up from where it appears and fades, like damage numbers. Jitter shakes it, in pixels. // Damage numbers also keep their value and which target they're over, so quick hits can add up. struct Popup { Color color; Vec2 position; Vec2 velocity; char text[16]; float jitter; float life; float scale; int target; int value; }; // Damage dealt at a moment in game time, for the DPS readout. struct Hit { float time = 0; int amount = 0; }; // A muzzle flash: a brief white star at the barrel, pointing along the shot. struct Flash { Color color; Vec2 position; float angle = 0; float life = 0; float size = 0; // The fighter, hand and weapon that fired it, for keeping it on the muzzle (see Scene::flash_follow). int owner = 0; int hand = 0; int weapon = 0; }; // A fading copy of a sprite left behind by something moving fast, and what its fighter wore (nothing, FASHION_NONE, // for an attack's). struct Afterimage { Pose pose; float life = 0; int worn = 0; }; // Particles, afterimages, text popups, screen shake and the damage-per-second tally. class Effects { public: void burst(Burst burst, Vec2 position, float angle, Color color); void afterimage_spawn(Pose pose, int worn); void flash_spawn(Flash flash); void afterimage_draw(Game& game); void number_spawn(Vec2 position, int value, int target, Color color); void dps_record(int amount); float dps_get(); void popup_spawn(Vec2 position, const char* text, Color color); void shake_add(float amount); Vec2 shake_get(); void update(); void draw(Game& game); void clear(); private: std::vector afterimages; std::vector flashes; std::vector hits; std::vector particles; std::vector popups; float shake = 0; int ticks = 0; };