aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-06-09 23:15:31 +0200
committersalaaad2 <arthurdurant263@gmail.com>2022-06-09 23:15:31 +0200
commit9477e06af0d90f12b92d63038ba6f6690b922092 (patch)
tree0023415ad5832b630dffc964da70b05e9aaa1208
parentdoesntwork i gotta sleep :^\} (diff)
downloadyabs-9477e06af0d90f12b92d63038ba6f6690b922092.tar.gz
yabs-9477e06af0d90f12b92d63038ba6f6690b922092.tar.bz2
yabs-9477e06af0d90f12b92d63038ba6f6690b922092.tar.xz
yabs-9477e06af0d90f12b92d63038ba6f6690b922092.tar.zst
yabs-9477e06af0d90f12b92d63038ba6f6690b922092.zip
format
-rw-r--r--src/yabs_core.cpp97
-rw-r--r--src/yabs_core.h6
-rw-r--r--src/yabs_defines.h12
3 files changed, 64 insertions, 51 deletions
diff --git a/src/yabs_core.cpp b/src/yabs_core.cpp
index 8920f96..3648dfb 100644
--- a/src/yabs_core.cpp
+++ b/src/yabs_core.cpp
@@ -8,13 +8,13 @@
#include <stdlib.h>
-#include "yabs_core.h"
#include "raymath.h"
+#include "yabs_core.h"
namespace yabs {
namespace core {
-int reset_camera(Scene3D & scene_3d) {
+int reset_camera(Scene3D& scene_3d) {
SetCameraMode(scene_3d.camera, CAMERA_FIRST_PERSON);
scene_3d.camera.position = (Vector3){50.0f, 1.0f, 50.0f};
scene_3d.camera.target = (Vector3){50.0f, 1.0f, 50.0f};
@@ -27,70 +27,71 @@ int reset_camera(Scene3D & scene_3d) {
return (0);
}
-int draw(gameState const& game_state, Model & model) {
- // draw checkerboard model
- for (int x = 0; x < 50; x++) {
- for (int z = 0; z < 50; z++) {
- Vector3 position;
- position.x = x;
- position.y = 0;
- position.z = z;
- DrawModel(model, position, 1.0f, WHITE);
- }
+int draw(gameState const& game_state, Model& model) {
+ // draw checkerboard model
+ for (int x = 0; x < 50; x++) {
+ for (int z = 0; z < 50; z++) {
+ Vector3 position;
+ position.x = x;
+ position.y = 0;
+ position.z = z;
+ DrawModel(model, position, 1.0f, WHITE);
}
+ }
- // end draw
+ // end draw
return (0);
}
-int tick(Scene3D & scene_3d) {
- // mouse look
- Vector2 mouseMovement =
- Vector2Subtract(GetMousePosition(), scene_3d.lastMousePos);
- scene_3d.lastMousePos = GetMousePosition();
- scene_3d.rotation.x +=
- (mouseMovement.x * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY);
- scene_3d.rotation.y +=
- (mouseMovement.y * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY);
+int tick(Scene3D& scene_3d) {
+ // mouse look
+ Vector2 mouseMovement =
+ Vector2Subtract(GetMousePosition(), scene_3d.lastMousePos);
+ scene_3d.lastMousePos = GetMousePosition();
+ scene_3d.rotation.x +=
+ (mouseMovement.x * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY);
+ scene_3d.rotation.y +=
+ (mouseMovement.y * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY);
- // direction array
- bool direction[4] = {IsKeyDown(KEY_W), IsKeyDown(KEY_S),
- IsKeyDown(KEY_D), IsKeyDown(KEY_A)};
+ // direction array
+ bool direction[4] = {IsKeyDown(KEY_W), IsKeyDown(KEY_S), IsKeyDown(KEY_D),
+ IsKeyDown(KEY_A)};
- // compute movement
- scene_3d.movement = (Vector3){0, 0, 0};
- scene_3d.movement.x = (sinf(scene_3d.rotation.x) * direction[1] -
+ // compute movement
+ scene_3d.movement = (Vector3){0, 0, 0};
+ scene_3d.movement.x = (sinf(scene_3d.rotation.x) * direction[1] -
sinf(scene_3d.rotation.x) * direction[0] -
cosf(scene_3d.rotation.x) * direction[3] +
cosf(scene_3d.rotation.x) * direction[2]) /
YABS_PLAYER_MOVEMENT_SENSITIVITY;
- scene_3d.movement.z = (cosf(scene_3d.rotation.x) * direction[1] -
+ scene_3d.movement.z = (cosf(scene_3d.rotation.x) * direction[1] -
cosf(scene_3d.rotation.x) * direction[0] +
sinf(scene_3d.rotation.x) * direction[3] -
sinf(scene_3d.rotation.x) * direction[2]) /
YABS_PLAYER_MOVEMENT_SENSITIVITY;
- // elevation
- if (IsKeyDown(KEY_SPACE))
- scene_3d.movement.y += 0.12f;
- if (IsKeyDown(KEY_LEFT_CONTROL))
- scene_3d.movement.y -= 0.12f;
+ // elevation
+ if (IsKeyDown(KEY_SPACE))
+ scene_3d.movement.y += 0.12f;
+ if (IsKeyDown(KEY_LEFT_CONTROL))
+ scene_3d.movement.y -= 0.12f;
- // apply movement
- scene_3d.camera.position.x +=
- scene_3d.movement.x / YABS_PLAYER_MOVEMENT_SENSITIVITY;
- scene_3d.camera.position.y += scene_3d.movement.y;
- scene_3d.camera.position.z +=
- scene_3d.movement.z / YABS_PLAYER_MOVEMENT_SENSITIVITY;
+ // apply movement
+ scene_3d.camera.position.x +=
+ scene_3d.movement.x / YABS_PLAYER_MOVEMENT_SENSITIVITY;
+ scene_3d.camera.position.y += scene_3d.movement.y;
+ scene_3d.camera.position.z +=
+ scene_3d.movement.z / YABS_PLAYER_MOVEMENT_SENSITIVITY;
- Matrix translation = MatrixTranslate(0, 0, (10));
- Matrix rotation2 = MatrixRotateXYZ((Vector3){
- YABS_DOUBLEPI - scene_3d.rotation.y, YABS_DOUBLEPI - scene_3d.rotation.x, 0});
- Matrix transform = MatrixMultiply(translation, rotation2);
+ Matrix translation = MatrixTranslate(0, 0, (10));
+ Matrix rotation2 =
+ MatrixRotateXYZ((Vector3){YABS_DOUBLEPI - scene_3d.rotation.y,
+ YABS_DOUBLEPI - scene_3d.rotation.x, 0});
+ Matrix transform = MatrixMultiply(translation, rotation2);
- // apply camera rotation
- scene_3d.camera.target.x = scene_3d.camera.position.x - transform.m12;
- scene_3d.camera.target.y = scene_3d.camera.position.y - transform.m13;
- scene_3d.camera.target.z = scene_3d.camera.position.z - transform.m14;
+ // apply camera rotation
+ scene_3d.camera.target.x = scene_3d.camera.position.x - transform.m12;
+ scene_3d.camera.target.y = scene_3d.camera.position.y - transform.m13;
+ scene_3d.camera.target.z = scene_3d.camera.position.z - transform.m14;
return (0);
}
diff --git a/src/yabs_core.h b/src/yabs_core.h
index 73c7543..ce30e0c 100644
--- a/src/yabs_core.h
+++ b/src/yabs_core.h
@@ -43,11 +43,11 @@ namespace core {
// draw takes a reference to the game_state, which is checked on each frame
// for next level or death
-int reset_camera(Scene3D & scene_3d);
+int reset_camera(Scene3D& scene_3d);
-int draw(gameState const& game_state, Model & model);
+int draw(gameState const& game_state, Model& model);
-int tick(Scene3D & scene_3d);
+int tick(Scene3D& scene_3d);
} // namespace core
diff --git a/src/yabs_defines.h b/src/yabs_defines.h
new file mode 100644
index 0000000..b0e045e
--- /dev/null
+++ b/src/yabs_defines.h
@@ -0,0 +1,12 @@
+#ifndef YABS_DEFINES_H
+#define YABS_DEFINES_H
+
+/*********************************/
+/* YABS ( // */
+/* yabs_defines ( )/ */
+/* by salade )(/ */
+/* ________________ ( /) */
+/* ()__)____________))))) :^} */
+/*********************************/
+
+#endif /* YABS_DEFINES_H */