@@ -20,9 +20,9 @@ ItemStackEntity::ItemStackEntity(const Swan::Context &ctx, const PackObject &obj | |||
} | |||
void ItemStackEntity::draw(const Swan::Context &ctx, Swan::Win &win) { | |||
SDL_Rect rect = item_->image_.frameRect(); | |||
SDL_Rect rect = item_->image.frameRect(); | |||
SDL_Texture *tex = item_->image_.texture_.get(); | |||
SDL_Texture *tex = item_->image.texture_.get(); | |||
Swan::TexColorMod darken(tex, 220, 220, 220); | |||
win.showTexture(body_.pos, tex, &rect, | |||
@@ -47,6 +47,6 @@ void ItemStackEntity::deserialize(const Swan::Context &ctx, const PackObject &ob | |||
Swan::Entity::PackObject ItemStackEntity::serialize(const Swan::Context &ctx, msgpack::zone &zone) { | |||
return { | |||
{ "pos", msgpack::object(body_.pos, zone) }, | |||
{ "tile", msgpack::object(item_->name_, zone) }, | |||
{ "tile", msgpack::object(item_->name, zone) }, | |||
}; | |||
} |
@@ -62,7 +62,7 @@ void PlayerEntity::update(const Swan::Context &ctx, float dt) { | |||
} | |||
// Fall down faster than we went up | |||
if (!physics_.on_ground && (!jumpPressed || physics_.vel.y > 0)) | |||
if (!physics_.onGround && (!jumpPressed || physics_.vel.y > 0)) | |||
physics_.force += Swan::Vec2(0, DOWN_FORCE); | |||
if (state_ != oldState) |
@@ -23,22 +23,22 @@ public: | |||
registerTile({ | |||
.name = "stone", | |||
.image = "core/tile/stone", | |||
.dropped_item = "core::stone", | |||
.droppedItem = "core::stone", | |||
}); | |||
registerTile({ | |||
.name = "dirt", | |||
.image = "core/tile/dirt", | |||
.dropped_item = "core::dirt", | |||
.droppedItem = "core::dirt", | |||
}); | |||
registerTile({ | |||
.name = "grass", | |||
.image = "core/tile/grass", | |||
.dropped_item = "core::dirt", | |||
.droppedItem = "core::dirt", | |||
}); | |||
registerTile({ | |||
.name = "tree-trunk", | |||
.image = "core/tile/tree-trunk", | |||
.dropped_item = "core::tree-trunk", | |||
.droppedItem = "core::tree-trunk", | |||
}); | |||
registerTile({ | |||
.name = "leaves", | |||
@@ -47,8 +47,8 @@ public: | |||
registerTile({ | |||
.name = "torch", | |||
.image = "core/tile/torch", | |||
.is_solid = false, | |||
.light_level = 80/255.0, | |||
.isSolid = false, | |||
.lightLevel = 80/255.0, | |||
}); | |||
registerItem({ | |||
@@ -75,9 +75,9 @@ public: | |||
} | |||
void onTileBreak(const Swan::Context &ctx, Swan::TilePos pos, Swan::Tile &tile) { | |||
if (tile.droppedItem_) { | |||
if (tile.droppedItem) { | |||
ctx.plane.spawnEntity<ItemStackEntity>( | |||
ctx, (Swan::Vec2)pos + Swan::Vec2{0.5, 0.5}, *tile.droppedItem_); | |||
ctx, (Swan::Vec2)pos + Swan::Vec2{0.5, 0.5}, *tile.droppedItem); | |||
} | |||
} | |||
@@ -11,7 +11,7 @@ void Animation::tick(float dt) { | |||
timer_ += interval_; | |||
frame_ += 1; | |||
if (frame_ >= resource_.num_frames_) | |||
if (frame_ >= resource_.numFrames_) | |||
frame_ = 0; | |||
} | |||
} |