Code tweak
This commit is contained in:
@@ -21,6 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "base_character.hpp"
|
#include "base_character.hpp"
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//graphics
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
void BaseCharacter::CorrectSprite() {
|
void BaseCharacter::CorrectSprite() {
|
||||||
//NOTE: These must correspond to the sprite sheet in use
|
//NOTE: These must correspond to the sprite sheet in use
|
||||||
if (motion.y > 0) {
|
if (motion.y > 0) {
|
||||||
@@ -45,3 +49,31 @@ void BaseCharacter::CorrectSprite() {
|
|||||||
sprite.SetXIndex(0);
|
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;
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
//std namespace
|
//std namespace
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class BaseCharacter : public Entity {
|
class BaseCharacter: public Entity {
|
||||||
public:
|
public:
|
||||||
BaseCharacter() = default;
|
BaseCharacter() = default;
|
||||||
virtual ~BaseCharacter() = default;
|
virtual ~BaseCharacter() = default;
|
||||||
@@ -38,12 +38,12 @@ public:
|
|||||||
void CorrectSprite();
|
void CorrectSprite();
|
||||||
|
|
||||||
//metadata
|
//metadata
|
||||||
int SetOwner(int i) { return owner = i; }
|
int SetOwner(int i);
|
||||||
int GetOwner() { return owner; }
|
int GetOwner();
|
||||||
std::string SetHandle(std::string s) { return handle = s; }
|
std::string SetHandle(std::string s);
|
||||||
std::string GetHandle() const { return handle; }
|
std::string GetHandle() const;
|
||||||
std::string SetAvatar(std::string s) { return avatar = s; }
|
std::string SetAvatar(std::string s);
|
||||||
std::string GetAvatar() const { return avatar; }
|
std::string GetAvatar() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//metadata
|
//metadata
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "entity.hpp"
|
#include "entity.hpp"
|
||||||
|
|
||||||
class BaseMonster : public Entity {
|
class BaseMonster: public Entity {
|
||||||
public:
|
public:
|
||||||
BaseMonster() = default;
|
BaseMonster() = default;
|
||||||
virtual ~BaseMonster() = default;
|
virtual ~BaseMonster() = default;
|
||||||
|
|||||||
@@ -30,6 +30,14 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpriteSheet* Entity::GetSprite() {
|
||||||
|
return &sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//accessors & mutators
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
int Entity::SetEntityIndex(int i) {
|
int Entity::SetEntityIndex(int i) {
|
||||||
return entityIndex = i;
|
return entityIndex = i;
|
||||||
}
|
}
|
||||||
@@ -45,6 +53,11 @@ Vector2 Entity::SetOrigin(Vector2 v) {
|
|||||||
Vector2 Entity::SetMotion(Vector2 v) {
|
Vector2 Entity::SetMotion(Vector2 v) {
|
||||||
return motion = v;
|
return motion = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoundingBox Entity::SetBounds(BoundingBox b) {
|
||||||
|
return bounds = b;
|
||||||
|
}
|
||||||
|
|
||||||
int Entity::GetEntityIndex() {
|
int Entity::GetEntityIndex() {
|
||||||
return entityIndex;
|
return entityIndex;
|
||||||
}
|
}
|
||||||
@@ -59,4 +72,8 @@ Vector2 Entity::GetOrigin() {
|
|||||||
|
|
||||||
Vector2 Entity::GetMotion() {
|
Vector2 Entity::GetMotion() {
|
||||||
return motion;
|
return motion;
|
||||||
|
}
|
||||||
|
|
||||||
|
BoundingBox Entity::GetBounds() {
|
||||||
|
return bounds;
|
||||||
}
|
}
|
||||||
@@ -32,24 +32,24 @@ public:
|
|||||||
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();
|
||||||
|
|
||||||
//accessors & mutators
|
//accessors & mutators
|
||||||
int SetEntityIndex(int i);
|
int SetEntityIndex(int i);
|
||||||
int SetRoomIndex(int i);
|
int SetRoomIndex(int i);
|
||||||
Vector2 SetOrigin(Vector2 v);
|
Vector2 SetOrigin(Vector2 v);
|
||||||
Vector2 SetMotion(Vector2 v);
|
Vector2 SetMotion(Vector2 v);
|
||||||
BoundingBox SetBounds(BoundingBox b) { return bounds = b; }
|
BoundingBox SetBounds(BoundingBox b);
|
||||||
|
|
||||||
int GetEntityIndex();
|
int GetEntityIndex();
|
||||||
int GetRoomIndex();
|
int GetRoomIndex();
|
||||||
Vector2 GetOrigin();
|
Vector2 GetOrigin();
|
||||||
Vector2 GetMotion();
|
Vector2 GetMotion();
|
||||||
BoundingBox GetBounds() { return bounds; }
|
BoundingBox GetBounds();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Entity() = default;
|
Entity() = default;
|
||||||
~Entity() = default;
|
virtual ~Entity() = default;
|
||||||
|
|
||||||
SpriteSheet sprite;
|
SpriteSheet sprite;
|
||||||
int entityIndex = -1;
|
int entityIndex = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user