4
votes
3answers
232 views

Make openGL program only update every 1/60 seconds

I'm learning C++ and openGL and have this program as a result from tutorials and playing around. The problem is that the main loop is running at "full speed", making the program unnecessarily cpu ...
1
vote
3answers
285 views

How can I implement a main menu?

I have been following the tutorials at http://lazyfoo.net/tutorials/SDL/index.php and although they are all very well written and I have learned more than I would have on my own, I am not sure how to ...
1
vote
3answers
99 views

Why is my FPS computation yielding higher numbers than I expect?

I have following code: void Game::execute() { isExit = false; init(); double dt = 1.0 / 60.0; boost::timer timer; double accumulator = 0.0; boost::timer fps_timer; int ...
4
votes
3answers
1k views

Game loop on windows

I have seen different "basic" game loops both from books like "Introduction to 3D game programming with DX11" or online tutorial ( Rastertek ) and if we take off all the fancy stuff to control ...
1
vote
1answer
291 views

Mixing Objective-C and C++: Game Loop Parts

I'm trying to write all of my game in C++ except for drawing and game loop timing. Those parts are going to be in Objective-C for iOS. Right now, I have ViewController handling the update cycle, but ...
-2
votes
1answer
219 views

How to add difficulty levels to a Guess The Number game using rand()? [closed]

User guesses a random number (between 1 and 100 or 5000 and 25,000 depending on difficulty) that the computer picks. User selects difficulty from list, difficulty (1, 2, 3, 4) is assigned to int ...
0
votes
1answer
162 views

Removing drawn Allegro texts and primitives

I'm working on a game with Allegro 5 that has a loop. I'd like to make the program write onto the screen, how much time the loop has ended. These are the rounds of a turn-based game, obviously. I use ...
-1
votes
1answer
134 views

simple win32 window wont show [closed]

The program compiles and runs successfully but does not show a window, it simply ends immediately. #include <Windows.h> LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, ...
1
vote
1answer
903 views

CPU usage, game loop and sleep()

I've read about this topic on numerous discussion sites, but I can't seem to find a clear definitive (up-to-date) answer, and hopefully this will me some more insight: I've read the excellent game ...
1
vote
1answer
549 views

SDL2 focus lost = massive gain in FPS

Whenever I lose focus from my game window, I go from ~60FPS to 6000+, then when the window gains focus again, I go back to around 60 frames per second. And yes, this happens every time I run my game, ...
13
votes
3answers
857 views

Game loop, how to check for conditions once, do something, then not do it again

For example, I have a Game class and it keeps an int that tracks the player's lives. I have a conditional if ( mLives < 1 ) { // Do some work. } However this condition keeps firing and the ...
3
votes
2answers
3k views

Calculating Delta time , what is wrong?

For 2 days now i am trying to calculate the correct delta time for my game , I am starting to getting crazy since i tried all the solutions that i found on the 5 first google pages... What is wrong? I ...
2
votes
2answers
854 views

How to slow down a sprite that updates every frame?

I am going through a Allegro 5 tutorial which has a game loop. There is also a variable "active" which determines if a key is being held down. Thus if the left key is being held down active is on and ...
3
votes
1answer
947 views

Why is the framerate (fps) capped at 60?

ISSUE I recently moved a project from my laptop to my desktop(machine info below). On my laptop the exact same code displays the fps(and ms/f) correctly. On my desktop it does not. What I mean by ...
3
votes
2answers
421 views

Explaining Asteroids Movement code

I'm writing an Asteroids Atari clone, and I want to figure out how the AI for the asteroids is done. I have came across that piece of code, but I can't get what it does 100% if ...
3
votes
4answers
3k views

Most effective way to manage a gamestate system that is easy to use?

I just started working on my game, mostly the game management. I plan and using game-states to make the menu's and other stuff easier. My main idea for implementing the game-states is creating a game ...
0
votes
2answers
246 views

Effort of impementing interpolation in networked Asteroids

Questions: When we draw with interpolation, where should the collision detection code be? Is it worth implementing interpolation in the following situation? This is for Scrolling Asteroids. I have my ...
22
votes
2answers
3k views

Is it safe to use Sleep() in game loop (on Windows)?

Is it safe to use Sleep() function on Windows in game loop (C++)? I want to have fixed frame rate.
2
votes
1answer
397 views

How to wisely update body trajectories in a 3D space simulation game?

Suppose I have a Spacecraft object in 3D space, controllable by the player. I want it to update its own trajectory, so I give it a function for that (actually it might be inside a controller component ...
28
votes
3answers
2k views

Several classes need to access the same data, where should the data be declared?

I have a basic 2D tower defense game in C++. Each map is a separate class which inherits from GameState. The map delegates the logic and drawing code to each object in the game and sets data such as ...
4
votes
3answers
440 views

Synchronise graphics and logic code

I have a procedural approach to the game loop that runs various classes. it looks like this: continue any in progress animations check for used input apply AI move things resolve events such as ...
0
votes
2answers
621 views

Console Text game: Vertical Scroller collision problems

Alright so i'm making a vertical side scroller where you are an '8' character traveling downward while avoiding my randomly generated walls (the "generation" function) on the left and right sides of ...
-1
votes
3answers
2k views

C++ GameState management

I have been attempting to make a game engine in C++ and have come across the dilemma of game state management. I have done a lot of research and found numerous ways of accomplishing from game engine ...
4
votes
4answers
1k views

C++ Game engine time scale

i have begun creating a very simple game engine and i am trying to work out how to create a time scale for the game.by time scale i mean some way of increasing and decreasing the speed of the game(not ...
1
vote
1answer
2k views

C++ OpenGL Game Timer [duplicate]

Possible Duplicate: Tips for writing the main game loop? I am attempting to make a game using OpenGL and C++ but i haven't been able to find any good tutorials..or anything that could ...
15
votes
3answers
4k views

Finite state machine in C++

So, I've read a lot about using FSMs to do game state management, things like what an FSM is, and using a stack or set of states for building one. I've gone through all that. But I'm stuck at writing ...