mirror of
https://gitlab.com/raylibtemplates/rt.git
synced 2026-06-28 03:06:18 -04:00
Seperate update into new file
This commit is contained in:
30
src/main.c
30
src/main.c
@@ -1,6 +1,8 @@
|
||||
#include "main.h"
|
||||
#include "consts.h"
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "update.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -13,7 +15,8 @@
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
void MainLoop();
|
||||
static void MainLoop();
|
||||
static void Draw();
|
||||
|
||||
RenderTexture2D target;
|
||||
|
||||
@@ -56,25 +59,16 @@ int main(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainLoop() {
|
||||
static void MainLoop() {
|
||||
int winWidth = GetScreenWidth(), winHeight = GetScreenHeight();
|
||||
float scale =
|
||||
MIN((float)winWidth / SCREEN_WIDTH, (float)winHeight / SCREEN_HEIGHT);
|
||||
|
||||
cube.transform =
|
||||
MatrixMultiply(MatrixRotateXYZ(Vector3Scale((Vector3){1.0f, 1.5f, 2.5f},
|
||||
GetFrameTime())),
|
||||
cube.transform);
|
||||
Update();
|
||||
|
||||
BeginTextureMode(target);
|
||||
{
|
||||
ClearBackground(BLACK);
|
||||
DrawCircleV((Vector2){160.0f, 120.0f}, 120.0f, WHITE);
|
||||
BeginMode3D(cam);
|
||||
{
|
||||
DrawModel(cube, Vector3Zero(), 1.0f, WHITE);
|
||||
}
|
||||
EndMode3D();
|
||||
Draw();
|
||||
}
|
||||
EndTextureMode();
|
||||
|
||||
@@ -91,3 +85,13 @@ void MainLoop() {
|
||||
}
|
||||
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
9
src/main.h
Normal 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
11
src/update.c
Normal 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
1
src/update.h
Normal file
@@ -0,0 +1 @@
|
||||
extern void Update();
|
||||
Reference in New Issue
Block a user