zad5
This commit is contained in:
39
2dkg_zad5/2dgk_zad5/KPawn.h
Normal file
39
2dkg_zad5/2dgk_zad5/KPawn.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#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;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user