# Visual syncopation in position updates due to pixel rounding

Discussion and feedback on Construct 2

### » Tue May 17, 2016 9:52 pm

Naw, takes 1 event.
Make a family containing all moving objects.

Loop through them with a 'for each'
Set x to x + (x%2)
Set y to y + (y%2)

Dunno about the inpact on performance. But i expect it to draw quicker because the n^2 rule.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Tue May 17, 2016 10:11 pm

@99Instances2Go

whats the n^2 rule?

...and I'm confused... what would x +=x%2 do to change the stair stepping... I didn't try it but I don't understand why doing this would change it?
B
34
S
12
G
2
Posts: 566
Reputation: 5,282

### » Tue May 17, 2016 10:39 pm

ruskul wrote:
Prominent wrote:Couldn't you just create a family and put all the objects you want in them, then give it instance variables to record their x/y positions and compare them each frame and do any corrections if necessary?
So you'd shift them at the end of the events, and then restore their positions at the beginning of the events.
Idk.. just an idea i had.
But yeah, I only make low-res pixel games, so this sort of thing would be important to solve, as well as any other jitter related issues.

Thats 1 solution in a nut shell, but can be performance costly doing that via events depending on the type of game you are making.

99Instances2Go wrote:Naw, takes 1 event.
Make a family containing all moving objects.

Loop through them with a 'for each'
Set x to x + (x%2)
Set y to y + (y%2)

Dunno about the inpact on performance. But i expect it to draw quicker because the n^2 rule.
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Tue May 17, 2016 11:17 pm

hi pple ... to whom may concern,
the n^2 rule applies to audio i think... as i read and tested the capx shared in this post im not personally sure if that has anything to do with it. but more a problem of this rule Delta-Time and frame rate independence its not fixed when minimum FPS is under or equaling to 60 FPS however even if you apply the lerp(a,b,1-f^dt) or lerp(a,b,60*dt) still same thing its similar to just adding 0.25 or (60*dt)/4 ...

if i remember correctly the 2dcanvas cant process faster then the frame rate... so its impossible to not have jitters. even if solved 80% 20% will fail most of times.

this problem was raised before in other topics around years on forum... the answer was pretty much the same... back then ...

@ruskul ... instead of substracting 1 substract 0.75 or 0.5 or 0.25 its going to work ... you had it pretty good from start ... but the trail spawning doesn't happen everytime when it moves.. however the movement happens in stairs ... for green and 1 of the reds ... then the other of the reds will brake some times.

not sure if this old post is the right one but take a look r190 jitter problem maybe you find something useful

anyway im waiting for the plot-twist on C3 .... i bet will have some cool goodies inside the engine that fixes all this problems and the breaks in physics collisions.
B
86
S
26
G
75
Posts: 1,440
Reputation: 47,810

### » Thu Jun 30, 2016 7:22 pm

http://gamedev.stackexchange.com/questions/18787/how-does-one-avoid-the-staircase-effect-in-pixel-art-motion

This has a fix, found it while working with unity. Th op also does a better job explaining the problem too.
Last edited by ruskul on Thu Jun 30, 2016 8:35 pm, edited 1 time in total.
B
34
S
12
G
2
Posts: 566
Reputation: 5,282

### » Thu Jun 30, 2016 8:25 pm

So basically we need:
Code: Select all
`if ( abs(velocity.x) > abs(velocity.y) ) {    x = round(position.x);    y = round(position.y + (x - position.x) * velocity.y / velocity.x);} else {    y = round(position.y);    x = round(position.x + (y - position.y) * velocity.x / velocity.y);}`

In an interpolation expression.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » Sat Jul 02, 2016 5:05 am

@ruskul @newt

Nice! thanks for finding that article. That's awesome and works really well.

I tried it out in the original capx, you can see my version with the solution above here: http://www.rieperts.com/games/forum/TestsJitterDemonstration.capx
B
99
S
35
G
20
Posts: 438
Reputation: 17,960

Previous

### Who is online

Users browsing this forum: No registered users and 2 guests