40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#pragma once
|
|
#include <memory>
|
|
#include <SDL_rect.h>
|
|
#include <unordered_map>
|
|
|
|
#include "KSolid.h"
|
|
#include "Utils.h"
|
|
|
|
namespace KapitanGame
|
|
{
|
|
class KSettings;
|
|
class KPlayerController;
|
|
|
|
class KPawn : public KSolid
|
|
{
|
|
public:
|
|
KPawn(const KVector2D& position, const KTexture& texture,
|
|
const std::shared_ptr<KPlayerController>& playerController, KSettings* settings)
|
|
: KSolid(position, texture, nullptr),
|
|
PlayerController(playerController), CanJump(false), CanDoubleJump(false), HasJumped(true), Settings(settings)
|
|
{
|
|
}
|
|
|
|
void CollisionDetectionStep(const std::unordered_map<std::pair<int, int>, std::shared_ptr<KSolid>, Utils::PairHash>& objects);
|
|
void MovementStep(const float& timeStep);
|
|
void CollisionDetectionWithMapStep(const SDL_FRect& map);
|
|
void AddXMovementInput(const float& input);
|
|
void StopJump();
|
|
void StartJump();
|
|
private:
|
|
const std::weak_ptr<KPlayerController> PlayerController;
|
|
KVector2D Velocity{ 0.f, 0.f };
|
|
bool CanJump;
|
|
bool CanDoubleJump;
|
|
bool HasJumped;
|
|
KSettings* Settings;
|
|
};
|
|
}
|
|
|