Pixel Rounding Issue

Get help using Construct 2

Post » Sun Sep 08, 2013 2:25 pm

Hey guys, have done some searching and seems like others are having similar issues to myself but I couldn't see a concise answer that applied to my situation, so apologies if I missed something obvious.

I'm in the early stages of making a very low res platformer, and having troubles with pixel rounding. With it off, I get obvious visual artifacts on some of my sprites (some sort of texture wrap around?). If I turn it on, the visuals are fixed, but I get significant amounts of jitter around the player object. The player is an invisible hitbox with several sprites oriented to it (including the camera), and they appear to move slightly out of synch. Here are current builds with pixel rounding on/off:

OFF
https://dl.dropboxusercontent.com/u/58256916/Test/MiniQuestNPR/index.html
ON
https://dl.dropboxusercontent.com/u/58256916/Test/MiniQuestPR/index.html

A+D to move, J+K for jump/attack

Anyway feel like I'm probably missing something obvious here so much thanks in advance to anyone who takes the time to set me right.
B
8
S
1
G
1
Posts: 12
Reputation: 1,124

Post » Sun Sep 08, 2013 2:40 pm

I've had similar issues when sprites werent at exact locations, so for instance if sprite.x was 200.25 instead of 200.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Sep 08, 2013 3:35 pm

This bothers me too. I'm making a game based on Gameboy Color specs (160x144 resolution) and pixel rounding seems to be causing a lot of issues with jump-thrus. IE: run off the edge of a jump-thru then try to make your player fall back towards the jump-thru and they will teleport back on top of the platform.

@Ashley
What is the reasoning behind visual pixel rounding with floating point positions instead of integer-based positions? Is there any way to have all positions strictly integer-based?superdbop2013-09-08 15:35:48
B
16
S
2
G
4
Posts: 42
Reputation: 2,642

Post » Sun Sep 08, 2013 3:43 pm

@Saraqael Your game is SO CUTE. I really like the graphics.

I've been having a similar issue with my game, there's a weird jittering going on whenever the player is going left/right. I tried to track it down but I didn't think of turning pixel rounding on/off... I'll have to try it tonight.
B
124
S
43
G
41
Posts: 849
Reputation: 28,235

Post » Sun Sep 08, 2013 4:53 pm

Here's a quick capx to apply pixel rounding to the sprite's position.

https://dl.dropboxusercontent.com/u/161279569/construct2/forum/truepixelrounding.capx

Basically:
Every Tick
Player | Set Position round(Player.X), round(Player.Y)

As you can see in the example, solids seem to push the player up one pixel (bug?). I have pixel rounding turned OFF in the capx.

Edit:
I should also mention I was incorrect thinking the pixel rounding is affecting the jump-thru. The bug is still present in this example, even with the recommended one pixel height.


@Saraqael
How are you positioning the sprites to your hitbox? And can you post a capx? It doesn't have to be one of your game. A quick mockup with basic colored blocks will work. Maybe we can all help figure it out :)superdbop2013-09-08 17:08:06
B
16
S
2
G
4
Posts: 42
Reputation: 2,642

Post » Sun Sep 08, 2013 6:11 pm

@superdbop https://dl.dropboxusercontent.com/u/58256916/PRSC.png
I should probably have shown this from the start, there's a lot going on there. The player is split into multiple pieces that can be switched out or animated independantly (try attacking while running/jumping) and the outlines are also separated on a different layer to prevent certain overlaps. I also shuffle the layers a little during some animations. Ummm. This project was supposed to be an attempt at doing something less needlessly complicated than my usual fare, go figure. You might be interested to see the last thing I was playing around with, which also roughly uses the GB limitations (except scaled to the nearest even fit for 1080p), I never noticed these issues here but then it's also much simpler, maybe I'm just trying to do too much.
> https://dl.dropboxusercontent.com/u/58256916/Test/GBNew/index.html
I also tried a similar thing with all the art pre-scaled to 4x size, which seemed to work a bit better. That might be the way to go?

@andreyin Thanks! I'm first and foremost an artist, so I worry about visual considerations before anything else.. hence my terrible OCD character setup~
B
8
S
1
G
1
Posts: 12
Reputation: 1,124

Post » Sun Sep 08, 2013 7:03 pm

CC & C2 are simply not designed for low resolution games. Variable time step, no tiles (even though high res games use them too), floating points, etc. Pixel rounding also doesn't come into play when scaling or rotating - you get that "pixel art in a flash video" look.

Pretty funny because there aren't that many "modern" games being made them due to performance issues and until Spriter is finished you can only use sprites anyway.

Anyhow..."solutions"...Only way to prevent the shaking & seams w/ pixel rounding is to move your player by framerate*dt, but that only fixes it when moving strictly horizontally and is pretty stupid for obvious reasons. You can try putting the camera code before your player movement code but that will probably just shake the rest of the screen instead of the player. You can also try int() on your camera to prevent seams w/o pixel rounding but then you'll get more shaking. Adding 1px transparent borders around your platforms helps there but you can't do that with tiled BG objects.

Personally I just leave pixel-rounding off and use sprite objects acting as tiles (see:TMXimporter) then paste them to a canvas prior to destroying them, preventing seams.MadFactory2013-09-08 19:42:47
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Sun Sep 08, 2013 7:11 pm

@Saraqael

Hmm... Maybe try using the Pin behavior. This way, you can avoid imagepoints and pin your sprites On Start of Layout rather than setting the position every tick.

Or... Maybe the combination of Pin and the position rounding I mentioned earlier will allow you to stay pixel-perfect without the need to turn Pixel Rounding on? Just make sure the position is being rounded early in the Every Tick.

Hopefully someone else can help too. I'm still a Scirra newbie :D
B
16
S
2
G
4
Posts: 42
Reputation: 2,642

Post » Sun Sep 08, 2013 7:53 pm

@MadFactory

Would a camera following the sprite with lerp do the trick? I just thought of that and I'll give it a try when I arrive home, but I'm feeling it can at least solve something.

EDIT:

Now I thought about making JUST the tiles be pixel rounding dependent, while the animated sprites (like NPCs/player) do not depend on it. Is that plausible?Pancholo2013-09-08 20:26:40
B
13
S
5
G
1
Posts: 34
Reputation: 2,022

Post » Mon Sep 09, 2013 3:56 am

Hummm. Currently considering giving up, removing camera movement entirely, and having single screen maps, zelda style. I guess that's the fallback plan. Have messed around with some of these ideas but without much luck. I guess upscaling all the art externally to a higher resolution would make the issues far less visible, but that seems like a silly way to do things. A large part of the issue is that because the player sprite is made up of several components, the individual pieces end up disjointed from each other on random frames, so some of these solutions might otherwise work, but not here. Looking at "most acceptable alternative" for now, since it looks like I won't be able to get things exactly perfect without considerable effort.
B
8
S
1
G
1
Posts: 12
Reputation: 1,124

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests