SFML community forums
General => SFML projects => Topic started by: elwydd on May 05, 2014, 06:44:39 pm
-
Hello community, I'm a student from Switzerland, and we've to program a game in groups. We decided to program an Asteroids.
All what I know about C++ I learned while programming this game, so please be kind. :)
So right know most of it is running very smoothly but sometimes I get small lag spikes (100ms). As far as my measurements are correct they happen in the codelines where I draw the asteroids the background and the spaceship. The problem is I don't know why :)
I'm using the 2.1 sfml library which has the framerate limit. This one works fine but I'm not sure if its a clean way to have a stable clock for the whole system.
I'm not sure how I should upload the code that you can look at the code. I would be very happy if someone could look at it and give me some tips how I could improve the whole project.
At the moment there is no sound, no menu and so on (and no collision detection for the spaceship -that i can test the other parts of the project-) but this will all get into the project till June.
And now here is a video
www.youtube.com/watch?v=KCzkFRop6AQ
I know the bullets are sound symbols "shhh"
I hope you understand my English :)
-
Welcome to the forum!
The video looks good and I really like how you implemented the collision between the asteroids, maybe you could also put the weights into account, so it does look more realistic when they bounc of?
As for the lag spikes I couldn't see any and without any code we have no idea what could probably cause such an issue.
Are you using the elapsed time to update your stuff, or do you just use the frame limit? If you only use the frame limit, this could be a possible reason for your problem ;)
-
I'm not sure how I should upload the code that you can look at the code. I would be very happy if someone could look at it and give me some tips how I could improve the whole project.
Have you used git before? That'd be optimal.
-
Have you used git before? That'd be optimal.
Well never used it before but I think i could get it working.
Welcome to the forum!
The video looks good and I really like how you implemented the collision between the asteroids, maybe you could also put the weights into account, so it does look more realistic when they bounc of?
As for the lag spikes I couldn't see any and without any code we have no idea what could probably cause such an issue.
Are you using the elapsed time to update your stuff, or do you just use the frame limit? If you only use the frame limit, this could be a possible reason for your problem ;)
Well the collisions don't take the weight into account because I think it's easier to play with only one speed of asteroids. If I take the weight into account they'll end up with different speeds I believe :)
And no I don't update with the elapsed time. If I'm correct the frame limit should just wait until the 1/30 fps time is over then display it and after this the calculations for the updates should be done again. But If you tell me that this doesn't work like that and could end up in lagspikes sometimes (rly its just sometimes) then Ill perhaps change that.
Try to get git to work :)
what should i upload to git ? I'm using codeblocks so the project file won't help all of you, so should I upload this one ? Or should I just upload the Header, the .cpp files and the images?
-
Read these - please :)
http://gafferongames.com/game-physics/fix-your-timestep/
http://www.koonsolo.com/news/dewitters-gameloop/
http://gameprogrammingpatterns.com/game-loop.html
And remember that regardless of whether you use vsync (setVerticalSyncEnabled) (do that) or setFramerateLimit (do that if vsync doesn't work for some reason). Then the time between frames *will* vary and can vary quite a bit. This is due to many factors; one being the code you write yourself. Another being the OS scheduling granularity. Another being the hardware in any given machine. Another being other tasks that may be running at the same time. And loads more.
So never assume a steady frame rate. Read the articles above and deal with it.
-
This looks good, but you may want to specify where you got your art assets. I'm just saying this because those asteroids look vaguely familiar with another game that I know of.
-
This looks good, but you may want to specify where you got your art assets. I'm just saying this because those asteroids look vaguely familiar with another game that I know of.
Perhaps it wasn't the best idea to get it from google :O It's an image from Tavis Coburn out of the magazin wired.uk
-
Always respect copyright and licences and openly state where stuff came from.
Should be obvious, but unfortunately is not always.
-
Jup sorry forgot that. The game wasn't supposed to be available for anyone. And the images were for testing purposes. Well forgot that when I came here for some help.
Well then I'll delete the youtube video, and then I'll rewrite my game with an elapsedTime. Thread can be closed. cya