Skip to content

Commit

Permalink
Feature PFD to update kinematics of a physical ETT
Browse files Browse the repository at this point in the history
Add Strengh enum

Rename Strength to Force. Add README for PFD.

Clean unused dep and typedef moved to lib/lib.h
  • Loading branch information
aTxr committed Jan 19, 2022
1 parent 4f4ce2e commit fa55c83
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project(

file(GLOB_RECURSE SRC_FILES src/*.cpp)
add_executable(app ${SRC_FILES})
target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/conductor)
target_include_directories(app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
find_package(SFML 2 REQUIRED network audio graphics window system)
target_include_directories(app PUBLIC ${SFML_INCLUDE_DIR})
target_link_libraries(app sfml-graphics)
10 changes: 5 additions & 5 deletions include/conductor/Conductor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#define DEF_CONDUCTOR

#include <SFML/Graphics.hpp>
#include "ControllerHandler.h"
#include "ScheduleHandler.h"
#include "PhysicsHandler.h"
#include "DrawHandler.h"
#include "AudioHandler.h"
#include "conductor/ControllerHandler.h"
#include "conductor/ScheduleHandler.h"
#include "conductor/PhysicsHandler.h"
#include "conductor/DrawHandler.h"
#include "conductor/AudioHandler.h"

class Conductor {
public:
Expand Down
4 changes: 2 additions & 2 deletions include/entity/strategies/strategy.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef STRATEGY_H
#define STRATEGY_H

virtual class Strategy
class Strategy
//For now Strategy seems only a polymorphic-class, usefull only to store every strategies.
//we'll have to think how we want to use strategies, because if they're all stored as Strategy
//we can't write strategies.get(0).aMethodFromPhysicalEntity() because strategies.get(0) is of type Strategy,
Expand All @@ -25,4 +25,4 @@ Strategy::~Strategy()
}


#endif
#endif
30 changes: 4 additions & 26 deletions include/phx/phx.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
#ifndef PHX_PHX_H
#define PHX_PHX_H

#include <tuple>
#include "lib/lib.h"
#include <vector>
#include <iostream>
#include "entity/strategies/physical_entity.h"

// Constrain
// vitessePersoMax < longeurPersoMin

// dependencies
class Scene;
class Entity;

typedef std::pair<unsigned int, unsigned int> Vec;
typedef std::pair<int, int> Vel;

/**
* Update each Entity in the Scene
*/
void update(Scene);

void updateCinematics(Entity&);
void updateCollision(Scene);

class Cinematics {
private:
Vec m_pos;
Vel m_vel;
};
Vel updateCinematics(PhysicalEntity const);

class Hitbox {
private:
std::vector<Vec> m_vertices;
};

class PhysicalParameters {
private:
std::vector<int> m_parameters;
};

#endif
2 changes: 1 addition & 1 deletion src/main.cpp → src/main.cppp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using namespace std;

#include <SFML/Graphics.hpp>

#include "Conductor.h"
#include "conductor/Conductor.h"


int main(){
Expand Down
7 changes: 7 additions & 0 deletions src/phx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#PHX

- Use unsigned int from 0 to MAX_INT to calculate the physics
- Positions are unsigned int pairs, Vectors are signed int pairs. These types are declared in lib.
- updateCinematics act like the pfd. Do not take into account collisions.
Param: PhysicalEntity
Output: correction velocity to apply
22 changes: 22 additions & 0 deletions src/phx/phx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "phx/phx.h"
#include <vector>

Vel updateCinematics(PhysicalEntity const ett) {
Vel correction (0,0);
Vel ett.getVelocity();
std::vector<Force> forces = ett.getForce();

for (auto force: forces) {
switch(force) {
case weight:
correction.second += -10;
break;

default:
break;
}
}

return correction;
}

0 comments on commit fa55c83

Please sign in to comment.