@@ -4,7 +4,7 @@ | |||
ItemStackEntity::ItemStackEntity( | |||
const Swan::Context &ctx, Swan::Vec2 pos, const std::string &item): | |||
PhysicsEntity(SIZE, MASS) { | |||
ItemStackEntity() { | |||
static std::uniform_real_distribution vx(-2.3f, 2.3f); | |||
static std::uniform_real_distribution vy(-2.3f, -1.2f); | |||
@@ -16,9 +16,7 @@ ItemStackEntity::ItemStackEntity( | |||
} | |||
ItemStackEntity::ItemStackEntity(const Swan::Context &ctx, const PackObject &obj): | |||
PhysicsEntity(SIZE, MASS) { | |||
PhysicsEntity::body_.bounciness_ = 0.6; | |||
ItemStackEntity() { | |||
deserialize(ctx, obj); | |||
} | |||
@@ -17,6 +17,10 @@ private: | |||
static constexpr Swan::Vec2 SIZE = Swan::Vec2(0.5, 0.5); | |||
static constexpr float DESPAWN_TIME = 5 * 60; | |||
ItemStackEntity(): PhysicsEntity(SIZE, MASS) { | |||
PhysicsEntity::body_.bounciness_ = 0.6; | |||
} | |||
float despawn_timer_ = DESPAWN_TIME; | |||
Swan::Item *item_ = NULL; | |||
}; |
@@ -5,22 +5,12 @@ | |||
#include "ItemStackEntity.h" | |||
PlayerEntity::PlayerEntity(const Swan::Context &ctx, Swan::Vec2 pos): | |||
PhysicsEntity(SIZE, MASS), inventory_(INVENTORY_SIZE), | |||
anims_{ | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-still"), 0.8), | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-running"), 1, SDL_FLIP_HORIZONTAL), | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-running"), 1) } { | |||
PlayerEntity(ctx) { | |||
body_.pos_ = pos; | |||
} | |||
PlayerEntity::PlayerEntity(const Swan::Context &ctx, const PackObject &obj): | |||
PhysicsEntity(SIZE, MASS), inventory_(INVENTORY_SIZE), | |||
anims_{ | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-still"), 0.8), | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-running"), 1, SDL_FLIP_HORIZONTAL), | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-running"), 1) } { | |||
PlayerEntity(ctx) { | |||
deserialize(ctx, obj); | |||
} | |||
@@ -24,6 +24,17 @@ private: | |||
static constexpr float DOWN_FORCE = 20 * MASS; | |||
static constexpr Swan::Vec2 SIZE = Swan::Vec2(0.6, 1.9); | |||
PlayerEntity(const Swan::Context &ctx): | |||
PhysicsEntity(SIZE, MASS), inventory_(INVENTORY_SIZE), | |||
anims_{ | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-still"), 0.8), | |||
Swan::Animation( | |||
ctx.resources.getImage("core/entity/player-running"), | |||
1, SDL_FLIP_HORIZONTAL), | |||
Swan::Animation(ctx.resources.getImage("core/entity/player-running"), 1) | |||
} {} | |||
Swan::InventoryTrait::BasicInventory inventory_; | |||
enum class State { |