0 Favourites

Shooter: How to keep the player in position?

  • I'm doing a vertical scrolling shooter, I'm using the huge layout/ scroll to/ move scroller object with bullet method.

    I basically took this from the Space Blaster example. In this very same example the player sticks to the background i.e. if you don't move him, he will move gradually towards the lower end of the screen.

    To compensate this and to keep him in place like in every arcade shooter I add a value to the player's Y-position per tick, I use

    Player: Set Y to Player.Y - (Scroller.Bullet.Speed / 60)

    I had assumed the tick frequency to be 60, which seems to be correct.

    Now this whole contraption *sort of* works, but not 100% correctly. I get a periodic micro-jitter of ~1 pixel sometimes, which I assume is a rounding problem somewhere.

    So.... how to do this correctly (and keep it relative to the Bullet-speed of the Scroller object which I might need to alter the scrolling speed)?

    Others seem to have done it, the Project Blaze Zero shooter looks 100% in sync to me <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • This probably isn't the solution to the problem, but you should use *dt instead of /60.

    dt stands for delta time and is the amount of time (in seconds) since the last tick... so it'll change with any frame rate dipping.

    Micro-jitter of 1 pixel makes me think of the 'pixel-rounding' project property. Other than that I'd suggest posting your capx

  • This probably isn't the solution to the problem, but you should use *dt instead of /60.

    In fact, it is..

    I was unaware of the dt-variable, using it fixed the jitter. So what I was seeing was basically the result of a small wobble in the framerate, not a rounding issue.

    Now everything is fine.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
[plugin] Youtube player
175 20,538
rexrainbow's avatar
rexrainbow
Unread hot topic
95 14,384
LaurenceBedford's avatar
LaurenceBedford
Unread hot topic
0 Favourites
Keep me logged in.
66 5,736
grigrizljac's avatar
grigrizljac