-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraylibeditor.c
More file actions
101 lines (85 loc) · 2.68 KB
/
raylibeditor.c
File metadata and controls
101 lines (85 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*******************************************************************************************
*
* raylib [core] example - Basic window
*
* Welcome to raylib!
*
* To test examples in Notepad++, provided with default raylib installer package,
* just press F6 and run [raylib_compile_execute] script, it will compile and execute.
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on [C:\raylib\raylib\examples] directory and
* raylib official webpage: [www.raylib.com]
*
* Enjoy using raylib. :)
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2013-2020 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include "raylibeditor.h"
#include "moduleLoop.h"
#include "splash.h"
#include "menu.h"
#include "gameplay.h"
void ExitGame()//todo: free memory from modules on abrupt exits.
{
canExit = 1;
}
void ScaleVec2(Vector2 *result, Vector2 *point, Vector2 *oldRes, Vector2 *newRes)
{
int x = ( ((*newRes).x * (*point).x )) / (*oldRes).x;
int y = ( ((*newRes).y * (*point).y )) / (*oldRes).y;
(*result).x = x;
(*result).y = y;
}
void SetModule(enum ModulePhase mp)
{
if (mp == MENU)
{
MenuInit();
}
else if (mp == GAMEPLAY)
{
GameplayInit();
}
else if (mp == SPLASH)
{
SplashInit();
}
}
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
defaultRes.x = 800;
defaultRes.y = 450;
canExit = 0;
//enum ModulePhase phase = SPLASH;
InitWindow(defaultRes.x, defaultRes.y, "raylibeditor");
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
InitAudioDevice();
//--------------------------------------------------------------------------------------
//SetModule(SPLASH);
SetModule(GAMEPLAY);//direct for testing
// Main game loop
while (canExit == 0)
{
// Update
//----------------------------------------------------------------------------------
// TODO: Update your variables here
//----------------------------------------------------------------------------------
dt.deltaTime = GetFrameTime();
dt.elapsedTime += dt.deltaTime;
// Draw
//----------------------------------------------------------------------------------
ModuleLoop();
//----------------------------------------------------------------------------------
}
CloseAudioDevice();
CloseWindow();
return 0;
}