#ifndef SPRITE_H_70503825 #define SPRITE_H_70503825 #include #include #include #include #include "direction.h" #include "renderer.h" #include "vector.h" #include "step_type.h" enum class SpriteLayer { Mask, Normal, Above, NUM_SPRITE_LAYERS // do not use }; struct SpriteFrame { SDL_Rect srcRect; vec2i center; vec2i size; }; struct Animation { bool looping = true; std::vector frameIndices; int timerNum = 0; }; enum class CharacterState { Still, Walking, Crouching, Running }; enum class CharacterMedium { Normal, Ladder, Water }; enum class BehaviourType { None, Wander, Path, Follow }; enum class MirrorType { None, Vertical }; struct Movement { vec2i pos; Direction dir; CharacterMedium medium; }; struct PathfindingInstruction { Direction dir; vec2i endpoint; }; class Sprite { public: std::string alias; bool persistent = false; bool paused = false; // Transform vec2i loc { 0, 0 }; SpriteLayer layer = SpriteLayer::Normal; bool collidable = false; bool solid = false; vec2i collisionOffset; vec2i collisionSize; std::string interactionScript; std::string walkthroughScript; std::string bumpPlayerScript; std::string enclosureZone; bool sliding = false; // Animation (internals) bool isAnimated = false; std::string spritesheet; Direction dir = Direction::down; std::string animationName = "still"; int animationId = 0; int animationFrame = 0; std::vector frames; std::vector animations; std::map> nameDirToAnim; bool animFinished = false; bool hasShadow = false; int bobAmount = 0; bool bobbingDown = false; int animSlowdownProgress = 0; // Animation (controls) bool normallyHasShadow = false; bool animPaused = false; bool bobbing = false; int animSlowdown = 1; // Animation will only advance every X frames (so, 1 means it's disabled) // Character bool orientable = false; int movementSpeed = 0; // 1 is slow (good for NPCs), 2 is Lucas's default walking speed std::vector followers; int leaderId = -1; std::deque trail; bool trailsAreHalved = false; CharacterState characterState = CharacterState::Still; CharacterMedium characterMedium = CharacterMedium::Normal; Direction movementDir = Direction::down; StepType stepType = StepType::none; int runningSfxChannel = -1; bool clipping = false; bool cantCrouch = false; // Use this to prevent running bool bobsWhenNormal = false; // If enabled, sets the animation bobbing flag whenever medium is Normal // Input bool controllable = false; bool player = false; // Behaviour BehaviourType behaviourType = BehaviourType::None; vec2i pathfindingDestination; bool cardinalDirectionsOnly = false; std::deque path; int followSpriteId = -1; // Mirror MirrorType mirrorType = MirrorType::None; int mirroredSpriteId = -1; int mirrorAxis = 0; }; #endif /* end of include guard: SPRITE_H_70503825 */