7
0
mirror of https://gitlab.com/raylibtemplates/rt.git synced 2026-06-28 11:15:21 -04:00

Seperate update into new file

This commit is contained in:
maple
2025-12-20 22:50:45 -06:00
parent 4d94c9b4b7
commit 8600517c12
4 changed files with 38 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
#include "main.h"
#include "consts.h" #include "consts.h"
#include "raylib.h" #include "raylib.h"
#include "raymath.h" #include "raymath.h"
#include "update.h"
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
@@ -13,7 +15,8 @@
#define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
void MainLoop(); static void MainLoop();
static void Draw();
RenderTexture2D target; RenderTexture2D target;
@@ -56,25 +59,16 @@ int main(void) {
return 0; return 0;
} }
void MainLoop() { static void MainLoop() {
int winWidth = GetScreenWidth(), winHeight = GetScreenHeight(); int winWidth = GetScreenWidth(), winHeight = GetScreenHeight();
float scale = float scale =
MIN((float)winWidth / SCREEN_WIDTH, (float)winHeight / SCREEN_HEIGHT); MIN((float)winWidth / SCREEN_WIDTH, (float)winHeight / SCREEN_HEIGHT);
cube.transform = Update();
MatrixMultiply(MatrixRotateXYZ(Vector3Scale((Vector3){1.0f, 1.5f, 2.5f},
GetFrameTime())),
cube.transform);
BeginTextureMode(target); BeginTextureMode(target);
{ {
ClearBackground(BLACK); Draw();
DrawCircleV((Vector2){160.0f, 120.0f}, 120.0f, WHITE);
BeginMode3D(cam);
{
DrawModel(cube, Vector3Zero(), 1.0f, WHITE);
}
EndMode3D();
} }
EndTextureMode(); EndTextureMode();
@@ -91,3 +85,13 @@ void MainLoop() {
} }
EndDrawing(); EndDrawing();
} }
static void Draw() {
ClearBackground(BLACK);
DrawCircleV((Vector2){160.0f, 120.0f}, 120.0f, WHITE);
BeginMode3D(cam);
{
DrawModel(cube, Vector3Zero(), 1.0f, WHITE);
}
EndMode3D();
}

9
src/main.h Normal file
View File

@@ -0,0 +1,9 @@
#include "raylib.h"
extern RenderTexture2D target;
extern Image texImg;
extern Texture2D texture;
extern Camera3D cam;
extern Model cube;

11
src/update.c Normal file
View File

@@ -0,0 +1,11 @@
#include "update.h"
#include "main.h"
#include "raylib.h"
#include "raymath.h"
void Update() {
cube.transform =
MatrixMultiply(MatrixRotateXYZ(Vector3Scale((Vector3){1.0f, 1.5f, 2.5f},
GetFrameTime())),
cube.transform);
}

1
src/update.h Normal file
View File

@@ -0,0 +1 @@
extern void Update();