int xspeed = 10;
x = ((xspeed - 1)*x + player.x)/xspeed;
int xspeed = 10;
x=((xspeed-1)*x+player.xscreen+x)/xspeed;
xvelocity=player.xvelocity/2 - (x+width*0.25>player.x)*5 + (x+width*0.75<player.x)*5;
view.angle=direction(view.x+(view.width*.5)-(MP_Dir*48),view.y+(view.height*.5)+16,x,y);
if(distance(view.x+(view.width*.5)-(MP_Dir*48),view.y+(view.height*.5)+16,x,y)<92)view.directional_velocity=distance(view.x+(view.width*.5)-(MP_Dir*48),view.y+(view.height*.5)+16,x,y)*0.04;
else view.directional_velocity=distance(view.x+(view.width*.5)-(MP_Dir*48),view.y+(view.height*.5)+16,x,y)*0.08;
int Hori_Offset=48;//horizontal offset
int Vert_Offset=16;//vertical offset
int HurryDist=96;//Distance at which the view starts moving faster
double SlowFact=0.04;//The factor at which the speed is reduced (lower=slower)
double FastFact=0.08;//The factor at which the speed is augmented
//Note, a factor of 1 means the view will move instantly towards the player and 0 means it won't move at all.
view.angle=direction(view.x+(view.width*.5)-(MP_Dir*Hori_Offset),view.y+(view.height*.5)+Vert_Offset,x,y);
if(distance(view.x+(view.width*.5)-(MP_Dir*Hori_Offset),view.y+(view.height*.5)+Vert_Offset,x,y)<HurryDist)view.directional_velocity=distance(view.x+(view.width*.5)-(MP_Dir*Hori_Offset),view.y+(view.height*.5)+Vert_Offset,x,y)*SlowFact;
else view.directional_velocity=distance(view.x+(view.width*.5)-(MP_Dir*Hori_Offset),view.y+(view.height*.5)+Vert_Offset,x,y)*FastFact;
int MP_Dir;
if(xvelocity>0)MP_Dir=1;
else if(xvelocity<0)MP_Dir=-1;
Game A Gogo wrote:
EDIT: also couldn't you use xvelocity=collide.xvelocity; when colliding with the platform? with xvelocity=0; when it stops colliding of course.
Jagmaster wrote:Click the text that says select all, then hit ctrl+c then go into the script editor and hit ctrl+v.
Btw, Gag, I can't get your code to work, I set up a variable called MP_Dir (integer, global) and set it to positive or negative 1 for right or left, but when I executed the game, the view went haywire.![]()
@Sky: The second code you sent works great, but for the first one, how would you center the player with this code? When I put + 320 at the end of the line, the screen also went haywire.![]()
![]()
I really want to get these methods to work because I'm so fed up with with the ones I'm using (with the parenting issue).
Users browsing this forum: No registered users and 1 guest