Strafe Controls added

linux_template
sigonasr2 2 years ago
parent 7ab07a3482
commit 062666753b
  1. BIN
      Faceball2030/assets/enemies/#Sonar.wings#
  2. 36
      Faceball2030/main.cpp

@ -753,6 +753,42 @@ void FaceBall::HandleKeys(float fElapsedTime) {
bullets.push_back({ green_bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true });
}
}
if (GetKey(Q).bHeld) {
mat4x4 leftMat = Matrix_MakeRotationY(-PI / 2);
vec3d vLeftStrafe = Matrix_MultiplyVector(leftMat, vForward);
vLeftStrafe = { vLeftStrafe.x,0,vLeftStrafe.z };
if (freeRoam) {
freeRoamCamera = Vector_Add(freeRoamCamera, vLeftStrafe);
}
else {
if (!CheckCollision({ vLeftStrafe.x,0,0 }, { player.GetPos().x,player.GetPos().z }, player.GetRadius())) {
vec3d xMovement{ vLeftStrafe.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
}
if (!CheckCollision({ 0,0,vLeftStrafe.z }, { player.GetPos().x,player.GetPos().z }, player.GetRadius())) {
vec3d zMovement{ 0,0,vLeftStrafe.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
}
}
}
if (GetKey(E).bHeld) {
mat4x4 leftMat = Matrix_MakeRotationY(PI / 2);
vec3d vRightStrafe = Matrix_MultiplyVector(leftMat, vForward);
vRightStrafe = { vRightStrafe.x,0,vRightStrafe.z };
if (freeRoam) {
freeRoamCamera = Vector_Add(freeRoamCamera, vRightStrafe);
}
else {
if (!CheckCollision({ vRightStrafe.x,0,0 }, { player.GetPos().x,player.GetPos().z }, player.GetRadius())) {
vec3d xMovement{ vRightStrafe.x,0,0 };
player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
}
if (!CheckCollision({ 0,0,vRightStrafe.z }, { player.GetPos().x,player.GetPos().z }, player.GetRadius())) {
vec3d zMovement{ 0,0,vRightStrafe.z };
player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
}
}
}
if (GetKey(W).bHeld) {
if (freeRoam) {
freeRoamCamera = Vector_Add(freeRoamCamera, vForward);

Loading…
Cancel
Save