demo map and weapon

This commit is contained in:
h4570
2022-07-31 16:24:46 +02:00
parent 834d57ea32
commit 12dd72f15e
28 changed files with 781 additions and 18 deletions
+49
View File
@@ -0,0 +1,49 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "states/game/player/camera.hpp"
#include "debug/debug.hpp"
namespace Demo {
Camera::Camera(Pad* t_pad) : lookAt(0.0F), position(0.0F), pad(t_pad) {
lengthFromOrigin = 30.0F;
circleRotation = -3.5F;
height = 1.5F;
}
Camera::~Camera() {}
void Camera::update(const Vec4& playerPosition) {
const float rotationOffset = 0.03F;
const float heightOffset = 0.5F;
const auto& rightJoy = pad->getRightJoyPad();
if (rightJoy.h <= 100) {
circleRotation -= rotationOffset;
} else if (rightJoy.h >= 200) {
circleRotation += rotationOffset;
}
if (rightJoy.v <= 100) {
height -= heightOffset;
} else if (rightJoy.v >= 200) {
height += heightOffset;
}
unitCircle.x = (sin(circleRotation) * lengthFromOrigin);
unitCircle.y = height + playerPosition.y;
unitCircle.z = (cos(circleRotation) * lengthFromOrigin);
lookAt = unitCircle + playerPosition;
}
} // namespace Demo