[Solved] pixel-perfect platform engine using loops

Get help using Construct 2

Post » Tue Apr 09, 2013 4:56 pm

@Ashley what did you have to do to the bounding box? Just adjust it in the sprite editor visually?
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Tue Apr 09, 2013 5:06 pm

Just right click, set to bounding box. That's the default collision polygon, it looks like that object was deliberately altered to have a one pixel sunk in collision mask.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Tue Apr 09, 2013 6:13 pm

@ashley I'm probably doing something wrong. I'd love to see your .capx

here's mine, with the built-in behavior:
https://dl.dropbox.com/u/28087823/Construct%20Examples/pixel-perfect%20engine%20with%20loops%20-%20no%20slope/C2platformmovement.capx
B
19
S
7
G
2
Posts: 188
Reputation: 2,846

Post » Tue Apr 09, 2013 6:33 pm

@christina - that .capx still uses the Sprite Font plugin.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Tue Apr 09, 2013 6:41 pm

@Ashley Apologies! Here's the one

https://dl.dropbox.com/u/28087823/Construct%20Examples/pixel-perfect%20engine%20with%20loops%20-%20no%20slope/platform2.capx
B
19
S
7
G
2
Posts: 188
Reputation: 2,846

Post » Tue Apr 09, 2013 7:36 pm

@christina - where do you see seams in that example? I don't see any.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Tue Apr 09, 2013 8:56 pm

@Ashley: no, no seams. There were never any. But two things:

1. ['player' starts off floating like this:] (edit: this was my bad)



2. 'player' can't get past this narrow corridor, is obstructed by the ceiling. Everything is laid out according to a 25x25px grid, so 'player' ought to be able to just squeeze through there.



It *can* apparently be fixed by making the bounding box one pixel shorter vertically, ending up with a 25x24px bounding box for a 25x25px sprite. But the same problem exists horizontally: 'player' can't squeeze through vertical corridors 25px wide, like so:



Which you'd argue can be fixed by making the bounding box one pixel shorter lengthwise. But it can't, because if I do that, then this happens: (one pixel gap)




Is this reproducible? Should I file a bug report? I'm fine with making a complicated engine that's tailor-made for my needs, I don't want to pile more work on your shoulders.christina2013-04-09 21:42:31
B
19
S
7
G
2
Posts: 188
Reputation: 2,846

Post » Tue Apr 09, 2013 10:38 pm

It's just that exact-sized gaps can't be moved through by the Platform behavior. If you shrink the bounding box it's still pixel perfect, but since the object can move further it shows a gap. Everything's working correctly and by design so far. (The player starts in the air because you placed them inside a solid, which confuses the behavior; place them over an empty space and they'll fall right down and work properly.)

Since you use pixel rounding, you can probably get away with making the bounding box just a tiny fraction of a pixel shorter horizontally and vertically. This will never let the player appear a pixel out of place, but still allow them to pass through exact sized gaps.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Wed Apr 10, 2013 12:37 am

@ashley That's good to know, thank you for taking all the time to help. I don't doubt the pixel-perfectness of the platform behavior, in fact it's proven itself. I'm just skeptical if it can do what I want it to do with the same accuracy and reproduceability.

Unfortunately, random behavior increased a lot when I did what you suggest. At least now we're closing in on the real issue.

This is the bounding box I used, just a fraction of a pixel smaller than 25x25px (I made a lot of different sized bounding box tests, all produced the same result)



(If you're certain a specific decimal will work, and I just haven't found it, then maybe we need decimal input support for the bounding box coordinates? I too discovered the cool properties of non-integer bounding boxes while making tests for my engine)

The problem is this; the 'player' sprite just stuck there for no reason for a good while and then dropped


Or even actively stayed on the wall, while I was pressing up and right;



These are all problems that got solved when working with loops... christina2013-04-10 00:37:43
B
19
S
7
G
2
Posts: 188
Reputation: 2,846

Post » Wed Apr 10, 2013 10:30 pm

@ashley plus I was thinking: it's not that complicated a code either, and it also simultaneously takes care of direction of animation.

If you'd rather you found an official workaround, I'm fine with it as well. Are you averse to me posting this as a fully commented example on the forum?

On the off-chance that someone is looking for a loop-based engine, since old-school games are often about that. I will comply whatever your decision.
B
19
S
7
G
2
Posts: 188
Reputation: 2,846

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests