aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/gameplay.cpp19
-rw-r--r--src/gameplay.hpp3
-rw-r--r--src/main.cpp4
-rw-r--r--src/weapon.cpp7
-rw-r--r--src/weapon.hpp4
5 files changed, 25 insertions, 12 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 15f96bd..b424229 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -8,14 +8,24 @@
#include "gameplay.hpp"
-#include <iostream>
-
#include "raymath.h"
+#include <fstream>
-Game::Game(void)
+Game::Game(std::string const & path)
{
- nEnemies = 10;
+ std::ifstream ifs(path);
+ std::string tok;
+ std::cout << "Init: reading map file [" << path << "]" << std::endl;
+ while (ifs >> tok)
+ {
+ if (tok == "E")
+ {
+ ifs >> tok;
+ std::cout << "will spawn " << tok << " enemies" << std::endl;
+ nEnemies = std::atoi(tok.c_str());
+ }
+ }
enemies = new std::vector<Entity>(nEnemies);
player = new Entity;
player->posX = SCREENWIDTH / 2;
@@ -107,6 +117,7 @@ int Game::getKeys() const
std::cout << "hit enemy at " << en->posX << "|" << en->posY
<< std::endl;
enemies->erase(en);
+ return (0);
}
}
DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 20, RED);
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 06ed0a7..7097995 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -13,6 +13,7 @@
#include "entity.hpp"
#include <vector>
+#include <iostream>
class Game {
int nEnemies;
@@ -22,7 +23,7 @@ class Game {
Entity * player;
public:
- Game();
+ Game(std::string const & path);
~Game();
void start() const ;
diff --git a/src/main.cpp b/src/main.cpp
index b4525c2..74b1adf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -13,7 +13,7 @@
gameState gs = TITLE;
-Game* game = new Game;
+Game* game = new Game("../meta/maps/stage_1_start.bfm");
int main(void) {
initWindow();
@@ -41,7 +41,7 @@ int main(void) {
{
gs = TITLE;
delete game;
- game = new Game;
+ game = new Game("../meta/maps/stage_1_start.bfm");
}
break ;
}
diff --git a/src/weapon.cpp b/src/weapon.cpp
index 74bf960..c876481 100644
--- a/src/weapon.cpp
+++ b/src/weapon.cpp
@@ -8,9 +8,8 @@
#include "weapon.hpp"
-Weapon::Weapon()
-{
-
-}
+Weapon::Weapon(float const & rg, unsigned int const & dmg) :
+ range(rg), damage(dmg)
+{}
Weapon::~Weapon() {}
diff --git a/src/weapon.hpp b/src/weapon.hpp
index 72d719f..9a3f875 100644
--- a/src/weapon.hpp
+++ b/src/weapon.hpp
@@ -11,7 +11,9 @@
class Weapon {
public:
- Weapon();
+ float const & range;
+ unsigned int const & damage;
+ Weapon(float const & rg, unsigned int const & dmg);
~Weapon();
};