I have some difficulties to understand how to correctly use GetTickCount() as I have some problems in my little game. I have to place on a case a space ship. This one will shoot with a certain frequence some missiles.
Edit: It works good now, I edit the code below. However there is an other problem, I don't know why there is only one shooting space ship.
I hope someone has an explanation for that.
MyGameEngine::MyGameEngine(...) : tickTime(0) {} // for the constructor... DWORD prev_frame_tick; DWORD curr_frame_tick = GetTickCount(); // function called everytime (loop) void MyGameEngine::idle() { prev_frame_tick = curr_frame_tick; curr_frame_tick = GetTickCount(); tickTime += curr_frame_tick - prev_frame_tick; int i; // SPACE SHIP for (i = 0; i < ship->size(); i++) { // verify if tickTime > freqShoot : if true return new missile with correct positions Missile* m = ship->at(i)->tick(tickTime); if (m != NULL) { missiles->push_back(m); std::cout << "new miss" << std::endl; // I have to put this, however nothing on screen tickTime = 0; } } // MISSILES ANIMATION for (i = 0; i < missiles->size(); i++) { missiles->at(i)->tick(); if (missiles->at(i)->getBordDroitX() > 1.0f) { missiles->erase(missiles->begin() + i); } } } Missile* Ship::tick(DWORD t) { Missile* m = NULL; if (t > freqTir) { m = new Missile(posX, posY, width, height, numCase); } return m; }