Skip to content

Commit 128ad28

Browse files
committed
basic enemy wall behavior
1 parent ae3c8ad commit 128ad28

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

bin/settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"audio" : {
3-
"music-volume" : 100,
4-
"sound-volume" : 100,
5-
"volume" : 100
3+
"music-volume" : 0,
4+
"sound-volume" : 0,
5+
"volume" : 0
66
},
77
"video" : {
88
"resolution" : "1920x1080",

src/Character.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Character :: Character(
2525
for(auto&& e: *cfg)
2626
{
2727
auto wpn = e.as<shared_ptr<Meta>>();
28-
LOG("1");
2928
m_Weapons.emplace_back(
3029
e.key,
3130
wpn->at<string>("ammo-type"),

src/MenuState.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,21 @@ void MenuState :: init_controls_menu()
332332
// TODO: add empty binds for buttons not found
333333

334334
for(auto&& bind: m_Binds)
335+
{
336+
string action = bind.first;
337+
vector<string> keys = bind.second;
338+
auto text = make_shared<string>(
339+
boost::to_upper_copy(action) + ": " +
340+
boost::algorithm::join(keys, ", ")
341+
);
335342
m_ControlsMenu.options().emplace_back(
336-
boost::to_upper_copy(bind.first) + ": " +
337-
boost::algorithm::join(bind.second, ", "),
338-
[this]{
339-
m_pMenuGUI->hide();
343+
text,
344+
[this, action, text]{
345+
*text = action + ": ...";
346+
m_pMenuGUI->visible(false);
340347
}
341-
);
348+
);
349+
}
342350
}
343351

344352
m_ControlsMenu.options().emplace_back(

src/Thing.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void Thing :: init_thing()
9292
// adding a sprite will spawn its center on 0,0...
9393
// so we offset
9494
move(glm::vec3(
95-
0.5f * m_pSprite->size().x,
96-
0.5f * m_pSprite->size().y,
95+
m_pSprite->origin().x * m_pSprite->size().x,
96+
m_pSprite->origin().y * m_pSprite->size().y,
9797
0.0f
9898
));
9999
//m_pPlaceholder->detach(); // don't want to invalidate iterator
@@ -308,7 +308,25 @@ void Thing :: cb_to_static(Node* thing_node, Node* static_node)
308308
auto thing = find_thing(thing_node);
309309
assert(thing);
310310
if(thing->solid() || thing->is_monster())
311+
{
312+
glm::vec3 pos_before = thing->position(Space::WORLD);
311313
thing->world()->cb_to_static(thing_node, static_node, thing.get());
314+
glm::vec3 pos_after = thing->position(Space::WORLD);
315+
if(thing->velocity() != glm::vec3(0.0f)){
316+
glm::vec3 vel = thing->velocity();
317+
if(pos_after.x != pos_before.x){
318+
vel.x = -vel.x;
319+
thing->velocity(vel);
320+
thing->orient(vel);
321+
}
322+
if(pos_after.y != pos_before.y){
323+
vel.y = -vel.y;
324+
thing->velocity(vel);
325+
thing->orient(vel);
326+
}
327+
328+
}
329+
}
312330
}
313331

314332
std::shared_ptr<Thing> Thing :: find_thing(Node* n)

0 commit comments

Comments
 (0)