Quicker version of makslanes's smooth moving code

Game Editor comments and discussion.

Quicker version of makslanes's smooth moving code

Postby Game A Gogo » Wed Feb 21, 2007 1:29 am

i made a quicker version of makslane's smooth view moving

1.Create an actor that should appear in the middle of the screen.

2.Make view Parent of Center actor.

3.In the center actor draw actor event:
Code: Select all
angle=direction(x, y, Player.x, Player.y);
directional_velocity=distance(x, y, Player.x, Player.y)/10;//Change the number 10 to set the "weight" factor
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Thu Feb 22, 2007 2:39 am

if the distance is > 25 it messes up!
:(
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Game A Gogo » Fri Feb 23, 2007 12:15 am

distance from what?
This never happened to me, at what actor this happens, and what does exactly happens?
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Fri Feb 23, 2007 1:22 am

the velocity is so great the view goes away from the players and goes flying all around
:lol:
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

keeping view ahead of actor

Postby pixelpoop » Sat Feb 24, 2007 3:43 am

thanks Game A Gogo, nice clean code. but I made it dirty

I took your code and added sin and cos to keep the view ahead of the actor instead of behind.
note:This code assumes you are already using angle on the actor being followed by the screen. if not you need to add angle coding.
to add:
-put the code into the view's -draw actor -script editor
-add local, real variables called e and c.
-no need to parent anything
-change anyplace that says "player" to your actor's name
-change where it says 160 and 120 to half of your view's x and y dimensions.
Code: Select all
//this code assumes your player is already assigned an angle
c=sin(degtorad(player.angle))*100;
e=cos(degtorad(player.angle))*100;
// 100 is the distance the view tries to keep
// ahead in either direction

angle=direction(x+160, y+120, player.x+e, player.y-c);
// 160 and 120 are half of my view's pixel dimensions(320x240)
// you must change these to half of your views X and y dimensions
directional_velocity=distance(x+160, y+120, player.x+e, player.y-c)/5;
//change the 160 and 120 here as well
//change the 5 to change how fast the screen follows
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby Troodon » Sat Feb 24, 2007 11:34 am

Hmmm...this code is cool but moves the main actor when I change the actor. For example if I make
1.follow actorA
2.follow actorB
the actor B moves little
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby arcreamer » Wed Aug 01, 2007 3:19 am

that code u made pixel, when i put it in draw actor of view and made 2 global integer variables e and c, when i put it all in and i clicked game mode, the view went down a little then started shaking like crazy made my head hurt... what happeneD?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby arcreamer » Wed Aug 01, 2007 3:21 am

nvm i got it had to made e and c real variables
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby arcreamer » Wed Aug 01, 2007 3:40 am

its not working for me. Whenever i put it in and do everything and go into game mode, whenever i stop the view moves down and to the right and it looks dumb... how do i make it not do that?
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Postby DilloDude » Wed Aug 01, 2007 6:48 am

Maybe put it inside an if (player.directional_velocity) statement. Then it will only move if you are moving. Or use another real variable instead of angle.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby pixelpoop » Wed Aug 01, 2007 10:38 am

do you have a directional velocity on your actor that the view follows? You need to have one even if it is .0000000001
Here is a demo:
Attachments
smooth_move_view_ahead.zip
shows how to keep the view ahead of your actor when using 360degrees of movement. Use arrow keys to rotate.
(216.57 KiB) Downloaded 92 times
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby arcreamer » Wed Aug 01, 2007 2:57 pm

thanks pixel i got it working
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron