...
 
Commits (2)
......@@ -21,7 +21,7 @@
3. Apply change
- [ ] HUD
- [x] Basic HUD done : we gots HPS
- [ ] Add items to the HUD
- [x] Add items to the HUD
### Gameplay
......@@ -32,4 +32,7 @@
- [ ] Move speed
- [ ] Different kinds of weapons
* Limit to 2 weapons
- [ ] Heals and consomable
- [x] Heals and consomable
* Ennemy :
- [x] Towers
- [ ] Rusher
#pragma once
class World;
#include <set>
#include <functional>
#include <SFML/Graphics.hpp>
......@@ -12,7 +14,7 @@ public :
typedef std::pair<SceneNode*, SceneNode*> Pair;
public :
SceneNode();
SceneNode(World* world = nullptr);
~SceneNode();
void attachChild(Ptr child);
Ptr detachChild(const SceneNode& node);
......@@ -42,10 +44,10 @@ public :
void checkSceneCollision(SceneNode& root, std::set<Pair>& target);
virtual void onCollideWith(SceneNode& collider);
World* getContext() const {return mWorld;}
private :
std::vector<Ptr> mChildren;
SceneNode* mParent;
SceneNode* mParent; World* mWorld;
bool isMarkedForRemoval, isMarkForReset;
};
......@@ -13,18 +13,6 @@ public :
private :
sf::Vector2f mBase;
};
class HomingSpeedPatern : public SpeedPatern {
public :
HomingSpeedPatern(sf::Vector2f base, SceneNode* target, float max_speed, float max_acc);
virtual void step(sf::Time dt);
void specifySource(SceneNode* source){mSource = source;}
private :
SceneNode* mTarget, *mSource;
float mSpeed, mAcc;
};
......
#include "../headers/ennemy.hpp"
Ennemy::Ennemy(TextureHolder const& textures) : Alive(Agent::Tower,textures,12,Entity::Ennemy),
Ennemy::Ennemy(TextureHolder const& textures) : Alive(Agent::Tower,textures,5,Entity::Ennemy),
mIsQ(true), mIsW(true){
mQCD = sf::seconds(4.f);
mQCD = sf::seconds(8.f);
markForReset();
}
......@@ -24,8 +24,6 @@ void Ennemy::q_spell(float sense){
for(int i = 0 ; i < 3 ; ++i){
Orbital* orb = new Orbital(Agent::tProjectile, getTexHolder(),
new HellSpeedPatern(positionSetter,sense*94.f,1.005f),Entity::Ennemy);
/*Orbital* orb = new Orbital(Agent::tProjectile, getTexHolder(),
new HomingSpeedPatern(positionSetter, mTGT, 100.f, 5.f),Entity::Ennemy);*/
orb->setPosition(positionSetter);
attachChild(orb);
positionSetter = transform.transformPoint(positionSetter);
......@@ -34,7 +32,6 @@ void Ennemy::q_spell(float sense){
void Ennemy::updateCurrent(sf::Time dt){
// Q-SPELL
Alive::updateCurrent(dt);
setVelocity(0.f,0.f);
}
......
......@@ -16,7 +16,7 @@ void Orbital::updateCurrent(sf::Time dt){
void Orbital::onCollideWith(SceneNode& node){
switch(node.identify()){
case Category::Player: case Category::Ennemy :
case Category::Player: case Category::Ennemy : case Category::Orbital :
stageForRemoval();
break;
}
......
#include "../headers/sceneNode.hpp"
#include <iostream>
SceneNode::SceneNode () : mParent(nullptr), isMarkedForRemoval(false), isMarkForReset(false){}
SceneNode::SceneNode (World* world) : mParent(nullptr), isMarkedForRemoval(false), isMarkForReset(false)
, mWorld(world){}
SceneNode::~SceneNode(){
for(auto& child : mChildren) delete child;
......
#include "../headers/speedPatern.hpp"
#include <cmath>
SpeedPatern::SpeedPatern(sf::Vector2f base) : mBase(base){}
SpeedPatern::SpeedPatern(sf::Vector2f base) : mBase(base){
}
void SpeedPatern::step(sf::Time dt){}
......@@ -10,20 +11,6 @@ sf::Vector2f SpeedPatern::getVelocity() const{
}
HomingSpeedPatern::HomingSpeedPatern(sf::Vector2f base, SceneNode* target, float mspeed, float macc)
: SpeedPatern(base), mSpeed(mspeed) , mAcc(macc) , mTarget(target){}
void HomingSpeedPatern::step(sf::Time dt){
sf::Vector2f dir = mTarget->getWorldPosition() - mSource->getWorldPosition();
if(dir.x == 0 && dir.y == 0) scale(0.f,0.f);
else{
float mag = sqrt(dir.x*dir.x + dir.y*dir.y);
dir /= mag * dt.asSeconds() * mAcc;
translate(dir);
}
}
RotationSpeedPatern::RotationSpeedPatern(sf::Vector2f base, float rpm)
: SpeedPatern(base), mRPM(rpm){
rotate(90.f);
......@@ -32,6 +19,7 @@ RotationSpeedPatern::RotationSpeedPatern(sf::Vector2f base, float rpm)
void RotationSpeedPatern::step(sf::Time dt){
rotate(mRPM*dt.asSeconds());
SpeedPatern::step(dt);
}
......@@ -39,7 +27,7 @@ HellSpeedPatern::HellSpeedPatern(sf::Vector2f base, float rpm, float scl)
: RotationSpeedPatern(base,rpm), mSCL(scl){}
void HellSpeedPatern::step(sf::Time dt){
RotationSpeedPatern::step(dt);
scale(mSCL,mSCL);
RotationSpeedPatern::step(dt);
}