Code tweak

This commit is contained in:
Kayne Ruse
2014-12-01 22:59:26 +11:00
parent cc167180f6
commit f50406d69f
5 changed files with 61 additions and 12 deletions
+32
View File
@@ -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;
}
+7 -7
View File
@@ -29,7 +29,7 @@
//std namespace
#include <string>
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
+1 -1
View File
@@ -24,7 +24,7 @@
#include "entity.hpp"
class BaseMonster : public Entity {
class BaseMonster: public Entity {
public:
BaseMonster() = default;
virtual ~BaseMonster() = default;
+17
View File
@@ -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;
}
@@ -60,3 +73,7 @@ Vector2 Entity::GetOrigin() {
Vector2 Entity::GetMotion() {
return motion;
}
BoundingBox Entity::GetBounds() {
return bounds;
}
+4 -4
View File
@@ -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;