Shooter: How to keep the player in position?

Get help using Construct 2

Post » Sat Sep 22, 2012 5:04 pm

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

B
66
S
25
G
30
Posts: 436
Reputation: 18,182

Post » Sat Sep 22, 2012 9:43 pm

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
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Sun Sep 23, 2012 12:36 pm

[QUOTE=keepee] This probably isn't the solution to the problem, but you should use *dt instead of /60.[/QUOTE]

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.
B
66
S
25
G
30
Posts: 436
Reputation: 18,182


Return to How do I....?

Who is online

Users browsing this forum: Calfuso, ETgirl79, totoe, Yahoo [Bot] and 14 guests