feature/imgui-sdl
Last change
on this file since e1f88a9 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
|
Rev | Line | |
---|
[203ab1b] | 1 | #include "utils.hpp"
|
---|
[a23fc08] | 2 |
|
---|
[0807aeb] | 3 | #include <ctime>
|
---|
[a23fc08] | 4 | #include <iostream>
|
---|
| 5 |
|
---|
[0807aeb] | 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 |
|
---|
[a23fc08] | 24 | float getRandomNum(float low, float high) {
|
---|
[0807aeb] | 25 | return low + ((float)rand() / RAND_MAX) * (high - low);
|
---|
[a23fc08] | 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;
|
---|
[203ab1b] | 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.