aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-05-03 08:49:01 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-05-03 08:49:01 -0400
commitafb0ada00a2c50ea541ba6dc93058ccdb0286cdd (patch)
tree36b070d21fd237419a9f0a3bafb11add8fd68aa7 /src
parentf102149e15ca1ac36cbb4e2627e5ce44f2d5273a (diff)
ortho snapping, reset option
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp13
-rw-r--r--src/mob.cpp10
-rw-r--r--src/ui_action.cpp8
-rw-r--r--src/world.cpp23
4 files changed, 24 insertions, 30 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 58c1651..216d9ef 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -64,15 +64,8 @@ void randGetomName(Entity *e)
names.close();
- switch(bufs[0]) {
- default :
- case 'm':
- e->gender = MALE;
- break;
- case 'f':
- e->gender = FEMALE;
- break;
- }
+ // gender is a binary construct
+ e->gender = (bufs[0] == 'm') ? MALE : FEMALE;
strcpy(e->name, bufs + 1);
@@ -343,7 +336,7 @@ void Entity::draw(void)
glColor3ub(255, 105, 180);
} else if (type == MOBT) {
if (Mobp(this)->rider != nullptr) {
- Mobp(this)->rider->loc.x = loc.x + width / 2;
+ Mobp(this)->rider->loc.x = loc.x + width * 0.25f;
Mobp(this)->rider->loc.y = loc.y + height - game::HLINE;
Mobp(this)->rider->vel.y = .12;
}
diff --git a/src/mob.cpp b/src/mob.cpp
index 1829240..6ce46ab 100644
--- a/src/mob.cpp
+++ b/src/mob.cpp
@@ -310,6 +310,8 @@ Mob::~Mob()
}
extern World *currentWorld;
+extern Arena *arena;
+
void Mob::wander(void)
{
static bool YAYA = false;
@@ -320,16 +322,12 @@ void Mob::wander(void)
if (aggressive && !YAYA && isInside(vec2 {player->loc.x + width / 2, player->loc.y + height / 4})) {
if (!ui::dialogBoxExists) {
std::thread([&](void){
- auto *a = new Arena(currentWorld, player, this);
- a->setStyle("");
- a->setBackground(WorldBGType::Forest);
- a->setBGM("assets/music/embark.wav");
-
+ arena->fight(currentWorld, player, this);
ui::toggleWhiteFast();
YAYA = true;
ui::waitForCover();
YAYA = false;
- currentWorld = a;
+ currentWorld = arena;
ui::toggleWhiteFast();
}).detach();
}
diff --git a/src/ui_action.cpp b/src/ui_action.cpp
index 960b222..ebdc705 100644
--- a/src/ui_action.cpp
+++ b/src/ui_action.cpp
@@ -5,6 +5,7 @@
#define ACTION_EPILOUGE { actioning = false; actionHover = 0; }
extern World *currentWorld;
+extern Arena *arena;
extern Player *player;
extern bool inBattle;
@@ -115,14 +116,11 @@ void actionAttack(void)
if (m->type == MOBT) {
if (!inBattle && m != nullptr) {
- Arena *a = new Arena(currentWorld, player, Mobp(m));
- a->setStyle("");
- a->setBackground(WorldBGType::Forest);
- a->setBGM("assets/music/embark.wav");
+ arena->fight(currentWorld, player, Mobp(m));
ui::toggleWhiteFast();
ui::waitForCover();
- currentWorld = a;
+ currentWorld = arena;
ui::toggleWhiteFast();
}
} else {
diff --git a/src/world.cpp b/src/world.cpp
index 223a8bc..80fc322 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1488,26 +1488,31 @@ draw(Player *p)
p->draw();
}
-Arena::Arena(World *leave, Player *p, Mob *m)
+Arena::Arena(void)
{
generate(800);
addMob(new Door(), vec2 {100, 100});
+}
+
+Arena::~Arena(void)
+{
+ mmob->die();
+ deleteEntities();
+}
- inBattle = true;
+void Arena::fight(World *leave, const Player *p, Mob *m)
+{
+ inBattle = true;
- mob.push_back((mmob = m));
+ mob.push_back((mmob = m));
entity.push_back(mmob);
mmob->aggressive = false;
arenaNest.emplace_back(leave, p->loc);
}
-Arena::~Arena(void) {
- mmob->die();
- deleteEntities();
-}
-
-WorldSwitchInfo Arena::exitArena(Player *p) {
+WorldSwitchInfo Arena::exitArena(Player *p)
+{
if (!mmob->isAlive() &&
p->loc.x + p->width / 2 > mob[0]->loc.x &&
p->loc.x + p->width / 2 < mob[0]->loc.x + HLINES(12)) {