infinite scrolling

For questions about using Classic.

Post » Fri Jan 09, 2009 9:07 am

Hello,

I have a concept for a driving game that requires a neverending landscape, that wraps around seamlessly as the player drives.

I thought you might be able to do this by adding something like, car.x > layout width, then set car.x to 0. And as the camera scrolls to the player location it would cut straight back with him hopefully without the player noticing as the backgrounds meet up. Also I set the layout to unbounded scrolling.

This seems to create a pop, when the player transports 0.

I've also got a camera zoom effect, where the faster the player goes the furthur back the camera zooms. Works great, but with the infinite scrolling on, this makes the pop even worse, and also adds some completely mental things in the middle. Like the car suddenly driving upside down.

Any ideas of how to pull this off?

The file is here: [url:wfspqxgh]http://www.mukpuddy.com/timtests/mukbuggy2.cap[/url:wfspqxgh]

I've tried to comment it as much as possible so it's clear.

Thanks a million
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Post » Fri Jan 09, 2009 2:42 pm

try checking on unbounded scrolling.
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Fri Jan 09, 2009 2:49 pm

I think the easiest way would be to enable unbounded scrolling to allow the camera to scroll outside the layout, then add a copy of a little bit of the part of the track that you're looping back to outside the layout in the appropriate position. Here's what I mean in a CAP: Infinite scrolling

I hope that helps, and I hope it's fairly easy to understand. :)
Moderator
B
98
S
36
G
19
Posts: 1,584
Reputation: 17,717

Post » Fri Jan 09, 2009 6:11 pm

Honestly I'm not sure if you can pull off seamless infinite scrolling with your physics game in that manner... there are so many complex things going on at once what with the physics and the motion blur that it seems to me you'd always have at least a little bit of a jolt when resetting it. I'm not saying it's impossible, just that... well I know I wouldn't even try except on something much less complex like linkman's example.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 09, 2009 6:33 pm

The zooming would definitely cause problems, but I think it would work fine otherwise. Also, I checked with my own example and motion blur actually isn't affected by the jump back to the other side of the screen. Physics would probably be fine as well.
Moderator
B
98
S
36
G
19
Posts: 1,584
Reputation: 17,717

Post » Fri Jan 09, 2009 6:37 pm

Maybe I'm just thinking it would be harder than it actually would be.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jan 09, 2009 7:43 pm

[quote="Squeemish":17wk3hud]I thought you might be able to do this by adding something like, car.x > layout width, then set car.x to 0[/quote:17wk3hud]
You should use unbounded scrolling, but you should still have some kind of wrapping system like this: the further you get away from the 0,0 origin, the less accurate the floating point values that hold the coordinates become. Still, you can be fairly generous and have say 10-50k pixels before you wrap. You'll need it to be a multiple of the width of any tiled background images you use for it to be seamless.

Setting the X to 0 is going to stutter, because it makes no provision for how much further beyond the layout width you've gone (it still goes to X=0 even if you've gone 1 or 100 pixels over the edge). To fix this, subtract the layout width from the X co-ordinate instead, eg. Car.X > LayoutWidth, set Car X to .X - LayoutWidth.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Fri Jan 09, 2009 8:34 pm

Thanks so much for all your help.

I'll have a play around later today and see if I can get it going.
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Post » Sat Jan 10, 2009 4:01 am

I'm in the process of finishing off the actual art for the background, so I might rebuild this once thats done, maybe in a few days. Then I'll revisit the problem.

Thanks for all the help so far though guys, much appreciated.
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Post » Sun Jan 11, 2009 1:50 am

I've uploaded a new version, with new graphics, and simplified code.

[url:34yl9q97]http://www.mukpuddy.com/timtests/mukbuggy_level1_test.cap[/url:34yl9q97]

The scrolling issue is still there, but it's not as bad. It's a little smoother now that I moved the wheels aswell, as opposed to letting them reset to the right position automatically.

It seems like the physics interferes with the move, is it possible to disable the physics when you hit the edge, then enable them again?

Strange thing is, it worked great when it was just a ball. As soon as switched to the car it went bung.
B
10
S
4
G
5
Posts: 136
Reputation: 2,977

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests