Q: Smooth VIEW Movement ?

Game Editor comments and discussion.

Q: Smooth VIEW Movement ?

Postby akhad » Mon Jun 23, 2008 8:38 am

Ok, here's another Q regarding an often-used game routine. What's the best way to move the game "camera" (view) using an `ease in/out ` spline type movement. eg. you have one actor at top right. Clicking on the actor will then move the view over the actor, makng it central to the whole screen. But using ease in; this will move the camera/view very quickly to the actor, but slowing (easing in) as it reaches the actor.
The kind of thing often seen in menu selections, really.
User avatar
akhad
 
Posts: 43
Joined: Tue Jan 16, 2007 1:59 pm
Location: U.K
Score: 0 Give a positive score

Re: Q: Smooth VIEW Movement ?

Postby DST » Mon Jun 23, 2008 9:13 am

use MoveTo

You can just set the coordinates, with two variables, global integers; name them whatever you like.

object>mousebuttondown
Code: Select all
whatever1=x;
whatever2=y;
CreateTimer("view", "timername", timerlength);


I like to use timers to send activation events like this. and of course, using a timer, you only have to have one event in view for all actors to call it to their xy.

In view, on timer:
Code: Select all
MoveTo("Event Actor", whatever1-width/2, whatever2-height/2, 5, "", "");


For the width/height/2 thing, you can substitute real values if you like (if your resolution is 640 x 480 than it would be whatever1-320, whatever2-240), and where i have '5' that is the speed. Also the "", "" have to be there. The first is 'relative to' and the second is 'avoid', but in this case you don't need them. You still need the "", "" though, or you'll get an error.

Should move smoothly. If it doesn't, I owe you a coke!
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Q: Smooth VIEW Movement ?

Postby akhad » Mon Jun 23, 2008 7:36 pm

Hey DST,
Thanks for the code. It does work ok (and there's a point for you) however I'm still stumped regarding the `ease in` part. I'm thinking there is a way to tie the movement to a Cos function or similar math, maybe like some invisible Bezier spline between the current screen centre and the just-clicked actor, with a variable defining the `tightness` of the curve at each end and thus the views speed. Showing my 3D background here I guess, but that's my best description :roll:
User avatar
akhad
 
Posts: 43
Joined: Tue Jan 16, 2007 1:59 pm
Location: U.K
Score: 0 Give a positive score

Re: Q: Smooth VIEW Movement ?

Postby Thanx » Mon Jun 23, 2008 8:14 pm

Maybe you could create a path in such a way, so that it creates an ease in + with paths it's easy to add any other moing effect, not just a straight way through, If you know what I mean...
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score

Re: Q: Smooth VIEW Movement ?

Postby DST » Mon Jun 23, 2008 8:51 pm

If you want a curve, you can use a path, if you want speed change, you can simply change the speed in the MoveTo function.

If you want both, then yes, you'll have to come up with some kinda cos thing.

Using angle/directional_velocity is possible, but very difficult to control.

I don't really know much about trigonometry so i guess i can't help beyond this. :P
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Q: Smooth VIEW Movement ?

Postby feral » Mon Jun 23, 2008 11:25 pm

if you are just moving directly to the actor ( which is what I assume you mean)

I would first , store the initial distance to the actor (on mouse button down)

then start moving toward the actor , checking the NEW current distance each move,
then as the distance decreased use a formulae to simply change the speed according to the new distance

to ease out simply reverse

attached is one way to do it..
ease-in.zip
ged files and data
(11.78 KiB) Downloaded 94 times

uses variables in global code the distance function and moveto function...
there are probably better ways to do it.. but this should give you the general idea..


feral
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron