Parallax Background Issues

For questions about using Classic.

Post » Tue Mar 27, 2012 5:51 pm

I've made a quick video to show the problem, viewable here.

I'm starting to throw things together to see what works. It's all work in progress of course, animations, sprites, textures, blah blah blah the usual "please don't crucify my artwork just yet" comments

I have two issues with the scrolling background at the moment. The first is that it always seems to 'snap' to the edge of the screen, and 'snap' out again when I move away from the edge. I could always have the player's starting position sufficiently into the level so that the edge of the screen is never encountered, but I would rather figure out what's causing the issue and learn how to avoid it in the future.

Secondly, the Y axis looks a little funky. I think it's because all the layers are set to 100% Y scroll speed, so my eye is telling me that it looks odd since they all move up or down at the same speed - whereas they should be slightly offset. However, changing the Y axis scroll speed led to my background appearing at odd locations (I could just about see the tops of the trees. The rest of the background was buried below the player's position).

Any advice on how to deal with Parallax backgrounds? The only tutorials I could find were for C2.

Bonus Question: Those tree roots my wolf runs right over? I want them to have collision detection. Easy enough - I've created small invisible boxes with the 'solid' attribute, the standard approach in CC platformers. But what I also want to do is have a sprint ability where holding down Left Shift makes the wolf run faster and ignore small obstacles like the tree roots, running right over them unhindered. I looked for a way to disable the solid attribute through events, but couldn't see the option. Eg:

Left Shift button is down --> Obstacle: Disable Solid Attribute
Left Shift button is released --> Obstacle: Enable Solid Attribute


Is there any way to achieve this?

Many thanks for reading, and for any advice you can provide
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Tue Mar 27, 2012 8:51 pm

I don't know if you use images or build the parallax layers with lots of sprites.

I've used looping images all my dev years and all I do is "set X to ScrollXLeft/2" and such. Super-simple, but only really good for smaller and undynamic textures.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Tue Mar 27, 2012 10:12 pm

They are looping images, yes. I have four large images with transparency (png files) each on their own layer. I then have each layer set to scroll 10% slower than the layer in front. So the first background layer scrolls at 90% speed, the second at 80%, etc.

You can only see the first two layers of the background in the video. The third and fourth are of the tree tops leading into the distance, viewable when the player reaches higher sections of the level. I then want a FIFTH layer showing mountains in the really far distance.

They're large images (each 2048 pixels wide, and either 1024 or 2048 high) so I might have to cut back on the ambition in order to save VRAM. I'm testing it on three different systems, and so far getting smooth gameplay on all three. It's early days though, and I've obviously got a heck of a lot more to add before it's anything like a playable game.
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Wed Mar 28, 2012 6:20 am

Set your layout scrolling properties to unbounded, and it will get rid of the snapping. Then use invisible walls or something to prevent leaving the layout/seeing black edges.

Sadly, setting the scroll speed % is probably the best way I've found of handling parallax. It does mean you'll need trial and error to make your maps, or create an in-game map creator though.

As for the bonus question, maybe have private variables for each object storing their start/old X and Y. When sprinting, move them to -10000,-10000 or whatever and then place them back at their starting/old X and Y when done. Have to make sure the player doesn't stop sprinting in the middle of one though I guess.

As for the image sizes, can you break them into smaller tiles? Like 512 by 256 or 512? It does mean lower quality images if you choose to just shrink the graphics and scale them up in-game though.

These are fairly short answers, so any further explaining I'd be happy to give when I next have time. Hope this helps though.Jayjay2012-03-28 06:22:01
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Mar 28, 2012 12:41 pm

Haha! Oh man...

So I've checked the unbounded scrolling box, and used an invisible wall to stop the player getting in view of the black edges. Pretty much exactly the same solution I already had: starting the player roughly 1000 pixels into the level and using an invisible wall. But I may as well tick the unbounded option too in case someone with an insane screen resolution plays. Better to see a black edge than have snapping backgrounds.

I've also had to bite the bullet and just learn through trial and error where the backgrounds need to be placed on the Y axis when using varying Y scroll speeds. Took a while, but it's all working well on various resolutions now (from 1280x720, right up to 1920x1080), so yay!

The crazy issue now is the bonus question(!) I asked about. Thanks to JayJay I got the Obstacle boxes to vanish and appear at will. But his guess about the issues that would lead to were a little off:

"Have to make sure the player doesn't stop sprinting in the middle of one though I guess."

Stopping in the middle turns out to be fine. The player just gets moved up a bit as the object appears from beneath him. Nothing catastrophic there. But... Pressing the shift button to start sprinting while already on top of an obstacle (such as a big tree root) not only teleports the obstacle box off the screen, but also takes the player along for the ride

Time for some coffee. My brain hates problem solving without a caffeine injection.
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Wed Mar 28, 2012 1:35 pm

MY FRIEND TO DISABLE A COLLISION WITH THE USE SOLID OBJECTS IN ITS SPRINTES IVISIVEIS VARIABLES VARIABLE VARIABLE IMPACT ABILITA a "0" DISABLE COLLISION ... IF YOU NEED HELP COMMAND A TUTORIAL.
ramosalvaro

MEU AMIGO PARA DESABILITAR A COLISO COM OS OBJETOS SOLIDOS UTILIZE VARIAVEIS EM SEUS SPRINTES IVISIVEIS VARIAVEL 1 ABILITA COLISO VARIAVEL" 0" DESABILITA COLISO...SE PRECISAR DE AJUDA TE MANDO UM TUTORIAL.
ramosalvaro
B
24
S
3
G
2
Posts: 10
Reputation: 4,610

Post » Wed Mar 28, 2012 4:14 pm

Glad to hear it's mostly working. Maybe try using a private variable system for the player too, so they are set to the exact position they started in right after the box is moved?

Either that, or try moving the box down and right out of the map, so that it doesn't "pull up" on the player, as the platform movement tries to ride anything that moves above it.

Still, that bug could turn out to be a really cool feature when making rocket elevators/teleport lifts in games, just move the block the player stands on and they go with it!
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Wed Mar 28, 2012 5:43 pm

[QUOTE=Jayjay]Still, that bug could turn out to be a really cool feature when making rocket elevators/teleport lifts in games, just move the block the player stands on and they go with it![/QUOTE]

This is true! Thanks for your help with the other issues. Guess this one is just going to take more experimentation than usual before I get it working well.

Sounds like Ramosalvaro knows the answer!

But he only speaks Caps Lock Spanish -Silver-2012-03-28 17:44:16
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Wed Mar 28, 2012 6:56 pm

No problem -Silver- glad to help! I think moving the box to +10000, +10000 should work, then it doesn't try to move through the player.

Hopefully that'll work out for you!
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests