-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·67 lines (47 loc) · 1.28 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
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include "SDL2/SDL.h"
#include <math.h>
#include "screen.h"
#include <stdlib.h>
#include <time.h>
#include "Swarm.h"
using std::cout;
using std::endl;
using namespace first;
int main()
{
srand(time(NULL));
Screen screen;
if (screen.init() == false)
{
cout << "Error initialist SDL." << endl;
}
Swarm swarm;
bool quit = false;
while (true)
{
int elapsed = SDL_GetTicks();
// screen.clear();
swarm.update(elapsed);
unsigned char green = (1 + sin(elapsed * 0.0001)) * 128;
unsigned char red = (1 + sin(elapsed * 0.0002)) * 128;
unsigned char blue = (1 + sin(elapsed * 0.0003)) * 128;
const particle *const pParticles = swarm.getparticles();
for (int i = 0; i < Swarm::NPARTICLES; i++)
{
particle particles = pParticles[i];
int x = (particles.m_x + 1) * (Screen::SCREEN_WIDTH / 2);
int y = particles.m_y * Screen::SCREEN_WIDTH / 2 + Screen::SCREEN_HEIGHT / 2;
screen.setPixel(x, y, red, green, blue);
}
screen.boxBlur();
// Draw the Screen
screen.update();
if (screen.processEvents() == false)
{
break;
}
}
screen.close();
return 0;
}