Refactor sprite handling for consistency by standardizing variable naming and improving constructor initialization
This commit is contained in:
@@ -7,7 +7,7 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
static const std::string overlordnames[] = {
|
||||
static const std::string kOverlordNames[] = {
|
||||
"Overlord_SpritePositionTarget",
|
||||
"Overlord_AllDirectionMetalBallFactory",
|
||||
"Overlord_CascadeMetalBallFactory",
|
||||
@@ -40,4 +40,4 @@ static const std::string overlordnames[] = {
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
#endif // YAZE_APP_ZELDA3_SPRITE_OVERLORD_H
|
||||
#endif // YAZE_APP_ZELDA3_SPRITE_OVERLORD_H
|
||||
|
||||
@@ -18,10 +18,10 @@ void Sprite::UpdateCoordinates(int map_x, int map_y) {
|
||||
}
|
||||
|
||||
void Sprite::UpdateBoundaryBox() {
|
||||
lowerX_ = 1;
|
||||
lowerY_ = 1;
|
||||
higherX_ = 15;
|
||||
higherY_ = 15;
|
||||
lower_x_ = 1;
|
||||
lower_y_ = 1;
|
||||
higher_x_ = 15;
|
||||
higher_x_ = 15;
|
||||
}
|
||||
|
||||
void Sprite::Draw() {
|
||||
@@ -57,13 +57,13 @@ void Sprite::Draw() {
|
||||
}
|
||||
|
||||
if (nx_ != x || ny_ != y) {
|
||||
bounding_box_.x = (lowerX_ + (nx_ * 16));
|
||||
bounding_box_.y = (lowerY_ + (ny_ * 16));
|
||||
bounding_box_.x = (lower_x_ + (nx_ * 16));
|
||||
bounding_box_.y = (lower_y_ + (ny_ * 16));
|
||||
bounding_box_.w = width_;
|
||||
bounding_box_.h = height_;
|
||||
} else {
|
||||
bounding_box_.x = (lowerX_ + (x * 16));
|
||||
bounding_box_.y = (lowerY_ + (y * 16));
|
||||
bounding_box_.x = (lower_x_ + (x * 16));
|
||||
bounding_box_.y = (lower_y_ + (y * 16));
|
||||
bounding_box_.w = width_;
|
||||
bounding_box_.h = height_;
|
||||
}
|
||||
@@ -864,8 +864,8 @@ void Sprite::Draw() {
|
||||
DrawSpriteTile((x * 16), (y * 16), 4, 4, 5);
|
||||
}
|
||||
|
||||
bounding_box_.x = (lowerX_ + (x * 16));
|
||||
bounding_box_.y = (lowerY_ + (y * 16));
|
||||
bounding_box_.x = (lower_x_ + (x * 16));
|
||||
bounding_box_.y = (lower_y_ + (y * 16));
|
||||
bounding_box_.w = width_;
|
||||
bounding_box_.h = height_;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "app/zelda3/common.h"
|
||||
#include "app/zelda3/sprite/overlord.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
@@ -297,7 +298,18 @@ class Sprite : public GameEntity {
|
||||
preview_gfx_.resize(64 * 64, 0xFF);
|
||||
}
|
||||
|
||||
void InitSprite(const std::vector<uint8_t>& src, uint8_t overworld_map_id,
|
||||
Sprite(uint8_t id, uint8_t x, uint8_t y, uint8_t subtype, uint8_t layer)
|
||||
: id_(id), nx_(x), ny_(y), subtype_(subtype), layer_(layer) {
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
name_ = kSpriteDefaultNames[id];
|
||||
if (((subtype & 0x07) == 0x07) && id > 0 && id <= 0x1A) {
|
||||
name_ = kOverlordNames[id - 1];
|
||||
overlord_ = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void InitSprite(const std::vector<uint8_t> &src, uint8_t overworld_map_id,
|
||||
uint8_t id, uint8_t x, uint8_t y, int map_x, int map_y) {
|
||||
current_gfx_ = src;
|
||||
overworld_ = true;
|
||||
@@ -341,11 +353,12 @@ class Sprite : public GameEntity {
|
||||
auto layer() const { return layer_; }
|
||||
auto subtype() const { return subtype_; }
|
||||
|
||||
auto Width() const { return bounding_box_.w; }
|
||||
auto Height() const { return bounding_box_.h; }
|
||||
auto width() const { return bounding_box_.w; }
|
||||
auto height() const { return bounding_box_.h; }
|
||||
auto name() { return name_; }
|
||||
auto deleted() const { return deleted_; }
|
||||
auto set_deleted(bool deleted) { deleted_ = deleted; }
|
||||
auto set_key_drop(int key) { key_drop_ = key; }
|
||||
|
||||
private:
|
||||
uint8_t map_id_;
|
||||
@@ -354,18 +367,18 @@ class Sprite : public GameEntity {
|
||||
uint8_t nx_;
|
||||
uint8_t ny_;
|
||||
uint8_t overlord_ = 0;
|
||||
uint8_t lowerX_;
|
||||
uint8_t lowerY_;
|
||||
uint8_t higherX_;
|
||||
uint8_t higherY_;
|
||||
uint8_t lower_x_ = 32;
|
||||
uint8_t lower_y_ = 32;
|
||||
uint8_t higher_x_ = 0;
|
||||
uint8_t higher_y_ = 0;
|
||||
|
||||
int width_ = 16;
|
||||
int height_ = 16;
|
||||
int map_x_;
|
||||
int map_y_;
|
||||
int layer_;
|
||||
int subtype_;
|
||||
int key_drop_;
|
||||
int map_x_ = 0;
|
||||
int map_y_ = 0;
|
||||
int layer_ = 0;
|
||||
int subtype_ = 0;
|
||||
int key_drop_ = 0;
|
||||
|
||||
bool deleted_ = false;
|
||||
bool overworld_;
|
||||
|
||||
Reference in New Issue
Block a user