yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
sprite_builder_test.cc
Go to the documentation of this file.
2
3#include <gmock/gmock.h>
4#include <gtest/gtest.h>
5
6namespace yaze {
7namespace test {
8namespace zelda3 {
9
10using namespace yaze::app::zelda3;
11
12class SpriteBuilderTest : public ::testing::Test {
13 protected:
14 void SetUp() override {
15 // Create a new sprite
17 .SetProperty("NbrTiles", 2)
18 .SetProperty("Health", 10)
19 .SetProperty("Harmless", false);
20 // Create an anonymous global action for the sprite to run before each
21 // action
24 // Create an action for the SprAction::LocalJumpTable
25 SpriteAction walkAction =
31 .AddCustomInstruction("JSL $0DBB7C"); // Custom ASM
32 // Link to the idle action. If the action does not exist, build will fail
33 walkAction.SetNextAction("IdleAction");
34
35 // Idle action which jumps to a fn. If the fn does not exist, build will
36 // fail
37 SpriteAction idleAction =
38 SpriteAction::Create("IdleAction")
40 idleAction.SetNextAction("Walk");
41
42 // Build the function that the idle action jumps to
43 SpriteAction idleFunction = SpriteAction::Create("IdleFn").AddInstruction(
45
46 // Add actions and functions to sprite
47 sprite.SetGlobalAction(globalAction);
48 sprite.AddAction(idleAction); // 0x00
49 sprite.AddAction(walkAction); // 0x01
50 sprite.AddFunction(idleFunction); // Local
51 }
52 void TearDown() override {}
53
55};
56
57TEST_F(SpriteBuilderTest, BuildSpritePropertiesOk) {
58 EXPECT_THAT(sprite.BuildProperties(), testing::HasSubstr(R"(!SPRID = $00
59!NbrTiles = $00
60!Harmless = $00
61)"));
62}
63
64} // namespace zelda3_test
65} // namespace test
66} // namespace yaze
SpriteAction & AddInstruction(const SpriteInstruction &instruction)
SpriteAction & SetNextAction(const std::string &nextActionName)
SpriteAction & AddCustomInstruction(const std::string &asmCode)
SpriteBuilder & AddFunction(const std::string &asmCode)
SpriteBuilder & SetGlobalAction(const SpriteAction &action)
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 BounceFromTileCollision()
static SpriteInstruction MoveXyz()
static SpriteInstruction ApplySpeedTowardsPlayer(int speed)
static SpriteInstruction JumpToFunction(const std::string &functionName)
static SpriteInstruction BehaveAsBarrier()
Zelda 3 specific classes and functions.
TEST_F(OverworldTest, OverworldLoadNoRomDataError)
Definition common.cc:21