[SOLVED]: Retro pixel-quantized platform engine using loops

Get help using Construct 2

Post » Wed Apr 29, 2015 10:48 am

EDIT: DONE! This is a working engine. Huge thanks to @Magistross @retrodude and @newt

Image

[url=https://drive.google.com/file/d/0B6_Uw_-Ku5yISnlPNG9URXIxcVE/view?usp=sharing[/url]Features:
* Always integer pixel positions
* Always fall down when trying to cross a gap of equal width to the player, at any horizontal speed
* Jumpthrough platforms
* loop-based movement
* framerate independent (takes dt into account)
* controllable speed (no acceleration, on/off)
* collision detection with walls

_______________
Original Post:
So I revisited this ( [url]https://www.scirra.com/forum/viewtopic.php?f=147&t=81757[/url]). It's a very old-school platform engine suitable for pixel games, that moves the player one pixel at a time using loops, always integer positions (unlike the built-in platform behavior). The player can fit inside gaps that are the same size as itself without horizontal or vertical wiggle room.

One thing I haven't been able to fix is falling through gaps when moving. If player.horizontalSpeed is high enough, player never registers the gap under its feet.

I could try to solve this by using @R0J0hound 's solution https://www.scirra.com/forum/how-do-i-fall-between-blocks_t125214?&hilit=platform+gaps, since horizontal walls work flawlessly with this engine.

However I wonder if it can be solved another way, since there's already a loop in place. Anyone?

Here is the CAPX:
CAPX
Last edited by christina on Sun Jun 04, 2017 11:11 pm, edited 6 times in total.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Wed Apr 29, 2015 11:11 am

Well, I think you're making it harder than it needs to be.
For one, what about using the custom movement behavior and just working with integer values?

Then, about the gap issue, I'd use an FSM to solve it

if (player.state === "running")
--- move him on the x axis first and push him out of solids to the nearest available position.
--- then check if he's on the ground to determine whether or not the character should go to the falling state

Or you can use a collider that's a bit longer than the character and that you use for collisions when the player is running.
In any case, even if you shouldn't use the official platform behavior, there's a nice plugin available on the forums (platform + i think) as well as the custom movement behavior to do the job.

Good luck!
B
79
S
22
G
4
Posts: 311
Reputation: 12,774

Post » Wed Apr 29, 2015 11:28 am

@Valerien I'm trying that right now :) Thank you!
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Wed Apr 29, 2015 3:29 pm

I modified the capx a bit. Unified the loop, and added an event to force the y movement to happen if the player is moving horizontally while "floating".
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Wed Apr 29, 2015 5:21 pm

@Magistross again, pure genius. Thank you! I couldn't see where to place that condition for the y axis.

Ok, this is a pretty robust engine for games like Bubble Bobble, Rick Dangerous and the like. I'm calling it done.

@Valerien I tried with the custom movement. Try as I might, I can't get it to increment by integer amounts of pixels. It always has a floating point. Can you get it to behave? The only way I know how is to control XY position using loops.
Last edited by christina on Wed Apr 29, 2015 6:19 pm, edited 1 time in total.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Wed Apr 29, 2015 5:41 pm

The loops first had to be unified, that's why you couldn't see it ! ;)
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Wed Apr 29, 2015 5:56 pm

When I grow up I want to be just as math-savvy as you
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Wed Apr 29, 2015 6:44 pm

@Magistross When I grow up I want to be just as math-savvy as you

Playtesting this, I see it doesn't play well with tight corners, damn.
Here I'm trying to go left past the gap, but it won't let me. Any idea how to fix this?

Image

I mean it's pretty much done, and I could make the player 1 pixel shorter, but this is theoretical curiosity for me now.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Wed Apr 29, 2015 7:24 pm

Sounds like what your engine needs is edge nudging,
a kind of "behind the scenes help".
its pretty much because the player is falling at such a speed where one frame he is above the hole and the next he is below the hole a solid (the left wall in that instance) is always colliding with the player.

you need to check when ever the player is not on the ground and wall is to left or right is there an open space or closed space and if open "boost" (or move) the player into that open space. i do it with the built in platform behavior all the time. it pretty much just checks on grid the game is built on (normaly 16x16 if pixel art) one above one below the player -8 as the speed i had was the player would fall past at a speed that made him only ever infront of the opening and half the grid height. if the check returned an open tile the player would move into it i also had a variable to ensure it only happened once per jump (would have to land on the floor again before it reset and would "boost" the player again) to not let the player know this was happening.

Ledge forgiveness is the same, in pixel games the characters sometimes move faster than the grid lines up making the player think they pressed jump when they were on the floor but in reality the player moved so fast they pressed it after the player left the platform but had yet to begin decent. in this instance i would have events in place to still have the jump action performed so the player would not feel like "this game is cheap and just didn't let me jump"

so while the engine is good, extra things can go in to help it. if i get time later i can try and look at the capx and see if i can add edge nudging.
B
26
S
7
G
1
Posts: 83
Reputation: 2,575

Post » Wed Apr 29, 2015 7:35 pm

Try removing the "player: Set xLoopIndex to 0 " on line 21. It seems to do the trick... most of the time :\
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Next

Return to How do I....?

Who is online

Users browsing this forum: adventurist, Artcadev, Blendi1223, PROxMTswatTR and 27 guests