-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
56 lines (42 loc) · 1.49 KB
/
Main.cpp
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
// Game Engine For Upcoming Simulation game with nick!
//Mitchell Marsh
#include "Scene.h"
class State; // this is what will keep track of which frame the scene is rendering to and from
// this manages the scene class ^^^^^
//class Scene / GameObject / Component--- this will contian a bunch of object stuff
long float getTimeInSeconds(); // maybe replace with gettime? Think about this!
int main()
{
bool quit = false;
double t = 0.0;
double dt = 0.01;
double currentTime = getTimeInSeconds();
double accumulator = 0.0;
State previousState;
State currentState;
while (!quit)
{
double newTime = getTimeInSeconds();
double frameTime = newTime - currentTime;
if (frameTime > 0.25)
frameTime = 0.25;
currentTime = newTime;
accumulator += frameTime;
while (accumulator >= dt)
{
previousState = currentState; //The state/scene is the same
//Do Calculaitons here CALC(); Which invlove an update que!
t += dt;
accumulator -= dt;
}
const double alpha = accumulator / dt;
//This blends the scenes together, allowing for smooth transition
/* Below is for real time drawing only
//BELOW: returns an alpha value between the old state and new: the new State is drawn onto the old using the alpha value!
//this is true until the new state is caught up
State stateAlpha = currentState * alpha +
previousState * (1.0 - alpha);
*/
//render(scene); //or draw in the case of the console
}
}