Hot answers tagged

15

By waiting for key-down events to be fired, you are likely at the mercy of the key event repeat rate that the OS controls (and which users can specify themselves). Instead, you may want to call SDL_GetKeyboardState at the top of your game update loop (the part of the update that happens every frame, whether or not an event has come in) to get the state of ...


8

An alternative way (Josh's approach is great too!) would be to setup an boolean on SDL_KEYDOWN, and possibly also ignoring all repeated key events. That you can do by checking the repeat member of the key event. Then you could implement your own timer, which doesn't have to be anything fancy, and implement key repetition your self. You could either trigger ...


3

It's only a matter of opinion and code style. You can use: GL_TRUE and GL_FALSE true and false 1 and 0 Or anything that can be converted to 1 and 0. They all may have different types, but usually it does not matter because they all will be implicitly converted to GLboolean upon use. Use whatever you want, any of them will work. My only advice would be ...


2

The theory will tell that you're likely to get less cache misses (so 'more efficiency' w.r.t. response time) if your objects are close one to another in memory. This means that if you use an array, and your objects are contiguous, and you access each of them in a in-memory-sequential fashion, it will be more efficient than if you hop from here to there and ...


1

I need somehow to delay an initialization of other level's entities Why not add an init() and a terminate() methods to your Level class that does just that? init() populates your level when you're ready to play it, and terminate() cleans everything up when you're done with it. You might want to consider changing your architecture to have Level created ...


1

You are fixing the time to 10(seconds?), so it will always takke it 10 seconds to reach its target. So if its a short distance, the bullet will move very slow and over a long distance the bullet will move very fast. So you need to set the time to (distance)/(velocity).



Only top voted, non community-wiki answers of a minimum length are eligible