OverworldMap sprite entities, canvas drawing updates
This commit is contained in:
@@ -4,39 +4,40 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
Sprite::Sprite() {
|
||||
preview_gfx_.reserve(64 * 64);
|
||||
for (int i = 0; i < 64 * 64; i++) {
|
||||
preview_gfx_.push_back(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x,
|
||||
uchar y, int map_x, int map_y) {
|
||||
current_gfx_ = src;
|
||||
overworld_ = true;
|
||||
map_id_ = mapid;
|
||||
map_id_ = static_cast<int>(mapid);
|
||||
id_ = id;
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
this->type_ = zelda3::OverworldEntity::EntityType::kSprite;
|
||||
this->entity_id_ = id;
|
||||
this->x_ = map_x_;
|
||||
this->y_ = map_y_;
|
||||
nx_ = x;
|
||||
ny_ = y;
|
||||
name_ = core::kSpriteDefaultNames[id];
|
||||
map_x_ = map_x;
|
||||
map_y_ = map_y;
|
||||
preview_gfx_.reserve(64 * 64);
|
||||
for (int i = 0; i < 64 * 64; i++) {
|
||||
preview_gfx_.push_back(0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
Sprite::Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
int map_y)
|
||||
: current_gfx_(src),
|
||||
map_id_(mapid),
|
||||
map_id_(static_cast<int>(mapid)),
|
||||
id_(id),
|
||||
x_(x),
|
||||
y_(y),
|
||||
nx_(x),
|
||||
ny_(y),
|
||||
map_x_(map_x),
|
||||
map_y_(map_y) {
|
||||
this->type_ = zelda3::OverworldEntity::EntityType::kSprite;
|
||||
this->entity_id_ = id;
|
||||
this->x_ = map_x_;
|
||||
this->y_ = map_y_;
|
||||
current_gfx_ = src;
|
||||
overworld_ = true;
|
||||
|
||||
@@ -47,6 +48,12 @@ Sprite::Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
}
|
||||
}
|
||||
|
||||
void Sprite::UpdateMapProperties(short map_id) {
|
||||
map_x_ = x_;
|
||||
map_y_ = y_;
|
||||
name_ = core::kSpriteDefaultNames[id_];
|
||||
}
|
||||
|
||||
void Sprite::updateCoordinates(int map_x, int map_y) {
|
||||
map_x_ = map_x;
|
||||
map_y_ = map_y;
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
#include "app/rom.h"
|
||||
#include "app/zelda3/common.h"
|
||||
|
||||
namespace yaze {
|
||||
namespace app {
|
||||
namespace zelda3 {
|
||||
|
||||
class Sprite {
|
||||
class Sprite : public OverworldEntity {
|
||||
public:
|
||||
Sprite();
|
||||
Sprite() = default;
|
||||
Sprite(Bytes src, uchar mapid, uchar id, uchar x, uchar y, int map_x,
|
||||
int map_y);
|
||||
void InitSprite(const Bytes& src, uchar mapid, uchar id, uchar x, uchar y,
|
||||
@@ -32,13 +33,14 @@ class Sprite {
|
||||
bool mirror_x = false, bool mirror_y = false,
|
||||
int sizex = 2, int sizey = 2);
|
||||
|
||||
void UpdateMapProperties(short map_id) override;
|
||||
|
||||
// New methods
|
||||
void updateCoordinates(int map_x, int map_y);
|
||||
|
||||
auto PreviewGraphics() const { return preview_gfx_; }
|
||||
auto GetRealX() const { return bounding_box_.x; }
|
||||
auto GetRealY() const { return bounding_box_.y; }
|
||||
auto id() const { return id_; }
|
||||
auto set_id(uchar id) { id_ = id; }
|
||||
auto x() const { return x_; }
|
||||
auto y() const { return y_; }
|
||||
auto nx() const { return nx_; }
|
||||
@@ -55,6 +57,7 @@ class Sprite {
|
||||
auto Height() const { return bounding_box_.h; }
|
||||
std::string& Name() { return name_; }
|
||||
auto deleted() const { return deleted_; }
|
||||
auto set_deleted(bool deleted) { deleted_ = deleted; }
|
||||
|
||||
private:
|
||||
Bytes current_gfx_;
|
||||
@@ -62,8 +65,8 @@ class Sprite {
|
||||
|
||||
uchar map_id_;
|
||||
uchar id_;
|
||||
uchar x_;
|
||||
uchar y_;
|
||||
// uchar x_;
|
||||
// uchar y_;
|
||||
uchar nx_;
|
||||
uchar ny_;
|
||||
uchar overlord_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user