Moved 'renderable' stuff to 'entities'
This commit is contained in:
@@ -24,12 +24,12 @@
|
|||||||
|
|
||||||
//components
|
//components
|
||||||
#include "character_defines.hpp"
|
#include "character_defines.hpp"
|
||||||
#include "renderable.hpp"
|
#include "entity.hpp"
|
||||||
|
|
||||||
//std namespace
|
//std namespace
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class BaseCharacter : public Renderable {
|
class BaseCharacter : public Entity {
|
||||||
public:
|
public:
|
||||||
BaseCharacter() = default;
|
BaseCharacter() = default;
|
||||||
virtual ~BaseCharacter() = default;
|
virtual ~BaseCharacter() = default;
|
||||||
@@ -22,9 +22,9 @@
|
|||||||
#ifndef BASEMONSTER_HPP_
|
#ifndef BASEMONSTER_HPP_
|
||||||
#define BASEMONSTER_HPP_
|
#define BASEMONSTER_HPP_
|
||||||
|
|
||||||
#include "renderable.hpp"
|
#include "entity.hpp"
|
||||||
|
|
||||||
class BaseMonster {
|
class BaseMonster : public Entity {
|
||||||
public:
|
public:
|
||||||
BaseMonster() = default;
|
BaseMonster() = default;
|
||||||
virtual ~BaseMonster() = default;
|
virtual ~BaseMonster() = default;
|
||||||
@@ -19,13 +19,44 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#include "renderable.hpp"
|
#include "entity.hpp"
|
||||||
|
|
||||||
void Renderable::Update() {
|
void Entity::Update() {
|
||||||
origin += motion;
|
origin += motion;
|
||||||
sprite.Update(0.016);
|
sprite.Update(0.016);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderable::DrawTo(SDL_Surface* const dest, int camX, int camY) {
|
void Entity::DrawTo(SDL_Surface* const dest, int camX, int camY) {
|
||||||
sprite.DrawTo(dest, origin.x - camX, origin.y - camY);
|
sprite.DrawTo(dest, origin.x - camX, origin.y - camY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Entity::SetEntityIndex(int i) {
|
||||||
|
return entityIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Entity::SetRoomIndex(int i) {
|
||||||
|
return roomIndex = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 Entity::SetOrigin(Vector2 v) {
|
||||||
|
return origin = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 Entity::SetMotion(Vector2 v) {
|
||||||
|
return motion = v;
|
||||||
|
}
|
||||||
|
int Entity::GetEntityIndex() {
|
||||||
|
return entityIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Entity::GetRoomIndex() {
|
||||||
|
return roomIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 Entity::GetOrigin() {
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 Entity::GetMotion() {
|
||||||
|
return motion;
|
||||||
|
}
|
||||||
@@ -19,37 +19,43 @@
|
|||||||
* 3. This notice may not be removed or altered from any source
|
* 3. This notice may not be removed or altered from any source
|
||||||
* distribution.
|
* distribution.
|
||||||
*/
|
*/
|
||||||
#ifndef RENDERABLE_HPP_
|
#ifndef ENTITY_HPP_
|
||||||
#define RENDERABLE_HPP_
|
#define ENTITY_HPP_
|
||||||
|
|
||||||
#include "bounding_box.hpp"
|
#include "bounding_box.hpp"
|
||||||
#include "sprite_sheet.hpp"
|
#include "sprite_sheet.hpp"
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
|
||||||
class Renderable {
|
//The base class for all objects in the world
|
||||||
|
class Entity {
|
||||||
public:
|
public:
|
||||||
Renderable() = default;
|
|
||||||
virtual ~Renderable() = default;
|
|
||||||
|
|
||||||
virtual void Update();
|
virtual void Update();
|
||||||
virtual void DrawTo(SDL_Surface* const, int camX, int camY);
|
virtual void DrawTo(SDL_Surface* const, int camX, int camY);
|
||||||
|
|
||||||
SpriteSheet* GetSprite() { return &sprite; }
|
SpriteSheet* GetSprite() { return &sprite; }
|
||||||
|
|
||||||
//position
|
//accessors & mutators
|
||||||
Vector2 SetOrigin(Vector2 v) { return origin = v; }
|
int SetEntityIndex(int i);
|
||||||
Vector2 GetOrigin() const { return origin; }
|
int SetRoomIndex(int i);
|
||||||
Vector2 SetMotion(Vector2 v) { return motion = v; }
|
Vector2 SetOrigin(Vector2 v);
|
||||||
Vector2 GetMotion() const { return motion; }
|
Vector2 SetMotion(Vector2 v);
|
||||||
|
|
||||||
//collision
|
|
||||||
BoundingBox SetBounds(BoundingBox b) { return bounds = b; }
|
BoundingBox SetBounds(BoundingBox b) { return bounds = b; }
|
||||||
|
|
||||||
|
int GetEntityIndex();
|
||||||
|
int GetRoomIndex();
|
||||||
|
Vector2 GetOrigin();
|
||||||
|
Vector2 GetMotion();
|
||||||
BoundingBox GetBounds() { return bounds; }
|
BoundingBox GetBounds() { return bounds; }
|
||||||
|
|
||||||
protected: //TODO: should be private
|
protected:
|
||||||
|
Entity() = default;
|
||||||
|
~Entity() = default;
|
||||||
|
|
||||||
SpriteSheet sprite;
|
SpriteSheet sprite;
|
||||||
Vector2 origin = {0, 0};
|
int entityIndex = -1;
|
||||||
Vector2 motion = {0, 0};
|
int roomIndex = -1;
|
||||||
|
Vector2 origin;
|
||||||
|
Vector2 motion;
|
||||||
BoundingBox bounds;
|
BoundingBox bounds;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2014
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#include "local_character.hpp"
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2014
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
#ifndef LOCALCHARACTER_HPP_
|
|
||||||
#define LOCALCHARACTER_HPP_
|
|
||||||
|
|
||||||
#include "base_character.hpp"
|
|
||||||
#include "statistics.hpp"
|
|
||||||
|
|
||||||
class LocalCharacter : public BaseCharacter {
|
|
||||||
public:
|
|
||||||
LocalCharacter() = default;
|
|
||||||
~LocalCharacter() = default;
|
|
||||||
|
|
||||||
int SetRoomIndex(int i) { return roomIndex = i; }
|
|
||||||
int GetRoomIndex() { return roomIndex; }
|
|
||||||
|
|
||||||
Statistics* GetBaseStats() { return &baseStats; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int roomIndex = -1;
|
|
||||||
Statistics baseStats;
|
|
||||||
//TODO: weapons, armour, buffs, debuffs, etc.
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user