merging from develpo

This commit is contained in:
arthur.jamet
2021-06-02 19:39:29 +02:00
81 changed files with 2048 additions and 499 deletions
@@ -0,0 +1,42 @@
//
// Created by Louis Auzuret on 2021-05-20.
//
#include "Component/Collision/CollisionComponent.hpp"
namespace BBM
{
CollisionComponent::CollisionComponent(WAL::Entity &entity)
: WAL::Component(entity)
{ }
WAL::Component *CollisionComponent::clone(WAL::Entity &entity) const
{
return new CollisionComponent(entity);
}
CollisionComponent::CollisionComponent(WAL::Entity &entity, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollide, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollided, Vector3f bound)
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound(bound)
{ }
CollisionComponent::CollisionComponent(WAL::Entity &entity, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollide, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollided, float boundSize)
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound({boundSize, boundSize, boundSize})
{ }
CollisionComponent::CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, Vector3f bound)
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound(bound)
{ }
CollisionComponent::CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, float boundSize)
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound({boundSize, boundSize, boundSize})
{ }
CollisionComponent::CollisionComponent(WAL::Entity &entity, Vector3f bound)
: WAL::Component(entity), onCollide(), onCollided(), bound(bound)
{ }
CollisionComponent::CollisionComponent(WAL::Entity &entity, float boundSize)
: WAL::Component(entity), onCollide(), onCollided(), bound({boundSize, boundSize, boundSize})
{ }
}
@@ -0,0 +1,57 @@
//
// Created by Louis Auzuret on 2021-05-20.
//
#pragma once
#include "Models/Callback.hpp"
#include "Models/Vector3.hpp"
#include "Component/Component.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
class CollisionComponent : public WAL::Component
{
private:
public:
//! @brief onCollide functions to be called
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide;
//! @brief onCollided functions to be called
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided;
//! @brief Bound size on all axis
Vector3f bound;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief A component can't be instantiated, it should be derived.
explicit CollisionComponent(WAL::Entity &entity);
//! @brief Constructor with a callback function
CollisionComponent(WAL::Entity &entity, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollide, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollided, Vector3f bound);
//! @brief Constructor with a callback function, same boundSize for all axis
CollisionComponent(WAL::Entity &entity, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollide, std::function<void (WAL::Entity &, const WAL::Entity &)> onCollided, float boundSize = 0);
//! @brief Constructor with a WAL::Callback
CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided,Vector3f bound);
//! @brief Constructor with a WAL::Callback, same boundSize for all axis
CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, float boundSize = 0);
//! @brief Constructor of collider with no callback
CollisionComponent(WAL::Entity &entity, Vector3f bound);
//! @brief Constructor no callback, same boundSize for all axis
CollisionComponent(WAL::Entity &entity, float boundSize);
//! @brief Default copy constructor
CollisionComponent(const CollisionComponent &) = default;
//! @brief default destructor
~CollisionComponent() override = default;
//! @brief A component can't be assigned
CollisionComponent &operator=(const CollisionComponent &) = delete;
};
}
@@ -0,0 +1,17 @@
//
// Created by Zoe Roux on 5/24/21.
//
#include "ControllableComponent.hpp"
namespace BBM
{
ControllableComponent::ControllableComponent(WAL::Entity &entity)
: WAL::Component(entity)
{}
WAL::Component *ControllableComponent::clone(WAL::Entity &entity) const
{
return new ControllableComponent(entity);
}
}
@@ -0,0 +1,38 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include <Models/Vector2.hpp>
#include "Component/Component.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
class ControllableComponent : public WAL::Component
{
public:
//! @brief The X and Z abscis of the movement.
Vector2f move;
//! @brief input value for jump
bool jump = false;
//! @brief input value for bomb
bool bomb = false;
//! @brief input value for pause
bool pause = false;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief Initialize a new controllable component.
explicit ControllableComponent(WAL::Entity &entity);
//! @brief A Controllable component is copy constructable.
ControllableComponent(const ControllableComponent &) = default;
//! @brief default destructor
~ControllableComponent() override = default;
//! @brief A Controllable component can't be assigned
ControllableComponent &operator=(const ControllableComponent &) = delete;
};
}
@@ -0,0 +1,34 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#include "GamepadComponent.hpp"
namespace BBM
{
GamepadComponent::GamepadComponent(WAL::Entity &entity)
: WAL::Component(entity), _ID(0)
{}
GamepadComponent::GamepadComponent(WAL::Entity &entity, int ID)
: WAL::Component(entity), _ID(ID)
{}
WAL::Component *GamepadComponent::clone(WAL::Entity &entity) const
{
return new GamepadComponent(entity, _ID);
}
GamepadComponent &GamepadComponent::setID(int ID)
{
this->_ID = ID;
return *this;
}
int GamepadComponent::getID() const
{
return this->_ID;
}
} // namespace BMM
@@ -0,0 +1,62 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include "Controllers/Gamepad.hpp"
#include "Component/Component.hpp"
#include "Entity/Entity.hpp"
using Button = RAY::Controller::GamePad::Button;
using Gamepad = RAY::Controller::GamePad;
namespace BBM
{
class GamepadComponent : public WAL::Component
{
private:
//! @brief Identifier of the gamepad, used to fetch events
int _ID;
public:
//! @brief jump key
Button keyJump = GAMEPAD_BUTTON_RIGHT_FACE_DOWN;
//! @brief bomb key
Button keyBomb = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT;
//! @brief pause key
Button keyPause = GAMEPAD_BUTTON_MIDDLE;
//! @brief move right key
Button keyRight = GAMEPAD_BUTTON_LEFT_FACE_RIGHT;
//! @brief move left key
Button keyLeft = GAMEPAD_BUTTON_LEFT_FACE_LEFT;
//! @brief move up key
Button keyUp = GAMEPAD_BUTTON_LEFT_FACE_UP;
//! @brief move down key
Button keyDown = GAMEPAD_BUTTON_LEFT_FACE_DOWN;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief Create a new gampad component using default keys.
explicit GamepadComponent(WAL::Entity &entity);
//! @brief Create a new PositionComponent at a certain position
GamepadComponent(WAL::Entity &entity, int id);
//! @brief A Gamepad component is copy constructable.
GamepadComponent(const GamepadComponent &) = default;
//! @brief default destructor
~GamepadComponent() override = default;
//! @brief A Gamepad component can't be assigned
GamepadComponent &operator=(const GamepadComponent &) = delete;
//! @brief Set the ID of the Gamepad the events must be fetch from;
GamepadComponent &setID(int ID);
//! @brief Get the ID of the Gamepad the events must be fetch from;
int getID() const;
};
}
@@ -0,0 +1,17 @@
//
// Created by Zoe Roux on 5/24/21.
//
#include "GridCenteredComponent.hpp"
namespace BBM
{
GridCenteredComponent::GridCenteredComponent(WAL::Entity &entity)
: WAL::Component(entity)
{}
WAL::Component *GridCenteredComponent::clone(WAL::Entity &entity) const
{
return new GridCenteredComponent(entity);
}
}
@@ -0,0 +1,33 @@
//
// Created by Zoe Roux on 5/24/21.
//
#pragma once
#include <Component/Component.hpp>
namespace BBM
{
//! @brief A component to slowly center entities to the middle of their current block.
//! This allow flexibility in their movement will preventing them from getting stuck at every corner.
class GridCenteredComponent : public WAL::Component
{
public:
//! @brief The force factor applied at each frame.
float force = 1;
//! @inherit
Component *clone(WAL::Entity &entity) const override;
//! @brief Create a new, default GridCenteredComponent.
//! @param entity The entity attached to this component.
explicit GridCenteredComponent(WAL::Entity &entity);
//! @brief A GridCenteredComponent is copy constructable
//! @param other The other GridCenteredComponent to copy.
GridCenteredComponent(const GridCenteredComponent &other) = default;
//! @brief A default destructor
~GridCenteredComponent() override = default;
//! @brief A GridCenteredComponent is not assignable
GridCenteredComponent &operator=(const GridCenteredComponent &) = delete;
};
}
@@ -0,0 +1,43 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
// Edited by Louis Auzuret on 2021-05-20.
//
#include "HealthComponent.hpp"
namespace BBM
{
HealthComponent::HealthComponent(WAL::Entity &entity)
: WAL::Component(entity),
_healthPoint()
{}
HealthComponent::HealthComponent(WAL::Entity &entity, unsigned int healthPoint)
: WAL::Component(entity),
_healthPoint(healthPoint)
{}
WAL::Component *HealthComponent::clone(WAL::Entity &entity) const
{
return new HealthComponent(entity);
}
void HealthComponent::addHealthPoint(unsigned int healthPoint)
{
this->_healthPoint += healthPoint;
}
void HealthComponent::takeDmg(unsigned int damage)
{
if (damage >= this->_healthPoint) {
this->_healthPoint = 0;
} else
this->_healthPoint -= damage;
}
unsigned int HealthComponent::getHealthPoint(void) const
{
return (this->_healthPoint);
}
}
@@ -0,0 +1,53 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
// Edited by Louis Auzuret on 2021-05-20.
//
#pragma once
#include <Models/Callback.hpp>
#include "Component/Component.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
class HealthComponent : public WAL::Component
{
private:
//! @brief life of an entity
unsigned int _healthPoint;
public:
//! @brief The callback invoked on this entity's death.
WAL::Callback<WAL::Entity &> onDeath;
//! @brief add health to the entity
void addHealthPoint(unsigned int healthPoint);
//! @brief reduce health
void takeDmg(unsigned int damage);
//! @brief return health point of the entity
unsigned int getHealthPoint(void) const;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief A Health component can't be instantiated, it should be derived.
explicit HealthComponent(WAL::Entity &entity);
//! @brief Constructor
HealthComponent(WAL::Entity &entity, unsigned int healthPoint);
//! @brief A Health component can't be instantiated, it should be derived.
HealthComponent(const HealthComponent &) = default;
//! @brief default destructor
~HealthComponent() override = default;
//! @brief A Health component can't be assigned
HealthComponent &operator=(const HealthComponent &) = delete;
};
}
@@ -0,0 +1,19 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#include "KeyboardComponent.hpp"
namespace BBM
{
KeyboardComponent::KeyboardComponent(WAL::Entity &entity)
: WAL::Component(entity)
{}
WAL::Component *KeyboardComponent::clone(WAL::Entity &entity) const
{
return new KeyboardComponent(entity);
}
} // namespace BMM
@@ -0,0 +1,49 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include <Controllers/Keyboard.hpp>
#include "Component/Component.hpp"
#include "Entity/Entity.hpp"
using Key = RAY::Controller::Keyboard::Key;
namespace BBM
{
class KeyboardComponent : public WAL::Component
{
public:
//! @brief jump key
Key keyJump = KEY_SPACE;
//! @brief bomb key
Key keyBomb = KEY_E;
//! @brief pause key
Key keyPause = KEY_ESCAPE;
//! @brief move right key
Key keyRight = KEY_A;
//! @brief move left key
Key keyLeft = KEY_D;
//! @brief move up key
Key keyUp = KEY_W;
//! @brief move down key
Key keyDown = KEY_S;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
//! @brief Create a new keyboard component using default keys.
explicit KeyboardComponent(WAL::Entity &entity);
//! @brief A Keyboard component is copy constructable.
KeyboardComponent(const KeyboardComponent &) = default;
//! @brief default destructor
~KeyboardComponent() override = default;
//! @brief A Keyboard component can't be assigned
KeyboardComponent &operator=(const KeyboardComponent &) = delete;
};
}
@@ -19,4 +19,15 @@ namespace BBM
{
this->_acceleration += force;
}
void MovableComponent::resetVelocity(void)
{
this->_velocity = {0, 0, 0};
}
const Vector3f &MovableComponent::getVelocity(void) const
{
return _velocity;
}
} // namespace WAL
@@ -18,10 +18,17 @@ namespace BBM
//! @brief The velocity of the entity.
Vector3f _velocity;
public:
//! @brief Add an instant force to this entity.
//! @param force The force to add to this entity's acceleration. The force is added instantly and in one go.
void addForce(Vector3f force);
//! @brief Set velocity to 0
void resetVelocity(void);
//! @brief Get velocity
const Vector3f &getVelocity(void) const;
//! @inherit
WAL::Component *clone(WAL::Entity &entity) const override;
@@ -6,8 +6,9 @@
namespace BBM
{
CameraComponent::CameraComponent(WAL::Entity &entity)
: Component(entity)
CameraComponent::CameraComponent(WAL::Entity &entity, Vector3f target)
: Component(entity),
target(target)
{}
WAL::Component *BBM::CameraComponent::clone(WAL::Entity &entity) const
@@ -5,6 +5,7 @@
#pragma once
#include <Component/Component.hpp>
#include <Models/Vector3.hpp>
namespace BBM
{
@@ -13,11 +14,14 @@ namespace BBM
class CameraComponent : public WAL::Component
{
public:
//! @brief The camera's target, the cam will look at this position.
Vector3f target;
//! @inherit
Component *clone(WAL::Entity &entity) const override;
//! @brief Ctor
explicit CameraComponent(WAL::Entity &);
explicit CameraComponent(WAL::Entity &, Vector3f target = Vector3f());
//! @brief A camera component is copy constructable.
CameraComponent(const CameraComponent &) = default;
//! @brief Default destructor.
@@ -6,7 +6,7 @@
#include <Models/TypeHolder.hpp>
#include "Component/Component.hpp"
#include "Drawables/ADrawable3D.hpp"
#include "Drawables/ADrawable2D.hpp"
#include "Model/Model.hpp"
namespace BBM
+238
View File
@@ -0,0 +1,238 @@
//
// Created by Tom Augier on 5/26/21.
// Edited by Benjamin Henry on 5/26/21.
//
#include "Map.hpp"
namespace RAY3D = RAY::Drawables::Drawables3D;
namespace BBM
{
void MapGenerator::generateUnbreakableBlock(int width, int height, std::shared_ptr<WAL::Scene> scene)
{
std::string unbreakableObj = "assets/wall/unbreakable_wall.obj";
std::string unbreakablePnj = "assets/wall/unbreakable_wall.png";
for (int i = 0; i < width + 1; i++) {
for (int j = 0; j < height + 1; j++) {
if (!(i % 2) && !(j % 2)) {
scene->addEntity("Unbreakable Wall")
.addComponent<PositionComponent>(Vector3f(i, 0, j))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj));
}
}
}
}
void MapGenerator::generateWall(int width, int height, std::shared_ptr<WAL::Scene> scene)
{
std::string unbreakableObj = "assets/wall/unbreakable_wall.obj";
std::string unbreakablePnj = "assets/wall/unbreakable_wall.png";
scene->addEntity("Bottom Wall")
.addComponent<PositionComponent>(Vector3f((width + 1) / 2, 0, -1))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1));
scene->addEntity("Upper Wall")
.addComponent<PositionComponent>(Vector3f((width + 1) / 2, 0, height + 1))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1));
scene->addEntity("Left Wall")
.addComponent<PositionComponent>(Vector3f(width + 1, 0, (height + 1) / 2))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 3));
scene->addEntity("Right Wall")
.addComponent<PositionComponent>(Vector3f(-1, 0, (height + 1) / 2))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 3));
}
void MapGenerator::generateFloor(int width, int height, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Floor")
.addComponent<PositionComponent>(Vector3f(width / 2, -1, height / 2))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png"), RAY::Vector3(width + 2, 0, height + 2));
}
void MapGenerator::createElement(Vector3f coords, std::shared_ptr<WAL::Scene> scene, BlockType blockType)
{
std::map<BlockType, MapElem> elements = {
{BREAKABLE, &createBreakable},
{UNBREAKABLE, &createUnbreakable},
{HOLE, &createHole},
{FLOOR, &createFloor},
/* {BUMPER, &createBumper},
{STAIRS, &createStairs} */
};
try {
auto element = elements.at(blockType);
element(coords, scene);
} catch (std::exception const &err) {
return;
}
}
void MapGenerator::createBreakable(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Breakable Block")
.addComponent<PositionComponent>(coords)
.addComponent<HealthComponent>(1)
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/breakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/breakable_wall.png"));
}
void MapGenerator::createFloor(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Floor")
.addComponent<PositionComponent>(Vector3f(coords))
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png"));
}
void MapGenerator::createUnbreakable(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Unbreakable Block")
.addComponent<PositionComponent>(coords)
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/unbreakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/unbreakable_wall.png"));
}
void MapGenerator::createHole(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Hole Block")
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z))
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/hole.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/hole.png"));
/* .addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
if (other.hasComponent<HealthComponent>()) {
auto &health = other.getComponent<HealthComponent>();
health.takeDmg(health.getHealthPoint());
}
}); */
}
void MapGenerator::createBumper(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Bumper Block")
.addComponent<PositionComponent>(Vector3f(coords.x, coords.y - 1, coords.z))
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/bumper_block.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/bumper_block.png"));
/* .addComponent<CollisionComponent>([](const WAL::Entity &entity, WAL::Entity &other) {
if (other.hasComponent<MovableComponent>()) {
auto &movable = other.getComponent<MovableComponent>();
movable.addForce(Vector3f(0, 5, 0));
}
} */
}
void MapGenerator::createStairs(Vector3f coords, std::shared_ptr<WAL::Scene> scene)
{
scene->addEntity("Stairs Block")
.addComponent<PositionComponent>(coords)
//.addComponent<CollisionComponent>(1)
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/wall/stairs_block.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/stairs_block.png"));
}
bool MapGenerator::isCloseToBlockType(std::map<std::tuple<int, int, int>, BlockType> map, int x, int y, int z, BlockType blockType)
{
return (map[std::make_tuple(x - 1, y, z)] == blockType ||
map[std::make_tuple(x + 1, y, z)] == blockType ||
map[std::make_tuple(x, y, z + 1)] == blockType ||
map[std::make_tuple(x, y, z - 1)] == blockType);
}
MapGenerator::BlockType MapGenerator::getRandomBlockType()
{
double rnd = static_cast<double>(std::rand())/RAND_MAX;
if (rnd > 0.95)
return HOLE;
if (rnd > 0.10)
return BREAKABLE;
return NOTHING;
}
MapGenerator::MapBlock MapGenerator::createHeight(MapBlock map, int width, int height)
{
double rnd = static_cast<double>(std::rand())/RAND_MAX;
if (rnd > 0.60) {
for (int i = 0; i < width; i++) {
map[std::make_tuple(i, 1, height)] = map[std::make_tuple(i, 0, height)];
map[std::make_tuple(i, 0, height)] = FLOOR;
}
for (int j = 0; j < height; j++) {
map[std::make_tuple(width, 1, j)] = map[std::make_tuple(width, 0, j)];
map[std::make_tuple(width, 0, j)] = FLOOR;
}
}
if (rnd > 0.30) {
for (int i = width - width/4; i < width + width/4 + 1; i++) {
for (int j = height - height/4; j < height + height/4 + 1; j++) {
map[std::make_tuple(i, 1, j)] = map[std::make_tuple(i, 0, j)];
map[std::make_tuple(i, 0, j)] = FLOOR;
}
}
}
return map;
}
MapGenerator::MapBlock MapGenerator::createSpawner(MapBlock map, int width, int height)
{
map[std::make_tuple(0, 0, 0)] = SPAWNER;
map[std::make_tuple(width, 0, 0)] = SPAWNER;
map[std::make_tuple(0, 0, height)] = SPAWNER;
map[std::make_tuple(width, 0, height)] = SPAWNER;
return map;
}
MapGenerator::MapBlock MapGenerator::createMap(int width, int height)
{
MapBlock map;
width = width % 2 ? width + 1 : width;
height = height % 2 ? height + 1 : height;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++)
map[std::make_tuple(i, 0, j)] = NOTHING;
}
map = createSpawner(map, width, height);
for (int i = 0; i < width + 1; i++) {
for (int j = 0; j < height + 1; j++) {
if (map[std::make_tuple(i, 0, j)] == SPAWNER)
continue;
if (isCloseToBlockType(map, i , 0, j, SPAWNER))
map[std::make_tuple(i, 0, j)] = NOTHING;
else
map[std::make_tuple(i, 0, j)] = getRandomBlockType();
if (map[std::make_tuple(i, 0, j)] == UNBREAKABLE && isCloseToBlockType(map, i, 0, j, UNBREAKABLE))
map[std::make_tuple(i, 0, j)] = BREAKABLE;
}
}
for (int i = 0; i < width + 1; i++) {
for (int j = 0; j < height + 1; j++) {
if (!((i + 1) % 2) && !((j + 1) % 2))
map[std::make_tuple(i, 0, j)] = UNBREAKABLE;
}
}
map = createHeight(map, width, height);
return (map);
}
void MapGenerator::loadMap(int width, int height, std::map<std::tuple<int, int, int>,
BlockType> map, std::shared_ptr<WAL::Scene> scene)
{
generateWall(width, height, scene);
generateFloor(width, height, scene);
for (int x = 0; x < width + 1; x++) {
for (int z = 0; z < height + 1; z++) {
for (int y = 0; y < 1 + 1; y++)
createElement(Vector3f(x, y, z), scene, map[std::make_tuple(x, y, z)]);
}
}
}
} // namespace BBM
+137
View File
@@ -0,0 +1,137 @@
//
// Created by Tom Augier on 5/26/21.
// Edited by Benjamin Henry on 5/26/21.
//
#pragma once
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <random>
#include <map>
#include <tuple>
#include <algorithm>
#include "Component/Renderer/Drawable3DComponent.hpp"
#include "System/Renderer/RenderSystem.hpp"
#include "Scene/Scene.hpp"
#include "Model/Model.hpp"
#include "Component/Component.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Health/HealthComponent.hpp"
#include "Component/Movable/MovableComponent.hpp"
namespace BBM
{
class MapGenerator
{
private:
//! @brief Enum of the block available.
enum BlockType {
NOTHING,
BREAKABLE,
HOLE,
FLOOR,
BUMPER,
STAIRS,
SPAWNER,
UNBREAKABLE
};
using MapElem = std::function<void (Vector3f coords, std::shared_ptr<WAL::Scene> scene)>;
using MapBlock = std::map<std::tuple<int, int, int>, BlockType>;
//! @brief Generate random block type
static BlockType getRandomBlockType();
//! @param map ASCII map
//! @param x x index on the block
//! @param z z index on the block
//! @param blockType blockType to compare with position
static bool isCloseToBlockType(std::map<std::tuple<int, int, int>, BlockType> map, int x, int y, int z, BlockType blockType);
//! @param width Width of the map
//! @param height Height of the map
//! @param scene Scene where the map is instanced
//! @brief Generate the unbreakable block of the map
static void generateUnbreakableBlock(int width, int height, std::shared_ptr<WAL::Scene> scene);
//! @param width Width of the map
//! @param height Height of the map
//! @param scene Scene where the map is instanced
//! @brief Generate the wall of the map
static void generateWall(int width, int height, std::shared_ptr<WAL::Scene> scene);
//! @param width Width of the map
//! @param height Height of the map
//! @param scene Scene where the map is instanced
//! @brief Generate the floor of the map
static void generateFloor(int width, int height, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create element of the map
static void createElement(Vector3f coords, std::shared_ptr<WAL::Scene> scene, BlockType blockType);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create breakable of the map
static void createBreakable(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create unbreakable of the map
static void createUnbreakable(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create hole of the map
static void createHole(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create bumper of the map
static void createBumper(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create bumper of the map
static void createFloor(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param coords coords of the element
//! @param scene Scene where the map is instanced
//! @brief Create stair of the map
static void createStairs(Vector3f coords, std::shared_ptr<WAL::Scene> scene);
//! @param map Map to load with block declared inside
//! @param width Width of the map
//! @param height Height of the map
//! @brief Generate map of block to be loaded
static MapBlock createSpawner(MapBlock map, int width, int height);
//! @param map Map to load with block declared inside
//! @param width Width of the map
//! @param height Height of the map
//! @brief Generate height for the map
static MapBlock createHeight(MapBlock map, int width, int height);
public:
//! @param width Width of the map
//! @param height Height of the map
//! @brief Generate map of block to be loaded
static MapBlock createMap(int width, int height);
//! @param width Width of the map
//! @param height Height of the map
//! @param map Map to load with block declared inside
//! @param scene Scene where the map is instanced
//! @brief Generate the map
static void loadMap(int width, int height, MapBlock map, std::shared_ptr<WAL::Scene> scene);
};
} // namespace BBM
+7
View File
@@ -129,6 +129,11 @@ namespace BBM
{
double mag = this->magnitude();
if (mag == 0) {
this->x = 0;
this->y = 0;
return *this;
}
this->x /= mag;
this->y /= mag;
return *this;
@@ -138,6 +143,8 @@ namespace BBM
{
T mag = this->magnitude();
if (mag == 0)
return Vector2<T>();
return Vector2<T>(this->x / mag, this->y / mag);
}
+24
View File
@@ -136,6 +136,12 @@ namespace BBM
{
double mag = this->magnitude();
if (mag == 0) {
this->x = 0;
this->y = 0;
this->z = 0;
return *this;
}
this->x /= mag;
this->y /= mag;
this->z /= mag;
@@ -146,6 +152,8 @@ namespace BBM
{
T mag = this->magnitude();
if (mag == 0)
return Vector3<T>();
return Vector3<T>(this->x / mag, this->y / mag, this->z / mag);
}
@@ -158,6 +166,22 @@ namespace BBM
{
return RAY::Vector3(this->x, this->y, this->z);
}
static Vector3<T> min(Vector3<T> a, Vector3<T> b)
{
Vector3<T> min = { std::min(a.x, b.x),
std::min(a.y, b.y),
std::min(a.z, b.z)};
return min;
}
static Vector3<T> max(Vector3<T> a, Vector3<T> b)
{
Vector3<T> max = { std::max(a.x, b.x),
std::max(a.y, b.y),
std::max(a.z, b.z)};
return max;
}
};
typedef Vector3<float> Vector3f;
+42 -11
View File
@@ -9,14 +9,23 @@
#include <Model/Model.hpp>
#include <Drawables/3D/Cube.hpp>
#include <Drawables/2D/Rectangle.hpp>
#include <Drawables/3D/Cube.hpp>
#include <TraceLog.hpp>
#include "Component/Position/PositionComponent.hpp"
#include <System/Keyboard/KeyboardSystem.hpp>
#include <System/Controllable/ControllableSystem.hpp>
#include <System/Collision/CollisionSystem.hpp>
#include <Component/Movable/MovableComponent.hpp>
#include <Component/Collision/CollisionComponent.hpp>
#include <Component/Controllable/ControllableComponent.hpp>
#include <Component/Keyboard/KeyboardComponent.hpp>
#include <System/Gamepad/GamepadSystem.hpp>
#include "Models/Vector2.hpp"
#include "Component/Renderer/CameraComponent.hpp"
#include "Component/Renderer/Drawable2DComponent.hpp"
#include "Component/Renderer/Drawable3DComponent.hpp"
#include "Runner.hpp"
#include "Models/GameState.hpp"
#include "Map/Map.hpp"
namespace RAY2D = RAY::Drawables::Drawables2D;
namespace RAY3D = RAY::Drawables::Drawables3D;
@@ -33,6 +42,15 @@ namespace BBM
engine.shouldClose = true;
}
void addSystems(WAL::Wal &wal)
{
wal.addSystem<KeyboardSystem>()
.addSystem<GamepadSystem>()
.addSystem<ControllableSystem>()
.addSystem<CollisionSystem>(wal)
.addSystem<MovableSystem>();
}
void enableRaylib(WAL::Wal &wal)
{
RAY::TraceLog::setLevel(LOG_WARNING);
@@ -43,25 +61,38 @@ namespace BBM
std::shared_ptr<WAL::Scene> loadGameScene()
{
auto scene = std::make_shared<WAL::Scene>();
scene->addEntity("cube")
.addComponent<PositionComponent>(10, 10, 0)
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(Vector2f(), Vector2f(10, 10), GREEN);
scene->addEntity("cube2")
.addComponent<PositionComponent>()
.addComponent<Drawable2DComponent, RAY2D::Rectangle>(Vector2f(), Vector2f(10, 10), RED);
scene->addEntity("player")
.addComponent<PositionComponent>()
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png"));
.addComponent<Drawable3DComponent, RAY3D::Model>("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png"))
.addComponent<ControllableComponent>()
.addComponent<KeyboardComponent>()
.addComponent<CollisionComponent>(2)
.addComponent<MovableComponent>();
scene->addEntity("cube")
.addComponent<PositionComponent>(-5, 0, -5)
.addComponent<Drawable3DComponent, RAY3D::Cube>(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED)
.addComponent<ControllableComponent>()
.addComponent<KeyboardComponent>()
.addComponent<CollisionComponent>([](WAL::Entity &, const WAL::Entity &){},
[](WAL::Entity &actual, const WAL::Entity &) {
try {
auto &mov = actual.getComponent<MovableComponent>();
mov.resetVelocity();
} catch (std::exception &e) { };
}, 3);
scene->addEntity("camera")
.addComponent<PositionComponent>(10, 10, 15)
.addComponent<CameraComponent>();
.addComponent<PositionComponent>(8, 20, 7)
.addComponent<CameraComponent>(Vector3f(8, 0, 8));
std::srand(std::time(NULL));
MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene);
return scene;
}
int run()
{
WAL::Wal wal;
wal.addSystem<MovableSystem>();
addSystems(wal);
enableRaylib(wal);
wal.scene = loadGameScene();
@@ -0,0 +1,52 @@
//
// Created by Louis Auzuret on 5/20/21
//
#include "Component/Movable/MovableComponent.hpp"
#include "Component/Position/PositionComponent.hpp"
#include "Component/Collision/CollisionComponent.hpp"
#include "System/Collision/CollisionSystem.hpp"
namespace BBM
{
CollisionSystem::CollisionSystem(WAL::Wal &wal)
: WAL::System({typeid(PositionComponent), typeid(CollisionComponent)}), _wal(wal)
{
}
bool CollisionSystem::collide(Vector3f minA, Vector3f maxA, Vector3f minB, Vector3f maxB)
{
bool overlapX = (minA.x <= maxB.x && maxA.x >= minB.x) || (minB.x <= maxA.x && maxB.x >= minA.x);
bool overlapY = (minA.y <= maxB.y && maxA.y >= minB.y) || (minB.y <= maxA.y && maxB.y >= minA.y);
bool overlapZ = (minA.z <= maxB.z && maxA.z >= minB.z) || (minB.z <= maxA.z && maxB.z >= minA.z);
return (overlapX && overlapY && overlapZ);
}
void CollisionSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &posA = entity.getComponent<PositionComponent>();
auto &col = entity.getComponent<CollisionComponent>();
Vector3f position = posA.position;
if (entity.hasComponent(typeid(MovableComponent)))
position += entity.getComponent<MovableComponent>().getVelocity();
Vector3f minA = Vector3f::min(position, position + col.bound);
Vector3f maxA = Vector3f::max(position, position + col.bound);
for (auto &other : _wal.scene->getEntities()) {
if (&other == &entity)
continue;
if (!other.hasComponent<CollisionComponent>() ||
!other.hasComponent<PositionComponent>())
continue;
auto colB = other.getComponent<CollisionComponent>();
auto posB = other.getComponent<PositionComponent>().position;
Vector3f minB = Vector3f::min(posB, posB + colB.bound);
Vector3f maxB = Vector3f::max(posB, posB + colB.bound);
if (collide(minA, maxA, minB, maxB)) {
col.onCollide(entity, other);
colB.onCollided(entity, other);
}
}
}
}
@@ -0,0 +1,37 @@
//
// Created by Louis Auzuret on 5/20/21
//
#pragma once
#include <algorithm>
#include "Wal.hpp"
#include "System/System.hpp"
#include "Models/Vector3.hpp"
namespace BBM
{
//! @brief A system to handle collisions.
class CollisionSystem : public WAL::System
{
private:
//! @brief reference to the ECS engine to get other entities
WAL::Wal &_wal;
public:
//! @inherit
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
CollisionSystem(WAL::Wal &wal);
//! @brief A Collision system is copy constructable
CollisionSystem(const CollisionSystem &) = default;
//! @brief A default destructor
~CollisionSystem() override = default;
//! @brief A Collision system is assignable.
CollisionSystem &operator=(const CollisionSystem &) = default;
//! @brief check AABB collision
static bool collide(Vector3f minA, Vector3f maxA, Vector3f minB, Vector3f maxB);
};
}
@@ -0,0 +1,30 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#include "ControllableSystem.hpp"
#include "Component/Movable/MovableComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
float ControllableSystem::speed = .25f;
ControllableSystem::ControllableSystem()
: WAL::System({
typeid(ControllableComponent),
typeid(MovableComponent)
})
{}
void ControllableSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &controllable = entity.getComponent<ControllableComponent>();
auto &movable = entity.getComponent<MovableComponent>();
Vector2f move = controllable.move.normalized() * ControllableSystem::speed;
movable.addForce(Vector3f(move.x, controllable.jump, move.y));
}
}
@@ -0,0 +1,31 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include "System/System.hpp"
namespace BBM
{
//! @brief A system to handle Controllable entities.
class ControllableSystem : public WAL::System
{
public:
//! @brief The speed applied to every controllable entities.
static float speed;
//! @inherit
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
ControllableSystem();
//! @brief A Controllable system is copy constructable
ControllableSystem(const ControllableSystem &) = default;
//! @brief A default destructor
~ControllableSystem() override = default;
//! @brief A Controllable system is assignable.
ControllableSystem &operator=(const ControllableSystem &) = default;
};
}
+43
View File
@@ -0,0 +1,43 @@
//
// Created by Arthur Jamet on 2021-05-31.
//
#include "GamepadSystem.hpp"
#include "Component/Gamepad/GamepadComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
#include "Controllers/Gamepad.hpp"
using Button = RAY::Controller::GamePad::Button;
using Gamepad = RAY::Controller::GamePad;
namespace BBM
{
GamepadSystem::GamepadSystem()
: WAL::System({
typeid(GamepadComponent),
typeid(ControllableComponent)
})
{}
void GamepadSystem::onFixedUpdate(WAL::Entity &entity)
{
const auto &gamepadComponent = entity.getComponent<GamepadComponent>();
auto &controllable = entity.getComponent<ControllableComponent>();
Gamepad gamepad(gamepadComponent.getID());
const std::map<Button, bool &> keyPressedMap = {
{gamepadComponent.keyJump, controllable.jump},
{gamepadComponent.keyBomb, controllable.bomb},
{gamepadComponent.keyPause, controllable.pause}
};
for (auto key : keyPressedMap)
key.second = gamepad.isPressed(key.first);
controllable.move = Vector2f();
controllable.move.x += gamepad.isPressed(gamepadComponent.keyRight);
controllable.move.x -= gamepad.isPressed(gamepadComponent.keyLeft);
controllable.move.y += gamepad.isPressed(gamepadComponent.keyUp);
controllable.move.y -= gamepad.isPressed(gamepadComponent.keyDown);
}
}
+28
View File
@@ -0,0 +1,28 @@
//
// Created by Arthur Jamet on 2021-05-31.
//
#pragma once
#include "System/System.hpp"
#include <map>
namespace BBM
{
//! @brief A system to handle Gamepad entities.
class GamepadSystem : public WAL::System
{
public:
//! @inherit
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
GamepadSystem();
//! @brief A Gamepad system is copy constructable
GamepadSystem(const GamepadSystem &) = default;
//! @brief A default destructor
~GamepadSystem() override = default;
//! @brief A Gamepad system is assignable.
GamepadSystem &operator=(const GamepadSystem &) = default;
};
}
@@ -0,0 +1,25 @@
//
// Created by Zoe Roux on 5/24/21.
//
#include "Component/Movable/MovableComponent.hpp"
#include "Component/GridCentered/GridCenteredComponent.hpp"
#include "GridCenteredSystem.hpp"
namespace BBM
{
GridCenteredSystem::GridCenteredSystem()
: WAL::System({
typeid(GridCenteredComponent),
typeid(MovableComponent),
// typeid(PositionComponent)
})
{}
void GridCenteredSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &grid = entity.getComponent<GridCenteredComponent>();
auto &movement = entity.getComponent<MovableComponent>();
// movement.addForce(grid.force * )
}
}
@@ -0,0 +1,26 @@
//
// Created by Zoe Roux on 5/24/21.
//
#pragma once
#include <System/System.hpp>
namespace BBM
{
//! @brief The system handling GridCenteredComponent
class GridCenteredSystem : public WAL::System
{
public:
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
GridCenteredSystem();
//! @brief A GridCenteredSystem is copyable.
GridCenteredSystem(const GridCenteredSystem &) = default;
//! @brief A default destructor
~GridCenteredSystem() override = default;
//! @brief A GridCenteredSystem is assignable
GridCenteredSystem &operator=(const GridCenteredSystem &) = default;
};
}
+26
View File
@@ -0,0 +1,26 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#include "HealthSystem.hpp"
#include "Component/Health/HealthComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
namespace BBM
{
HealthSystem::HealthSystem()
: WAL::System({
typeid(HealthComponent)
})
{}
void HealthSystem::onFixedUpdate(WAL::Entity &entity)
{
auto &health = entity.getComponent<HealthComponent>();
if (health.getHealthPoint() == 0)
health.onDeath(entity);
}
}
+28
View File
@@ -0,0 +1,28 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include "System/System.hpp"
namespace BBM
{
//! @brief A system to handle Health entities.
class HealthSystem : public WAL::System
{
public:
//! @inherit
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
HealthSystem();
//! @brief A Health system is copy constructable
HealthSystem(const HealthSystem &) = default;
//! @brief A default destructor
~HealthSystem() override = default;
//! @brief A Health system is assignable.
HealthSystem &operator=(const HealthSystem &) = default;
};
}
@@ -0,0 +1,47 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#include <iostream>
#include "KeyboardSystem.hpp"
#include "Component/Keyboard/KeyboardComponent.hpp"
#include "Component/Controllable/ControllableComponent.hpp"
#include "Entity/Entity.hpp"
#include "Controllers/Keyboard.hpp"
using Keyboard = RAY::Controller::Keyboard;
namespace BBM
{
KeyboardSystem::KeyboardSystem()
: WAL::System({
typeid(KeyboardComponent),
typeid(ControllableComponent)
})
{}
void KeyboardSystem::onFixedUpdate(WAL::Entity &entity)
{
const auto &keyboard = entity.getComponent<KeyboardComponent>();
auto &controllable = entity.getComponent<ControllableComponent>();
const std::map<KeyboardKey, bool &> keyPressedMap = {
{keyboard.keyJump, controllable.jump},
{keyboard.keyBomb, controllable.bomb},
{keyboard.keyPause, controllable.pause}
};
for (auto key : keyPressedMap)
key.second = Keyboard::isDown(key.first);
controllable.move = Vector2f();
if (Keyboard::isDown(keyboard.keyRight))
controllable.move.x += 1;
if (Keyboard::isDown(keyboard.keyLeft))
controllable.move.x -= 1;
if (Keyboard::isDown(keyboard.keyUp))
controllable.move.y += 1;
if (Keyboard::isDown(keyboard.keyDown))
controllable.move.y -= 1;
}
}
@@ -0,0 +1,29 @@
//
// Created by Tom Augier on 2021-05-20.
// Edited by Benjamin Henry on 2021-05-20.
//
#pragma once
#include "System/System.hpp"
#include <map>
namespace BBM
{
//! @brief A system to handle keyboard entities.
class KeyboardSystem : public WAL::System
{
public:
//! @inherit
void onFixedUpdate(WAL::Entity &entity) override;
//! @brief A default constructor
KeyboardSystem();
//! @brief A keyboard system is copy constructable
KeyboardSystem(const KeyboardSystem &) = default;
//! @brief A default destructor
~KeyboardSystem() override = default;
//! @brief A keyboard system is assignable.
KeyboardSystem &operator=(const KeyboardSystem &) = default;
};
}
+2 -3
View File
@@ -5,7 +5,6 @@
#include "Component/Position/PositionComponent.hpp"
#include "MovableSystem.hpp"
#include "Component/Movable/MovableComponent.hpp"
#include "Wal.hpp"
namespace BBM
{
@@ -21,8 +20,8 @@ namespace BBM
auto &movable = entity.getComponent<MovableComponent>();
auto &position = entity.getComponent<PositionComponent>();
position.position += movable._velocity * WAL::Wal::timestep.count();
movable._velocity = movable._acceleration * WAL::Wal::timestep.count();
position.position += movable._velocity;
movable._velocity = movable._acceleration;
movable._acceleration = Vector3f();
}
} // namespace WAL
+1
View File
@@ -23,5 +23,6 @@ int main(int argc, char **argv)
usage(argv[0]);
return 1;
}
//return demo();
return BBM::run();
}