feature/imgui-sdl
points-test
Last change
on this file since 6d95ade was 0807aeb, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago |
Spawn asteroids at a regular interval and make them move in the player's direction, change the movement of all game objects to depend on elapsed time and be framerate-independent, and switch from SDL2 timers to the C++ chrono library
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | #include "utils.hpp"
|
---|
2 |
|
---|
3 | #include <ctime>
|
---|
4 | #include <iostream>
|
---|
5 |
|
---|
6 | #include "compiler.hpp"
|
---|
7 |
|
---|
8 | #ifdef WINDOWS
|
---|
9 | #include <process.h>
|
---|
10 | #else
|
---|
11 | #include <unistd.h>
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | // TODO: Use a more modern method of generating random numbers
|
---|
15 |
|
---|
16 | void seedRandomNums() {
|
---|
17 | #ifdef WINDOWS
|
---|
18 | srand(_getpid() ^ time(nullptr));
|
---|
19 | #else
|
---|
20 | srand(getpid() ^ time(nullptr));
|
---|
21 | #endif
|
---|
22 | }
|
---|
23 |
|
---|
24 | float getRandomNum(float low, float high) {
|
---|
25 | return low + ((float)rand() / RAND_MAX) * (high - low);
|
---|
26 | }
|
---|
27 |
|
---|
28 | void printVec3(string label, const vec3& v) {
|
---|
29 | cout << label << " -> (" << v.x << "," << v.y << "," << v.z << ")" << endl;
|
---|
30 | }
|
---|
31 |
|
---|
32 | void printVec4(string label, const vec4& v) {
|
---|
33 | cout << label << " -> (" << v.x << "," << v.y << "," << v.z << "," << v.w << ")" << endl;
|
---|
34 | }
|
---|
35 |
|
---|
36 | void printMat4(string label, const mat4& m) {
|
---|
37 | cout << label << ": " << endl;
|
---|
38 | cout << "[ " << m[0][0] << " " << m[1][0] << " " << m[2][0] << " " << m[3][0] << " ]" << endl;
|
---|
39 | cout << "[ " << m[0][1] << " " << m[1][1] << " " << m[2][1] << " " << m[3][1] << " ]" << endl;
|
---|
40 | cout << "[ " << m[0][2] << " " << m[1][2] << " " << m[2][2] << " " << m[3][2] << " ]" << endl;
|
---|
41 | cout << "[ " << m[0][3] << " " << m[1][3] << " " << m[2][3] << " " << m[3][3] << " ]" << endl;
|
---|
42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.