-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add IndexRect to save & load map edge index info - Add player & door - Add camera edge-snapping
- Loading branch information
Showing
26 changed files
with
959 additions
and
242 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include "game_entity_IOpenableEntity.h" | ||
|
||
#include <bn_fixed_rect.h> | ||
#include <bn_sprite_animate_actions.h> | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class Door final : public IOpenableEntity | ||
{ | ||
public: | ||
Door(bn::fixed_point position, bool isOpened); | ||
|
||
Door(Door&& other); | ||
Door& operator=(Door&& other); | ||
|
||
Door(const Door& other) = delete; | ||
Door& operator=(const Door& other) = delete; | ||
|
||
void FreeGraphicResource() final; | ||
|
||
void Update() final; | ||
|
||
void InitDoorOpenAction(); | ||
void InitDoorCloseAction(); | ||
|
||
private: | ||
bn::optional<bn::sprite_animate_action<4>> action_; | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include "game_entity_IEntity.h" | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class HoverButton final : IEntity | ||
{ | ||
public: | ||
private: | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
|
||
#include <bn_camera_ptr.h> | ||
#include <bn_fixed_rect.h> | ||
#include <bn_optional.h> | ||
#include <bn_sprite_item.h> | ||
#include <bn_sprite_ptr.h> | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class IEntity | ||
{ | ||
public: | ||
virtual ~IEntity() = 0; | ||
|
||
/** | ||
* @brief Constructor. | ||
* | ||
* Graphic is not allocated in here. | ||
* You have to manually call AllocateGraphicResource(). | ||
* | ||
* @param position center position of the Entity | ||
* @param relativeInteractRange rect range to interact with player, relative to position. | ||
* @param spriteItem sprite_item | ||
*/ | ||
IEntity(bn::fixed_point position, bn::fixed_rect relativeInteractRange, | ||
const bn::sprite_item* spriteItem = nullptr); | ||
|
||
/** | ||
* @brief Move constructor. | ||
* | ||
*/ | ||
IEntity(IEntity&& other); | ||
|
||
/** | ||
* @brief Move assignment operator. | ||
* | ||
*/ | ||
IEntity& operator=(IEntity&& other); | ||
|
||
IEntity(const IEntity& other) = delete; | ||
IEntity& operator=(const IEntity& other) = delete; | ||
|
||
virtual void Update(); | ||
|
||
/** | ||
* @brief Get the interactive range. | ||
* Absolute coordinate. | ||
* | ||
*/ | ||
bn::fixed_rect GetInteractRange() const; | ||
|
||
virtual void FreeGraphicResource(); | ||
virtual void AllocateGraphicResource(int z_order); | ||
|
||
void SetCamera(const bn::camera_ptr& camera); | ||
|
||
bn::fixed_point GetPosition() const; | ||
void SetPosition(const bn::fixed_point& position); | ||
bn::fixed GetX() const; | ||
bn::fixed GetY() const; | ||
void SetX(bn::fixed x); | ||
void SetY(bn::fixed y); | ||
|
||
protected: | ||
bn::fixed_point position_; | ||
bn::fixed_rect relativeInteractRange_; | ||
bn::optional<bn::sprite_ptr> sprite_; | ||
const bn::sprite_item* spriteItem_; | ||
|
||
void SyncSpritePositionToPosition_(); | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include "game_entity_IEntity.h" | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class IGravityEntity : public IEntity | ||
{ | ||
public: | ||
virtual ~IGravityEntity() = 0; | ||
|
||
IGravityEntity(bn::fixed_point position, bn::fixed_rect relativeInteractRange, | ||
bn::fixed_rect relativePhysicsCollider, bool isGravityEnabledByDefault, bn::fixed gravityScale, | ||
const bn::sprite_item* spriteItem); | ||
|
||
IGravityEntity(IGravityEntity&& other); | ||
IGravityEntity& operator=(IGravityEntity&& other); | ||
|
||
IGravityEntity(const IGravityEntity& other) = delete; | ||
IGravityEntity& operator=(const IGravityEntity& other) = delete; | ||
|
||
/** | ||
* @brief Get the physics collider. | ||
* Absolute Coordinate. | ||
* | ||
* @return `bn::fixed_rect` collider | ||
*/ | ||
bn::fixed_rect GetPhysicsCollider() const; | ||
|
||
bool GetGravityEnabled() const; | ||
void SetGravityEnabled(bool isGravityEnabled); | ||
|
||
bn::fixed GetGravityScale() const; | ||
void SetGravityScale(bn::fixed gravityScale); | ||
[[maybe_unused]] bool ToggleGravityEnabled(); | ||
|
||
protected: | ||
/** | ||
* @brief saves collider relative to the position_. | ||
* | ||
*/ | ||
bn::fixed_rect relativePhysicsCollider_; | ||
bool isGravityEnabled_; | ||
bn::fixed gravityScale_; | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "game_entity_IEntity.h" | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class IOpenableEntity : public IEntity | ||
{ | ||
public: | ||
virtual ~IOpenableEntity() = 0; | ||
|
||
IOpenableEntity(bn::fixed_point position, bn::fixed_rect relativeInteractRange, bool isOpened, | ||
const bn::sprite_item* spriteItem = nullptr); | ||
|
||
IOpenableEntity(IOpenableEntity&& other); | ||
IOpenableEntity& operator=(IOpenableEntity&& other); | ||
|
||
IOpenableEntity(const IOpenableEntity& other) = delete; | ||
IOpenableEntity& operator=(const IOpenableEntity& other) = delete; | ||
|
||
bool GetOpened() const; | ||
void SetOpened(bool); | ||
[[maybe_unused]] bool ToggleOpened(); | ||
|
||
private: | ||
bool isOpened_; | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#pragma once | ||
|
||
#include "game_entity_IGravityEntity.h" | ||
|
||
#include <bn_any.h> | ||
#include <bn_sprite_animate_actions.h> | ||
|
||
namespace sym::game::entity | ||
{ | ||
|
||
class Player final : public IGravityEntity | ||
{ | ||
public: | ||
Player(bn::fixed_point position); | ||
|
||
Player(Player&& other); | ||
Player& operator=(Player&& other); | ||
|
||
Player(const Player& other) = delete; | ||
Player& operator=(const Player& other) = delete; | ||
|
||
void FreeGraphicResource() final; | ||
|
||
void Update() final; | ||
|
||
void InitIdleAction(); | ||
void InitJumpAction(); | ||
void InitFallAction(); | ||
void InitLandAction(); | ||
void InitMergeStartAction(); | ||
void InitMergeEndAction(); | ||
|
||
private: | ||
static constexpr bn::fixed_rect RELATIVE_INTERACT_RANGE = {{0, 0}, {32, 32}}; | ||
static constexpr bn::fixed_rect RELATIVE_PHYSICS_COLLIDER = {{0, 0}, {26, 26}}; | ||
static constexpr bool IS_GRAVITY_ENABLED_BY_DEFAULT = true; | ||
static constexpr bn::fixed GRAVITY_SCALE = 1; | ||
|
||
static constexpr int IDLE_ACTION_WAIT_UPDATE = 30; | ||
static constexpr int OTHER_ACTIONS_WAIT_UPDATE = 10; | ||
|
||
bn::optional<bn::sprite_animate_action<2>> action2_; | ||
bn::optional<bn::sprite_animate_action<3>> action3_; | ||
/** | ||
* @brief Additional wait update before the InitIdleAction() is called. | ||
* If it is `-1`, InitIdleAction() is not called. | ||
* (i.e. the last animation frame is used after the action ends.) | ||
* | ||
*/ | ||
int additionalWaitUpdateCount = -1; | ||
|
||
void DestroyActions_(); | ||
}; | ||
|
||
} // namespace sym::game::entity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.