-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (42 loc) · 1.08 KB
/
main.c
File metadata and controls
53 lines (42 loc) · 1.08 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
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "state.h"
#include "particles/particles.h"
// Global state variable
struct State state;
void init() {
srand(time(NULL));
init_particles();
init_renderer();
}
void destroy() {
destroy_particles();
glfwTerminate();
}
void update() {
printf("Frames: %llu\n", window.fps);
if (!state.window->keyboard.keys[GLFW_KEY_SPACE].down) {
update_particles();
did_particles_collide();
}
if (state.window->keyboard.keys[GLFW_KEY_R].down) {
destroy_particles();
init_particles();
}
}
void render_() {
glClear(GL_COLOR_BUFFER_BIT);
for (int i = 0; i < state.particle_count; i++) {
if (state.particles[i].active) {
state.render->draw_circle(state.particles[i].position.x, state.particles[i].position.y, state.particles[i].radius, 100, state.particles[i].color);
}
}
}
int main() {
state.window = &window;
state.render = &render;
window_create(init, destroy, NULL, update, render_);
window_loop();
return 0;
}