Changeset 0807aeb in opengl-game for utils.cpp


Ignore:
Timestamp:
Mar 10, 2020, 2:53:34 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
22217d4
Parents:
44f23af
git-author:
Dmitry Portnoy <dmp1488@…> (03/10/20 00:43:57)
git-committer:
Dmitry Portnoy <dmp1488@…> (03/10/20 02:53:34)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • utils.cpp

    r44f23af r0807aeb  
    11#include "utils.hpp"
    22
     3#include <ctime>
    34#include <iostream>
    45
     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
     16void seedRandomNums() {
     17#ifdef WINDOWS
     18   srand(_getpid() ^ time(nullptr));
     19#else
     20   srand(getpid() ^ time(nullptr));
     21#endif
     22}
     23
    524float getRandomNum(float low, float high) {
    6    return low + ((float)rand() / RAND_MAX) * (high-low);
     25   return low + ((float)rand() / RAND_MAX) * (high - low);
    726}
    827
Note: See TracChangeset for help on using the changeset viewer.