Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (23)
Showing
with 253 additions and 38 deletions
......@@ -15,6 +15,10 @@ bin/
# Libraries
libs/
# Doctest generated files
*.gcna
*.gcdo
# Build directory
build/
......
# This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/C++.gitlab-ci.yml
# use the official gcc image, based on debian
# can use versions as well, like gcc:5.2
# see https://hub.docker.com/_/gcc/
image: gcc
build:
stage: build
# instead of calling g++ directly you can also use some build toolkit like make
# install the necessary build tools when needed
before_script:
- mkdir bin
- mkdir saves
- mkdir logs
script:
- make console
artifacts:
paths:
- bin/
# depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
# cache:
# paths:
# - "*.o"
cache:
paths:
- "build/*.o"
# run tests using the binary built before
test:
stage: test
script:
- echo "Dummy Testing"
- make test
#ifndef __ASSET_H__
#define __ASSET_H__
#include <string>
#include "logger.h"
class Asset
......@@ -8,6 +10,8 @@ class Asset
public:
Asset();
~Asset();
void loadMedia( std::string path );
private:
Logger& _logger;
};
......
#ifndef __COMPONENT__COLLISION_H__
#define __COMPONENT__COLLISION_H__
#include "components/components-generic.h"
#include "maths/maths.h"
class cCollision : public CComponentGeneric
{
public:
double radius = 0.0;
cCollision(){}
cCollision( float rad )
: radius( rad ) {}
};
#endif // __COMPONENT__COLLISION_H__
\ No newline at end of file
#ifndef __COMPONENT__INPUT_H__
#define __COMPONENT__INPUT_H__
#include "components/components-generic.h"
#include "maths/maths.h"
class cInput : public CComponentGeneric
{
public:
bool up = false;
bool down = false;
bool left = false;
bool right = false;
bool shoot = false;
};
#endif // __COMPONENT__INPUT_H__
#ifndef __COMPONENT__LIFESPAN_H__
#define __COMPONENT__LIFESPAN_H__
#include "components/components-generic.h"
class cLifespan : public CComponentGeneric
{
public:
uint16_t total;
uint16_t remaining;
};
#endif // __COMPONENT__LIFESPAN_H__
#ifndef __COMPONENT__POINT_BAR_H__
#define __COMPONENT__POINT_BAR_H__
#include "components/components-generic.h"
#include "maths/maths.h"
class cPointBar : public CComponentGeneric
{
public:
cPointBar( uint16_t value )
: _total(value), _current(value) {}
private:
uint16_t _total;
uint16_t _current;
};
#endif // __COMPONENT__POINT_BAR_H__
#ifndef __COMPONENT__SCORE_H__
#define __COMPONENT__SCORE_H__
#include "components/components-generic.h"
class cScore : public CComponentGeneric
{
public:
uint16_t score;
};
#endif // __COMPONENT__SCORE_H__
#ifndef __COMPONENT__SHAPE_H__
#define __COMPONENT__SHAPE_H__
#include "components/components-generic.h"
#include "maths/maths.h"
class cShape : public CComponentGeneric
{
public:
cShape( uint8_t verticies )
: _verticies( verticies ) {}
private:
uint8_t _verticies;
};
#endif // __COMPONENT__SHAPE_H__
#ifndef __COMPONENT__TRANSFORM_H__
#define __COMPONENT__TRANSFORM_H__
#include "components/components-generic.h"
#include "maths/maths.h"
class cTransform : public CComponentGeneric
{
public:
Vec2 position = { 0.0, 0.0 };
Vec2 velocity = { 0.0, 0.0 };
Vec2 scale = { 0.0, 0.0 };
double angle = 0.0;
cTransform(){}
cTransform( const Vec2 &pos, const Vec2 &vel, float ang )
: position(pos), velocity(vel), angle(ang) {}
};
#endif // __COMPONENT__TRANSFORM_H__
......@@ -3,11 +3,11 @@
#include <SDL.h>
#include "entities/entity-generic.h"
#include "entities/entity.h"
#include "maths/maths.h"
#include "components/cTexture.h"
class eButton : public EntityGeneric
class eButton : public Entity
{
public:
void setPosition( Vec2 pos );
......
......@@ -4,30 +4,37 @@
// #include "entity-manager.h"
#include "logger.h"
#include "components/cTransform.h"
#include "components/cScore.h"
#include "components/cShape.h"
#include "components/cCollision.h"
class EntityGeneric
class Entity
{
// friend class EntityManager;
friend class EntityManager;
public:
EntityGeneric( const std::string& tag, size_t id ); /** @todo make this private */
~EntityGeneric();
~Entity();
bool isAlive() { return this->_alive; }
bool isDead() { return ! this->_alive; }
void kill() { this->_alive = false; }
bool isActive() { return this->_active; }
bool isDestroyed() { return ! this->_active; }
void destroy() { this->_active = false; }
const size_t id() const { return this->_id; }
// Component Variables
const std::string& tag() { return this->_tag; }
private:
Entity( const std::string& tag, size_t id ); /** @todo make this private */
Logger& _logger;
cScore _score;
cTransform _transform;
cShape _shape = {0};
cCollision _collision;
bool _active = true;
const size_t _id = 0;
const std::string _tag = "Default";
bool _alive = true;
};
typedef EntityGeneric Entity;
#endif // __ENTITIES__ENTITY_GENERIC_H
......@@ -7,10 +7,9 @@
#include <map>
#include "logger.h"
#include "entities/entity-generic.h"
#include "entities/entity.h"
typedef EntityGeneric Entity;
typedef std::vector<std::shared_ptr<EntityGeneric>> EntityVector;
typedef std::vector<std::shared_ptr<Entity>> EntityVector;
typedef std::map< std::string, EntityVector > EntityMap;
class EntityManager
......@@ -18,7 +17,7 @@ class EntityManager
public:
EntityManager();
~EntityManager();
std::shared_ptr<EntityGeneric> addEntity( const std::string& tag );
std::shared_ptr<Entity> addEntity( const std::string& tag );
void removeEntity();
void update();
......
#ifndef __GAME_H__
#define __GAME_H__
#include <memory>
#include <map>
#include <string>
#include <vector>
......@@ -15,10 +16,15 @@
#include "logger.h"
#include "entity-manager.h"
#include "game-state.h"
#include "scene.h"
#include "window.h"
#include "asset.h"
#include "save-manager.h"
// #include "window.h"
#endif
class Window;
class GameEngine
{
......@@ -31,29 +37,38 @@ class GameEngine
void close();
void clean();
Scene* currentScene();
// void changeScene( Scene scene );
// std::vector< Asset& > getAssets();
// Window& getWindow();
void changeScene( std::string label, Scene *scene );
void changeScene( std::string label );
std::vector< Asset& > getAssets();
Window& getWindow();
std::vector<Asset> getAssets();
void sUserInput();
bool isRunning;
void handleInput();
private:
SaveManager _saveManager;
GameState _state = Uninitialised;
size_t _frame = 0;
std::time_t _frametime = 0;
EntityManager _entityManager;
Logger& _logger;
std::string _currScene;
bool _paused = false;
Window* _window;
// std::vector<Asset> _assets;
// std::map< std::string, Scene > _scenes;
std::vector<Asset> _assets; /** @todo : move this to scene */
std::string _currScene;
std::map< std::string, Scene* > _scenes;
/* Systems */
// sUserInput
// void sMovement();
// void sUserInput();
// void sRender();
// void sCollision();
};
#endif // __GAME_H__
#ifndef __GAME_STATE__H__
#define __GAME_STATE__H__
enum GameState
{
Uninitialised,
......@@ -6,3 +8,5 @@ enum GameState
Active,
Exit
};
#endif // __GAME_STATE__H__
\ No newline at end of file
#ifndef UTILS_LOGGER_H
#ifndef UTILS_LOGGER_H
#define UTILS_LOGGER_H
#include <string>
......@@ -13,7 +13,7 @@
enum LogLevel
{
DEBUG, INFO, WARNING, ERROR, FATAL
DEBUG, INFO, WARNING, ERR, FATAL
};
class Logger
......
......@@ -6,21 +6,29 @@
#define SDL_MAIN_HANDLED
#ifdef __TEST_RUNNER__
#ifndef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
#include "testlist.hpp"
#endif // __TEST_RUNNER__
enum GenerationMethod
{
Random,
Cave
};
#include "maths/maths.h"
#include "save-manager.h"
#include "game-state.h"
#include "world-hex-2d.h"
#include "world-map-3d.h"
#include "chunk.h"
#include "config-parser.h"
#include "game-engine.h"
#include "logger.h"
#include "entities/entity-generic.h"
#include "entities/entity.h"
#include "maths/maths.h"
#include "entity-manager.h"
#include "components/cTexture.h"
......
......@@ -3,6 +3,7 @@
#include <cmath>
class Vec2
{
public:
......@@ -11,15 +12,23 @@ class Vec2
Vec2( float xIn, float yIn );
bool operator == ( const Vec2 rhs ) const;
bool operator != ( const Vec2 rhs ) const;
Vec2 operator + ( const Vec2 rhs ) const;
Vec2 operator * ( const Vec2 rhs ) const;
Vec2 operator - ( const Vec2 rhs ) const;
Vec2 operator * ( const Vec2 rhs ) const;
Vec2 operator * ( const float scale ) const;
Vec2 operator / ( const Vec2 rhs ) const;
Vec2 operator / ( const float scale ) const;
void operator += ( const Vec2 & rhs );
void operator -= ( const Vec2 & rhs );
void operator *= ( const Vec2 & rhs );
void operator *= ( const float rhs );
void operator /= ( const Vec2 & rhs );
void operator /= ( const float rhs );
float dist( const Vec2 &rhs ) const;
float length();
void normalise();
};
......
......@@ -7,19 +7,20 @@
#include "logger.h"
#include "asset.h"
#include "entities/entity-generic.h"
#include "entities/entity.h"
#include "entity-manager.h"
class Scene{
public:
Scene();
Scene();// : _logger( Logger::instance() ) {}
~Scene();
virtual void update() = 0;
virtual void simulate() = 0;
virtual void doAction() = 0;
virtual void render() = 0;
virtual void registerAction() = 0;
private:
protected:
std::vector<Asset> _assets;
Logger& _logger;
......
#ifndef __SCENES__PLAY_H__
#define __SCENES__PLAY_H__
#include "scene.h"
#include "entities/entity.h"
class ScenePlay : public Scene
{
public:
void update();
void simulate();
void doAction();
void render();
void registerAction();
private:
std::string _levelPath;
Entity* _player;
// Systems
// sAnimation();
};
#endif // __SCENES__PLAY_H__