yaze 0.2.2
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 {
8
9using namespace yaze::zelda3;
10
11class SpriteBuilderTest : public ::testing::Test {
12 protected:
13 void SetUp() override {
14 // Create a new sprite
16 .SetProperty("NbrTiles", 2)
17 .SetProperty("Health", 10)
18 .SetProperty("Harmless", false);
19 // Create an anonymous global action for the sprite to run before each
20 // action
23 // Create an action for the SprAction::LocalJumpTable
24 SpriteAction walkAction =
30 .AddCustomInstruction("JSL $0DBB7C"); // Custom ASM
31 // Link to the idle action. If the action does not exist, build will fail
32 walkAction.SetNextAction("IdleAction");
33
34 // Idle action which jumps to a fn. If the fn does not exist, build will
35 // fail
36 SpriteAction idleAction =
37 SpriteAction::Create("IdleAction")
39 idleAction.SetNextAction("Walk");
40
41 // Build the function that the idle action jumps to
42 SpriteAction idleFunction = SpriteAction::Create("IdleFn").AddInstruction(
44
45 // Add actions and functions to sprite
46 sprite.SetGlobalAction(globalAction);
47 sprite.AddAction(idleAction); // 0x00
48 sprite.AddAction(walkAction); // 0x01
49 sprite.AddFunction(idleFunction); // Local
50 }
51 void TearDown() override {}
52
54};
55
56TEST_F(SpriteBuilderTest, BuildSpritePropertiesOk) {
57 EXPECT_THAT(sprite.BuildProperties(), testing::HasSubstr(R"(!SPRID = $00
58!NbrTiles = $00
59!Harmless = $00
60)"));
61}
62
63} // namespace test
64} // namespace yaze
SpriteAction & AddInstruction(const SpriteInstruction &instruction)
static SpriteAction Create()
SpriteAction & AddCustomInstruction(const std::string &asmCode)
SpriteAction & SetNextAction(const std::string &nextActionName)
static SpriteBuilder Create(const std::string &spriteName)
SpriteBuilder & SetProperty(const std::string &propertyName, const std::string &value)
static SpriteInstruction JumpToFunction(const std::string &functionName)
static SpriteInstruction BehaveAsBarrier()
static SpriteInstruction BounceFromTileCollision()
static SpriteInstruction ApplySpeedTowardsPlayer(int speed)
static SpriteInstruction PlayAnimation(int startFrame, int endFrame, int speed)
static SpriteInstruction MoveXyz()
TEST_F(CpuTest, AsmParserTokenizerOk)
Definition cpu_test.cc:44
Main namespace for the application.
Definition controller.cc:18