yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sprite_builder.h
Go to the documentation of this file.
1#ifndef YAZE_APP_ZELDA3_SPRITE_SPRITE_BUILDER_H_
2#define YAZE_APP_ZELDA3_SPRITE_SPRITE_BUILDER_H_
3
4#include <array>
5#include <string>
6#include <vector>
7
8namespace yaze {
9namespace app {
10namespace zelda3 {
11
13 public:
14 // Predefined instructions
15 static SpriteInstruction PlayAnimation(int startFrame, int endFrame,
16 int speed);
21 static SpriteInstruction SetTimer(int timerId, int value);
23 static SpriteInstruction JumpToFunction(const std::string& functionName);
24
25 // Custom instruction
26 static SpriteInstruction Custom(const std::string& asmCode);
27
28 // Get the instruction configuration
29 std::string GetConfiguration() const { return instruction_; }
30 void SetConfiguration(const std::string& instruction) {
31 instruction_ = instruction;
32 }
33
34 private:
35 std::string instruction_;
36};
37
39 public:
40 // Factory method to create a new action
41 static SpriteAction Create(const std::string& actionName);
42
43 // Anonymously create an action
44 static SpriteAction Create();
45
46 // Add a predefined instruction to the action
48
49 // Add custom raw ASM instruction to the action
50 SpriteAction& AddCustomInstruction(const std::string& asmCode);
51
52 // Set the next action to jump to
53 SpriteAction& SetNextAction(const std::string& nextActionName);
54
55 // Get the action configuration
56 std::string GetConfiguration() const;
57
58 private:
59 std::string name;
60 std::vector<std::string> instructions;
61 std::string nextAction;
62};
63
64// Array of sprite property names
65constexpr const char* kSpriteProperties[] = {"!SPRID",
66 "!NbrTiles",
67 "!Harmless",
68 "!HVelocity",
69 "!Health",
70 "!Damage",
71 "!DeathAnimation",
72 "!ImperviousAll",
73 "!SmallShadow",
74 "!Shadow",
75 "!Palette",
76 "!Hitbox",
77 "!Persist",
78 "!Statis",
79 "!CollisionLayer",
80 "!CanFall",
81 "!DeflectArrow",
82 "!WaterSprite",
83 "!Blockable",
84 "!Prize",
85 "!Sound",
86 "!Interaction",
87 "!Statue",
88 "!DeflectProjectiles",
89 "!ImperviousArrow",
90 "!ImpervSwordHammer",
91 "!Boss"};
92
94 public:
95 // Factory method to create a new sprite
96 static SpriteBuilder Create(const std::string& spriteName);
97
98 // Set sprite properties
99 SpriteBuilder& SetProperty(const std::string& propertyName,
100 const std::string& value);
101 SpriteBuilder& SetProperty(const std::string& propertyName, int value);
102 SpriteBuilder& SetProperty(const std::string& propertyName, bool value);
103
104 // Add an action to the sprite
105 SpriteBuilder& AddAction(const SpriteAction& action);
106
107 // Set global action to the sprite (always runs)
109
110 // Add a function to be called from anywhere in the sprite code
111 SpriteBuilder& AddFunction(const std::string& asmCode);
112 SpriteBuilder& AddFunction(const SpriteAction& action);
113
114 std::string BuildProperties() const;
115
116 // Build and get the sprite configuration
117 std::string Build() const;
118
119 private:
120 std::string name;
121 std::array<std::string, 27> properties;
122 std::vector<SpriteAction> actions;
124 std::vector<SpriteAction> functions;
125};
126
127} // namespace zelda3
128} // namespace app
129} // namespace yaze
130
131#endif // YAZE_APP_ZELDA3_SPRITE_SPRITE_BUILDER_H_
SpriteAction & AddInstruction(const SpriteInstruction &instruction)
SpriteAction & SetNextAction(const std::string &nextActionName)
std::string GetConfiguration() const
std::vector< std::string > instructions
SpriteAction & AddCustomInstruction(const std::string &asmCode)
SpriteBuilder & AddFunction(const std::string &asmCode)
std::string BuildProperties() const
std::vector< SpriteAction > actions
std::vector< SpriteAction > functions
SpriteBuilder & SetGlobalAction(const SpriteAction &action)
std::array< std::string, 27 > properties
static SpriteBuilder Create(const std::string &spriteName)
SpriteBuilder & AddAction(const SpriteAction &action)
SpriteBuilder & SetProperty(const std::string &propertyName, const std::string &value)
static SpriteInstruction PlayAnimation(int startFrame, int endFrame, int speed)
static SpriteInstruction CheckDamageFromPlayer()
static SpriteInstruction BounceFromTileCollision()
static SpriteInstruction Custom(const std::string &asmCode)
static SpriteInstruction MoveXyz()
static SpriteInstruction SetTimer(int timerId, int value)
void SetConfiguration(const std::string &instruction)
static SpriteInstruction ApplySpeedTowardsPlayer(int speed)
static SpriteInstruction JumpToFunction(const std::string &functionName)
static SpriteInstruction BehaveAsBarrier()
constexpr const char * kSpriteProperties[]
Definition common.cc:21