Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: And again another Asteroids clone  (Read 4288 times)

0 Members and 1 Guest are viewing this topic.

elwydd

  • Newbie
  • *
  • Posts: 9
    • View Profile
And again another Asteroids clone
« 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


I know the bullets are sound symbols "shhh"

I hope you understand my English :)




Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: And again another Asteroids clone
« Reply #1 on: May 05, 2014, 07:16:54 pm »
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 ;)
Failing to succeed does not mean failing to progress!

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: And again another Asteroids clone
« Reply #2 on: May 05, 2014, 07:39:36 pm »
Quote
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.

elwydd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: And again another Asteroids clone
« Reply #3 on: May 05, 2014, 08:13:07 pm »
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?
« Last Edit: May 05, 2014, 08:30:42 pm by elwydd »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: And again another Asteroids clone
« Reply #4 on: May 05, 2014, 08:25:26 pm »
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.
« Last Edit: May 05, 2014, 08:31:20 pm by Jesper Juhl »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: And again another Asteroids clone
« Reply #5 on: May 05, 2014, 08:54:34 pm »
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.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

elwydd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: And again another Asteroids clone
« Reply #6 on: May 05, 2014, 09:37:13 pm »
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

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: And again another Asteroids clone
« Reply #7 on: May 05, 2014, 09:43:57 pm »
Always respect copyright and licences and openly state where stuff came from.
Should be obvious, but unfortunately is not always.

elwydd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: And again another Asteroids clone
« Reply #8 on: May 05, 2014, 09:49:18 pm »
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
« Last Edit: May 05, 2014, 10:51:32 pm by elwydd »