Пример #1
0
void CCharacterController::jump()
{
	if (!canJump())
		return;

	SetJumpSpeed((float)m_hEntity->JumpStrength());

	m_hEntity->SetGlobalVelocity(ToTVector(GetUpVector()) * m_flJumpSpeed + m_hEntity->GetGlobalVelocity());

	m_hEntity->SetGroundEntity(nullptr);
}
Пример #2
0
Character::Character(Settings *settings, int mapWidth, int mapHeight, std::vector<std::vector<Cell>> *cellMap)
{
    hasText_ = false;
    movespeed_ = 0;
    currentRotation_ = 0;
    hasImage_ = false;
    hasColor_ = false;
    hasImageReference_ = false;
    aiEnabled_ = true;

    mapWidth_ = mapWidth;
    mapHeight_ = mapHeight;

    cellMap_ = cellMap;


    settings_ = settings;
    KeyLeft_ = false;
    KeyRight_ = false;
    KeySpace_ = false;
    SetCurrentPosition(mapWidth_ / Constants::TileSize() + 1, mapHeight_ / Constants::TileSize() + 1);
    SetColor(al_map_rgb_f(1, 1, 1));
    SetWidth(0.8);
    SetHeight(0.8);

    SetGravityY(-9.8);
    SetVelocityY(0.125);
    SetMaxVelocityY(1);
    SetAccelerationY(0.03125);


    SetMoveSpeedDelta(0.0625);
    SetMoveSpeed(30);
    SetJumpSpeed(12);

    font30_ = al_load_font("arial.ttf", Constants::TileSize(), 0);



    SetCharacterYAxisState(CHARACTERYAXISSTATES::CHARACTERFALLING);



}