Skip to content

Commit

Permalink
updates startegies inheritance and folder orga, physicalEntity is the…
Browse files Browse the repository at this point in the history
… most advanced class
  • Loading branch information
ctmbl committed Dec 15, 2021
1 parent 01745ad commit bed08e2
Show file tree
Hide file tree
Showing 8 changed files with 177 additions and 101 deletions.
50 changes: 50 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"files.associations": {
"*.tcc": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"map": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp"
},
"C_Cpp.errorSquiggles": "Disabled"
}
34 changes: 0 additions & 34 deletions include/entity/controllable.h

This file was deleted.

30 changes: 0 additions & 30 deletions include/entity/drawable_handler.h

This file was deleted.

35 changes: 0 additions & 35 deletions include/entity/physical_entity.h

This file was deleted.

35 changes: 35 additions & 0 deletions include/entity/strategies/controllable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef CONTROLLABLE_H
#define CONTROLLABLE_H
#include "strategy.h"
#include <SFML/Window.hpp>



class Controllable : public virtual Strategy
{
private:

public:
Controllable(/* args */);
~Controllable();

void flush(bool[] inputs); //flush ? events ?, receive an array of boolean (flags) representing if some keys are pressed,
// WARNIGN needs a convention (between conductor.ControllableHandler and this class) on that boolean array

};

Controllable::Controllable(/* args */)
{
}

Controllable::~Controllable()
{
}







#endif
32 changes: 32 additions & 0 deletions include/entity/strategies/multi_drawable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef DRAWABLE_HANDLER
#define DRAWABLE_HANDLER
#include "strategy.h"
#include <vector>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderTarget.hpp>

class MultiDrawable : public sf::Drawable/*--> peut etre le mettre en attribut*/, public virtual Strategy {
private:
std::vector<sf::Drawable*> toDraw; //list of sprites/shapes to draw
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const; //i don't understand why const, comes form google "sfml drawable"
public:
DrawableHandler();
~DrawableHandler();
};

// in cpp:

virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
for(sf::Drawable* d : toDraw){
target.draw(*d,states);
}
}

DrawableHandler::DrawableHandler(/* args */){
}

DrawableHandler::~DrawableHandler(){
}


#endif
58 changes: 58 additions & 0 deletions include/entity/strategies/physical_entity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#ifndef PHYSICAL_ENTITY
#define PHYSICAL_ENTITY
#include "strategy.h"
#include <SFML/Graphics/Transformable.hpp>

class Hitbox{};

class PhysicalEntity : public sf::Transformable, public Strategy
{
/*Maybe the most important strategy
PhysicalEntity (or later simply "Physical" ? "Physicable" ?) has to describe physical caracteristics of his entity:
mass, touchable, (not invisible --> in Drawable), elasticity (wait ?), forceSensible (if he is or isn't sensible to some)..
Maybe we would like to store damage hitbox in here instead of Character,
or damageHitbox != physicalHitbox (like i can touch with my legs) but they can't take damages
*/
private:
//position, rotation etc in the parent class Transformable

Hitbox physicalHitbox; // boolean solid (or touchable ?) in here
unsigned double mass; //mass > 0
signed short gravityReaction; //-1 if the PhysicalEntity is likely to fly
unsigned double bouncyness; // [0,1] absorb every momentum (0) or none (1), maybe it will increase it's internal energy ( to satisfy conservation of energy)
double internalEnergy; //for characters that can absorb energy and then liberate it ?
double electricCharge; //mdr

public:

Hitbox getHitbox();
void setHitbox(Hitbox newHitbox);

//setPosition already handle in parent class Transformable: Google "sfml Transformable"

/*
the Physic toolbox will access position and then update position of every Entity
with this strategy, these functions aren't implemented here
only get and set positions are needed
*/

PhysicalEntity(/* args */);
~PhysicalEntity();
};

// in cpp :

PhysicalEntity::PhysicalEntity(/* args */)
{
//think to instantiate the parent Transformable attributes
}

PhysicalEntity::~PhysicalEntity()
{
}



#endif
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef SCHEDULABLE_H
#define SCHEDULABLE_H
#include "entity.h"
#include "strategy.h"
#include <queue>
#include <functional>
#include <map>

class Schedulable : public virtual Entity
class Schedulable : public virtual Strategy //schedulable is useless right now we'll think it later
{
private:

Expand Down

0 comments on commit bed08e2

Please sign in to comment.