Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Circles! (https://forums.graalonline.com/forums/showthread.php?t=23124)

Will45 02-06-2002 03:05 AM

Circles!
 
Could someone teach me how to make something move in a circle? Thanks.

btedji 02-06-2002 04:01 AM

I would never had said that lol, havent had evough schooling yet

TDK_RC6 02-06-2002 04:18 AM

Re: Re: Circles!
 
Quote:

Originally posted by Kaimetsu


Cartesian coords: (centerx+mag*cos(ang),centery+mag*sin(ang))

Increase the angle and watch it spin.

what is mag??

Saga2001 02-06-2002 06:37 AM

magnitude.

TDK_RC6 02-06-2002 07:44 AM

magnitude??

like how much it will rotate

Faheria_GP2 02-06-2002 07:48 AM

Quote:

Originally posted by TDK_RC6
magnitude??

like how much it will rotate

liek, teh radius foo! LEL!

TDK_RC6 02-06-2002 07:59 AM

well okay then, that helps more


i've never heard it called magnitude

lordhelmut 02-06-2002 09:59 AM

i learned a new vocab word =D but how would i incorporate that formula into a NPC?

Faheria_GP2 02-06-2002 10:51 AM

NPC Code:

if (playerenters) timeout=.05;
if (timeout) {
this.angle=(this.angle+.1)%6.28;
showimg 0,beer.gif,x+6*sin(this.angle),y+6*cos(this.angle) ;
timeout=.05;
}


Saga2001 02-06-2002 11:21 AM

Quote:

Originally posted by Faheria_GP2
NPC Code:

if (playerenters) timeout=.05;
if (timeout) {
this.angle=(this.angle+.1)%6.28;
showimg 0,beer.gif,x+6*sin(this.angle),y+6*cos(this.angle) ;
timeout=.05;
}


;P

joseyisleet 02-06-2002 02:04 PM

-=Josey=-
Nice formula Kaimetsu. I wouldn't use showimg for that, I do believe showimg is local. So you could use something like this;

if (playerenters){
timeout=.05;
setimg light2.png;
setcoloreffect 0,0.5,1,0.99;
}
if (timeout) {
this.x=30;
this.y=30;
this.angle=(this.angle+.1)%6.28;
x = this.x+6*sin(this.angle);
y = this.y+6*cos(this.angle);
timeout=.05;
}

Just change this.x and this.y to wherever you want the light to be.

nyghtGT 02-06-2002 02:30 PM


*wishes she would have had a better Geometry teacher*

joseyisleet 02-06-2002 02:48 PM

-=Josey=-
Hey! Everyone makes mistakes. ;P In that formula, the angle = the speed, this.x+6 = the width, this.y+6 = the hieght.

joseyisleet 02-06-2002 03:09 PM

-=Josey=-
Lol, if you use the code that I provided above, it is.
Say you use this.angle=(this.angle+.7)%6.28;. That will speed up the circular movement. If you use this.x+10 and this.y+10 it will make the radius bigger, making it circle bigger.

Slaktmaster 02-06-2002 05:20 PM

Nice try, Josey. :p

joseyisleet 02-06-2002 10:17 PM

Lol. thisx+6 and this.y+6 = the circumference of the circle.

joseyisleet 02-06-2002 10:25 PM

- wonders what 6 + 6 is
:eek:

Saga2001 02-06-2002 11:44 PM

Notice when he knows what he is saying is wrong, he starts all of his posts with Lol...thats just something I noticed...humans amaze me...
The curcumference is 2pi*r is it not? Not trying to correct Kaimetsu, I am seriously wondering.
And the area is pi*(r*r)...
and i consider myself bad at math...joseyisnoleet.

joseyisleet 02-07-2002 12:01 AM

-=Josey=-
- Shrugs. I've been up for about 5 days. Tired as heck and my mind isn't working right. ;\ Maybe after I eat breakfast I'll go to bed, doubtfull though. - Beats the hell out of insomnia. ;X

Saga2001 02-07-2002 07:40 AM

Re: Re: Circles!
 
Quote:

Originally posted by Kaimetsu


Cartesian coords: (centerx+mag*cos(ang),centery+mag*sin(ang))

Increase the angle and watch it spin.

what about this instead?
centerx+mag*cos(ang+rotate),centery+mag*sin(ang+ro tate)

it seems when you add to the numbers inside the sin and cos it makes them rotate, which would make sence, but its just a sidenote. look:
NPC Code:

if (playerenters) {
this.dista = 5;
this.distb = 5;
timeout = .05;
}
if (timeout) {
for (i=0;i<10;i+=.1;) {
showimg (i*10)+500,@.,30+sin(i)*this.dista,30+cos(i+this.r otate)*this.distb;
}
this.rotate+=.05;
timeout = .05;
}


dragoonvenganc 02-07-2002 10:56 AM

to the person that said geometry this is pretty much trig..
i like making stuff move in a sine or cosine wave..
tangent is messed.. up.. any one out there besides kammy know what i mean

nyghtGT 02-07-2002 12:01 PM

Quote:

Originally posted by Kaimetsu


Once again this is incorrect. The circumference of the circle is pi*12.

yes, the radius is equal to 2*pi*r ...

2*3.14*6=37.68 ...

That is the circufrence ...

the area of the circle is pi*r*r:

3.14*6*6=113.04

...

nyghtGT 02-07-2002 04:02 PM

Re: Re: Re: Re: Circles!
 
Quote:

Originally posted by Kaimetsu


Which is the same as 12*pi, except that my answer was more precise.

you get the same answer ...
and it helps him learn where to place the varaibles for his equations ...

Saga2001 02-08-2002 12:32 AM

What I am saying, is that if you add variables to to the numbers inside sine or cosine like incrementally add .05 to this.rotate and add it to i than it seems to rotate try the script I included when I first posted. Its actually very cool.

Saga2001 02-08-2002 12:55 AM

Quote:

Originally posted by Kaimetsu


Ah, I understand now. I didn't notice that you were only adding to the sin.

Mmmmmm...l33t


All times are GMT +2. The time now is 04:32 AM.

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