Skip to content

Commit

Permalink
Added entities and updated Character class
Browse files Browse the repository at this point in the history
  • Loading branch information
benstyle11 authored and ctmbl committed Dec 15, 2021
1 parent dfed72a commit 2b0c3fc
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 33 deletions.
25 changes: 21 additions & 4 deletions include/entity/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,35 @@
#include "drawable_handler.h"
#include "physical_entity.h"
#include "schedulable.h"
#include <vector>

// dependencies
class Hitbox{ /* Stuff with hitboxes */ };


class Character : Controllable, DrawableHandler, PhysicalEntity, Schedulable
{
private:
/* data */
public:

virtual void sendEvent( sf::Event e );

std::vector<Hitbox> attackHitbox;
Hitbox damageHitbox;


public:

Character(/* args */);
~Character();

virtual void sendEvent( sf::Event e );


float maxLife;
float currentLife;
float strength;
float speed;
float jumpHeight;


};

Character::Character(/* args */)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#ifndef CONTROLLABLE_H
#define CONTROLLABLE_H
#include "entity.h"
#include <SFML/Window.hpp>


class Controllable

class Controllable : public virtual Entity
{
private:

Expand Down
4 changes: 2 additions & 2 deletions include/entity/drawable_handler.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef DRAWABLE_HANDLER
#define DRAWABLE_HANDLER

#include "entity.h"
#include <vector>
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderTarget.hpp>

class DrawableHandler : public sf::Drawable {
class DrawableHandler : public sf::Drawable, public virtual Entity {
private:
std::vector<sf::Drawable*> toDraw;
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
Expand Down
24 changes: 24 additions & 0 deletions include/entity/entity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef ENTITY_H
#define ENTITY_H

class Entity
{
private:

public:
Entity();
~Entity();
};

Entity::Entity()
{
}

Entity::~Entity()
{
}




#endif
20 changes: 9 additions & 11 deletions include/entity/physical_entity.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
#ifndef PHYSICAL_ENTITY
#define PHYSICAL_ENTITY
#include <SFML/System/Vector2.hpp>
#include "entity.h"
#include <SFML/Graphics/Transformable.hpp>

typedef struct
{
/* collider stuff ( e.g. linked list of vertex) */
} Collider;

class Hitbox{};

class PhysicalEntity
class PhysicalEntity : public sf::Transformable
{
private:

Collider bndBox;
Hitbox physicalHitbox;


public:

virtual void updatePhysics(); //here some kind of phx::PhysicsHandler;
void getCollider();
void setCollider(Collider newCollider);
Hitbox getHitbox();
void setHitbox(Hitbox newHitbox);

PhysicalEntity(/* args */);
~PhysicalEntity();
};
Expand Down
18 changes: 4 additions & 14 deletions include/entity/schedulable.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
#ifndef SCHEDULABLE.H
#define SCHEDULABLE.H
#include "entity.h"
#include <queue>
#include <functional>
#include <map>

class Schedulable
class Schedulable : public virtual Entity
{
private:

std::multimap<int, std::function<void ()> > actions; // actions to do at a given frame (contains a frame and a function to call)
// Maybe a Circular buffer would be better ?

public:



void update(int frame)
/*
{
if(actions.count(frame) > 0){
for(std::function<void()> currentAction : (actions.find(frame)) ){
}
}
} */; // call this one each frame
void update(int frame);

void addAction(int frame, std::function<void()> action);

Expand Down
2 changes: 1 addition & 1 deletion include/entity/wall.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Wall: DrawableHandler, PhysicalEntity
{
private:
/* data */

public:
Wall(/* args */);
~Wall();
Expand Down

0 comments on commit 2b0c3fc

Please sign in to comment.