Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Small Movement Script (https://forums.graalonline.com/forums/showthread.php?t=33241)

Loriel 07-10-2002 07:22 PM

Small Movement Script
 
I started working on a movement script which lets you steer using the left/right keys and accelerate with up/down.
It's meant for underwater/swimming movement.
Do you people think that it's usable, or should I change it's behaviour?

NPC Code:
//#CLIENTSIDE
if (created) {
this.playerdir = 1;
timeout = 0.05;
}
if (timeout) {
disabledefmovement;
// Steering left/right
// Changing the dir
if (keydown(1)) this.playerdir += 0.05;
if (keydown(3)) this.playerdir -= 0.05;
this.playerdir = this.playerdir%2;
// Calculating the actual angle
angle = 3.14159265 * this.playerdir;
// Displaying the current direction
showimg 0,@tempus sans itc@cb@X,playerx+1.5+xmove,playery+2+ymove;
// Accelerating
// Calculating current direction
xmove = sin(angle);
ymove = cos(angle);
// Adding speed into a direction
if (keydown(0)) {
this.xspeed += xmove/5;
this.yspeed += ymove/5;
}
if (keydown(2)) {
this.xspeed -= xmove/20;
this.yspeed -= ymove/20;
}
// Limiting the speed
if (this.xspeed>0.5) this.xspeed = 0.5;
if (this.yspeed>0.5) this.yspeed = 0.5;
if (this.xspeed<-0.5) this.xspeed = -0.5;
if (this.yspeed<-0.5) this.yspeed = -0.5;
// Moving the player
playerx += this.xspeed;
playery += this.yspeed;
// Slowing down a bit
this.xspeed *= 0.99;
this.yspeed *= 0.99;
// Displaying the speed
setplayerprop #c,#v(this.xspeed) #v(this.yspeed);
timeout = 0.05;
}


warp2ukew 07-10-2002 08:01 PM

sorry for double posting lol...it looks good though i just took a quick look at it

Mista_Micro 07-11-2002 08:13 PM

i could use help with movement in my c++ game o.O

bigkow44 07-11-2002 10:32 PM

Did anyone else noticed the angle is equal to 'pi'

adam 07-12-2002 06:45 PM

Radians are neat yes? ;)

warp2ukew 07-12-2002 08:49 PM

Quote:

Originally posted by bigkow44
Did anyone else noticed the angle is equal to 'pi'
ya

GrowlZ1010 07-13-2002 12:25 AM

Although it takes a bit of getting used to, it's pretty good. It strikes me as being kinda like the GTA1/2 motion system.

screen_name 07-14-2002 09:16 PM

i notcied the PI thing also

:) thought it was just me

adam 07-15-2002 02:25 AM

Quote:

Originally posted by screen_name
i notcied the PI thing also

:) thought it was just me

You seem to have a problem you need to take care of......before you end up in trouble....

screen_name 07-15-2002 08:20 AM

Quote:

Originally posted by adam


You seem to have a problem you need to take care of......before you end up in trouble....


o yeah, i thought i fixed that Xx

adam 07-15-2002 09:25 AM

Quote:

Originally posted by screen_name



o yeah, i thought i fixed that Xx

good boy ;)

bigkow44 07-24-2002 11:07 AM

pi is 3.14 etc. in math terms, not 180 degrees.

adam 07-24-2002 10:05 PM

Quote:

Originally posted by adam
Radians are neat yes? ;)

bigkow44 07-26-2002 12:08 AM

Quote:

Originally posted by Kaimetsu


True. Though we both know that they meant 3.14 radians are equal to 180 degrees.

yeah :) well its pi both ways


All times are GMT +2. The time now is 06:56 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.