-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
40 lines (40 loc) · 1.27 KB
/
main.cpp
File metadata and controls
40 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "LD32.hpp"
#include <Engine/Factory.hpp>
#include "Slayer.hpp"
#include "WeaponSelector.hpp"
#include "Projectile.hpp"
#include "Damagable.hpp"
#include "Bat.hpp"
#include "Level.hpp"
#include "Vampire.hpp"
#include <Engine/Node.hpp>
int main() {
engine::Factory::RegisterType("slayer", engine::Factory::CreateChildNode<Slayer>);
engine::Factory::RegisterType("selector", [](Json::Value& root, engine::Node* parent){
engine::Node* n = engine::Factory::CreateChildNode<WeaponSelector>(root, parent);
if (n) {
LD32* g = static_cast<LD32*>(n->GetScene()->GetGame());
auto u = [&](WeaponType wt){
auto s = static_cast<engine::SpriteNode*>(n->GetChildByID(weapons[wt].name));
if (s) {
if (g->IsUnlocked(wt)) {
s->PlayAnimation("default");
} else {
s->PlayAnimation("disabled");
}
}
};
u(WT_CROSSBOW);
u(WT_LAUNCHER);
u(WT_SUNCANNON);
static_cast<engine::SpriteNode*>(n->GetChildByID("none"))->PlayAnimation("active");
}
return n;
});
engine::Factory::RegisterType("projectile", engine::Factory::CreateChildNode<Projectile>);
engine::Factory::RegisterType("bat", engine::Factory::CreateChildNode<Bat>);
engine::Factory::RegisterType("vampire", engine::Factory::CreateChildNode<Vampire>);
LD32 game;
game.run();
return 0;
}