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