aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp82
1 files changed, 12 insertions, 70 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0472a95..4ba1970 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,50 +6,25 @@
/* ()__)____________))))) :^} */
/*********************************/
+#include <raylib.h>
#include "yabs_core.h"
#include "yabs_utils.h"
-static yabs::gameState game_state = yabs::TITLE;
-
-static yabs::Scene3D sc3d{
- // camera
- {{5.0f, 5.0f, 5.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, 45.0f, 0},
- // movement
- {0.0f, 0.0f},
- // rotation
- {0.0f, -0.2f, 0.0f},
- // mouse
- {0.0f, 0.0f}};
+static yabs::gameState game_state = yabs::GAMEPLAY;
int main(void) {
// create window
InitWindow(YABS_SCREENWIDTH, YABS_SCREENHEIGHT, YABS_TITLE);
+ bool started = false;
- // create image
- Image checked = GenImageChecked(2, 2, 1, 1, BLACK, GRAY);
- Texture2D texture = LoadTextureFromImage(checked);
- UnloadImage(checked);
-
- // create model with image as texture
- Model model = {};
- model = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f));
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
-
- // setup camera
- SetTargetFPS(60);
- SetCameraMode(sc3d.camera, CAMERA_FIRST_PERSON);
- sc3d.camera.position = (Vector3){50.0f, 1.0f, 50.0f};
- sc3d.camera.target = (Vector3){50.0f, 1.0f, 50.0f};
- sc3d.camera.up = (Vector3){0.0f, 1.0f, 0.0f};
- sc3d.camera.fovy = 90.0f;
- sc3d.camera.projection = CAMERA_PERSPECTIVE;
-
- sc3d.rotation = (Vector3){0.0f, 0.0f, 0.0f};
- sc3d.lastMousePos = GetMousePosition();
// game loop
while (!WindowShouldClose()) {
switch (game_state) {
case (yabs::TITLE): {
+ if (IsKeyPressed(KEY_ENTER))
+ {
+ game_state = yabs::GAMEPLAY;
+ }
break;
}
case (yabs::PICK): {
@@ -59,28 +34,11 @@ int main(void) {
break;
}
case (yabs::GAMEPLAY): {
- yabs::core::reset_camera(sc3d);
- break;
- }
- case (yabs::NEXT): {
- break;
- }
- case (yabs::ENDING): {
- break;
- }
- }
-
- switch (game_state) {
- case (yabs::TITLE): {
- break;
- }
- case (yabs::PICK): {
- break;
- }
- case (yabs::DEATH): {
- break;
- }
- case (yabs::GAMEPLAY): {
+ if (!started)
+ {
+ started = true;
+ yabs::core::init_game();
+ }
break;
}
case (yabs::NEXT): {
@@ -90,23 +48,7 @@ int main(void) {
break;
}
}
-
- // draw
- BeginDrawing();
- ClearBackground(GRAY);
- BeginMode3D(sc3d.camera);
-
- yabs::core::tick(sc3d);
- yabs::core::draw(model);
-
- EndMode3D();
- DrawFPS(0, 0);
- DrawText("Controls: Mouse / WASD / SPACE/CTRL.", YABS_SCREENWIDTH - 400,
- 0, 20, DARKGRAY);
- EndDrawing();
}
- UnloadTexture(texture);
- UnloadModel(model);
CloseWindow();
return (0);
}