Smoother Scrolling

You must understand the Game Editor concepts, before post here.

Smoother Scrolling

Postby Cleve_Blakemore » Sun Aug 27, 2006 6:25 am

The quickest way to get the viewport to follow your character on your tilemap/level artwork is to parent the view. The problem is that it results in rough scrolling because the view is anchored to your player actor and if you are moving it 2-6 pixels at a time the view moves with it, with no intermediate frames to smooth the motion out.

For both the isometric game and the platformer I've been working on, I tried another method instead, which is to compute where the viewport center should be and use a MoveTo command to slide it there at a uniform rate. This results in much smoother scrolling around following the character.

It looks tons better for platform games but for overhead maps/isometrics it is a must. Otherwise the rough scrolling at resolutions above 640x480 becomes too noticeable.
Cleve_Blakemore
 
Posts: 20
Joined: Sat Aug 05, 2006 7:26 am
Score: 1 Give a positive score

Postby makslane » Sun Aug 27, 2006 1:49 pm

You can smooth the view move by removing the parent and using a little code. In the 'Draw Actor' event of the view:


Code: Select all
double weight = 10;

x = ((weight  - 1)*x + player.x)/weight ;
y = ((weight  - 1)*y + player.y)/weight ;


Change the weight value to get the right movement for you.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SergeLo00001 » Wed Sep 06, 2006 10:12 pm

ok i do this and the scrolling looks good, but once i start the game everything just rushes to the top and i can only see the bottom half of the player and verything below that point. why?
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby makslane » Thu Sep 07, 2006 12:29 pm

I'm sorry, you must take account the view size too:

Code: Select all
x = ((weight  - 1)*x + player.x)/weight - width/2;
y = ((weight  - 1)*y + player.y)/weight - height/2;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Jokke » Thu Sep 07, 2006 2:47 pm

so THATS why it didnt work for me too XD
Image
Jokke
 
Posts: 65
Joined: Sat Aug 26, 2006 11:53 am
Location: Yes
Score: 0 Give a positive score

Postby pavel329 » Mon Sep 25, 2006 8:03 pm

just make the player the views parent.works really easy for me.goes very smooth.but it goes in all directiong to if you don't want your charcter to be seen when he's falling to his doom just use the event disable.
Drugs r bad.
Mgaay?

Image
User avatar
pavel329
 
Posts: 269
Joined: Thu May 25, 2006 2:05 pm
Location: Behind you
Score: 5 Give a positive score

Postby SergeLo00001 » Sat Oct 21, 2006 2:40 am

i put this in draw actor of view:
double weight = 10;
x = ((weight - 1)*x + SergeLo.x)/weight - 1200/2;
y = ((weight - 1)*y + SergeLo.y)/weight - 480/2;

SergeLo is the player
The view is 1200 by 480

When i start the game everything goes black.
Last edited by SergeLo00001 on Sat Oct 21, 2006 2:46 am, edited 1 time in total.
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby SergeLo00001 » Sat Oct 21, 2006 2:45 am

has this wroked for anyone yet??
The whole smoothing thing worked, i coud've seen that when i didn't include the view/2 thing at first.... Just that when i do include it, it looks like the view rapidly shoots away into some direction when i start the game.
Plz Help :cry:
I really like this view smoothing thing
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby SergeLo00001 » Sat Oct 21, 2006 2:50 am

O, and Jokke....
How does that Bum in ur signature know all that... :shock:
He's right!
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby SergeLo00001 » Sat Oct 21, 2006 2:53 am

SergeLo00001 wrote:He's right!

sweet, figured out how ppl do this... 8)
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby makslane » Sat Oct 21, 2006 2:22 pm

Sorry again. I think I need to sleep a little more!
The right solution is:

Code: Select all
double weight = 10;

x = ((weight  - 1)*x + (player.x - width/2))/weight;
y = ((weight  - 1)*y + (player.y - height/2))/weight;
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SergeLo00001 » Fri Oct 27, 2006 5:33 am

the view still doesnt stay in poition :(
once you move with the actor that is child to view, the view moves to a direction the view movest faster than my character.

Am i doing something wrong?
SergeLo00001
 
Posts: 46
Joined: Sun Jul 02, 2006 4:58 am
Score: 0 Give a positive score

Postby makslane » Fri Oct 27, 2006 12:34 pm

If you want to use this code to control the view, use with an actor that is not child of the view.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Cleve_Blakemore » Fri Nov 24, 2006 11:36 am

makslane wrote:If you want to use this code to control the view, use with an actor that is not child of the view.


I will put up a small demo sometime in the next week or so to show this in action. Improves the render quality and appearance dramatically for most games.
Cleve_Blakemore
 
Posts: 20
Joined: Sat Aug 05, 2006 7:26 am
Score: 1 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest