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

Author Topic: My first space shooter  (Read 15304 times)

0 Members and 1 Guest are viewing this topic.

blojayble

  • Newbie
  • *
  • Posts: 19
  • whoa
    • View Profile
Re: My first space shooter
« Reply #15 on: August 31, 2013, 07:58:30 pm »
Hi. Your game is simple and fun, but while playing I found a way to cheat a bit.

When you're playing, hold the window bar with a mouse like you would like to move it, and wait like this for a bit. The game will freeze, but music will be still playing. When game is like this, spaceship will be "moving", but no collisions will be detected.

If you want to fix it, put the event loop to other thread, I've got my own fix, if you're interested.

Good luck with improving the game!
0 bottles of beer on the wall,
0 bottles of beer!
Take one down, pass it around,
4,294,967,295 bottles of beer on the wall!

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: My first space shooter
« Reply #16 on: August 31, 2013, 08:28:55 pm »
When you're playing, hold the window bar with a mouse like you would like to move it, and wait like this for a bit. The game will freeze, but music will be still playing. When game is like this, spaceship will be "moving", but no collisions will be detected.

If you want to fix it, put the event loop to other thread.

Actually that is not a good way to fix the problem. The best way would be to directly fix the problem instead of working around it.

What this problem is commonly known as is called tunneling. When you click and hold the title bar the game loop is temporarily paused, but continues to track elapsed time. After you release mouse the game loop will resume and the time elapsed will be such a large number that the ship has had enough time that it would be past the objects it should have collided with.

The way to fix this has a simple solution. You can implement a fixed time step which will cause your code to do multiple updates when a large amount of time has passed instead one huge update. The huge update is what allows the ship to pass through objects is called tunneling.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

blojayble

  • Newbie
  • *
  • Posts: 19
  • whoa
    • View Profile
Re: My first space shooter
« Reply #17 on: August 31, 2013, 10:01:43 pm »
@Up

Yes, you're right. I just mainly thought about fixing the freezing, also as problem with detecting collisions is the other thing.
0 bottles of beer on the wall,
0 bottles of beer!
Take one down, pass it around,
4,294,967,295 bottles of beer on the wall!

voodinator

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: My first space shooter
« Reply #18 on: September 26, 2013, 06:33:00 pm »
Can you make an reup? The Dropbox file is down, would like to test the game :)