From f50406d69f9b64da72a05a88409bf4cef93a71d5 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Mon, 1 Dec 2014 22:59:26 +1100 Subject: [PATCH] Code tweak --- client/entities/base_character.cpp | 32 ++++++++++++++++++++++++++++++ client/entities/base_character.hpp | 14 ++++++------- client/entities/base_monster.hpp | 2 +- client/entities/entity.cpp | 17 ++++++++++++++++ client/entities/entity.hpp | 8 ++++---- 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/client/entities/base_character.cpp b/client/entities/base_character.cpp index ad31e92..8acdc72 100644 --- a/client/entities/base_character.cpp +++ b/client/entities/base_character.cpp @@ -21,6 +21,10 @@ */ #include "base_character.hpp" +//------------------------- +//graphics +//------------------------- + void BaseCharacter::CorrectSprite() { //NOTE: These must correspond to the sprite sheet in use if (motion.y > 0) { @@ -45,3 +49,31 @@ void BaseCharacter::CorrectSprite() { sprite.SetXIndex(0); } } + +//------------------------- +//metadata +//------------------------- + +int BaseCharacter::SetOwner(int i) { + return owner = i; +} + +int BaseCharacter::GetOwner() { + return owner; +} + +std::string BaseCharacter::SetHandle(std::string s) { + return handle = s; +} + +std::string BaseCharacter::GetHandle() const { + return handle; +} + +std::string BaseCharacter::SetAvatar(std::string s) { + return avatar = s; +} + +std::string BaseCharacter::GetAvatar() const { + return avatar; +} \ No newline at end of file diff --git a/client/entities/base_character.hpp b/client/entities/base_character.hpp index 8c44ce3..c3d1b1e 100644 --- a/client/entities/base_character.hpp +++ b/client/entities/base_character.hpp @@ -29,7 +29,7 @@ //std namespace #include -class BaseCharacter : public Entity { +class BaseCharacter: public Entity { public: BaseCharacter() = default; virtual ~BaseCharacter() = default; @@ -38,12 +38,12 @@ public: void CorrectSprite(); //metadata - int SetOwner(int i) { return owner = i; } - int GetOwner() { return owner; } - std::string SetHandle(std::string s) { return handle = s; } - std::string GetHandle() const { return handle; } - std::string SetAvatar(std::string s) { return avatar = s; } - std::string GetAvatar() const { return avatar; } + int SetOwner(int i); + int GetOwner(); + std::string SetHandle(std::string s); + std::string GetHandle() const; + std::string SetAvatar(std::string s); + std::string GetAvatar() const; private: //metadata diff --git a/client/entities/base_monster.hpp b/client/entities/base_monster.hpp index ddcc876..d7d1b6b 100644 --- a/client/entities/base_monster.hpp +++ b/client/entities/base_monster.hpp @@ -24,7 +24,7 @@ #include "entity.hpp" -class BaseMonster : public Entity { +class BaseMonster: public Entity { public: BaseMonster() = default; virtual ~BaseMonster() = default; diff --git a/client/entities/entity.cpp b/client/entities/entity.cpp index 5509604..04ba38a 100644 --- a/client/entities/entity.cpp +++ b/client/entities/entity.cpp @@ -30,6 +30,14 @@ void Entity::DrawTo(SDL_Surface* const dest, int camX, int camY) { sprite.DrawTo(dest, origin.x - camX, origin.y - camY); } +SpriteSheet* Entity::GetSprite() { + return &sprite; +} + +//------------------------- +//accessors & mutators +//------------------------- + int Entity::SetEntityIndex(int i) { return entityIndex = i; } @@ -45,6 +53,11 @@ Vector2 Entity::SetOrigin(Vector2 v) { Vector2 Entity::SetMotion(Vector2 v) { return motion = v; } + +BoundingBox Entity::SetBounds(BoundingBox b) { + return bounds = b; +} + int Entity::GetEntityIndex() { return entityIndex; } @@ -59,4 +72,8 @@ Vector2 Entity::GetOrigin() { Vector2 Entity::GetMotion() { return motion; +} + +BoundingBox Entity::GetBounds() { + return bounds; } \ No newline at end of file diff --git a/client/entities/entity.hpp b/client/entities/entity.hpp index a73d3eb..694490d 100644 --- a/client/entities/entity.hpp +++ b/client/entities/entity.hpp @@ -32,24 +32,24 @@ public: virtual void Update(); virtual void DrawTo(SDL_Surface* const, int camX, int camY); - SpriteSheet* GetSprite() { return &sprite; } + SpriteSheet* GetSprite(); //accessors & mutators int SetEntityIndex(int i); int SetRoomIndex(int i); Vector2 SetOrigin(Vector2 v); Vector2 SetMotion(Vector2 v); - BoundingBox SetBounds(BoundingBox b) { return bounds = b; } + BoundingBox SetBounds(BoundingBox b); int GetEntityIndex(); int GetRoomIndex(); Vector2 GetOrigin(); Vector2 GetMotion(); - BoundingBox GetBounds() { return bounds; } + BoundingBox GetBounds(); protected: Entity() = default; - ~Entity() = default; + virtual ~Entity() = default; SpriteSheet sprite; int entityIndex = -1;