Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-02-2007, 02:04 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
vec<x/y>, sin, cos

What does vecx/vecy, sin, and cos do/mean??
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #2  
Old 09-02-2007, 03:19 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Vectors.

Level of Math Education Suggested: 10 - 11th Grade Calculus
__________________
Stan.
Reply With Quote
  #3  
Old 09-02-2007, 03:25 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
darn im only at an 8th grader's math edu

so how about cos and sin?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 09-02-2007, 03:39 AM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
im 11 xD i only know algebra and can swear in 3 differant languages.....
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #5  
Old 09-02-2007, 04:02 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
vecx/y and sin cos are simple to learn with Graal. I learned that stuff way back in 7th grade on my own(I honestly don't know the true mathmatics behind it... though we did start getting into sine/cosine in Geometry).
vec stands for vector, in which you're getting the vectorx/y of a direction.
Basically, vecx and vecy are like the following arrays:
vecx={0,-1,0,1};
vecy={-1,0,1,0};
It's generally used to get the movement of a direction.
x=vecx(player.dir)
y=vecy(player.dir)
if your direction was 3, would return (1,0).
You can also multiply it like so:
player.x+=vecx(player.dir)*.5
player.y+=vecy(player.dir)*.5
Which would move the player .5 tiles in their direction. Sin/cos are kind of the same(in principle in Graal, I'm sure I will have the math guru's all over me for this post), in which it gets the 'movement' of an angle.
Reply With Quote
  #6  
Old 09-02-2007, 04:02 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
My suggestion applied to both subjects.
__________________
Stan.
Reply With Quote
  #7  
Old 09-02-2007, 04:06 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I honestly wouldn't dwell on the whole "I'm not in a high enough grade," thing. Best thing to do is find scripts that use the functions and pick them apart(this was a lot easier to do way back than it is now, as offline levels had a lot of scripts, and they weren't as overwhelming as they are now adays). You'll soon learn how they work by trial and error and be impressed with yourself. I learned a lot of stuff in Graal before I was ever taught it in a class, such as coordinates(a Graal level is just like a huge graph paper), arrays, problem solving and algorithms'
I mean, it might not apply the same in class, but you'll learn how to use them in Graal, and you won't feel completely out of the loop when you start learning them in school, unlike just about everyone else in your class.
Reply With Quote
  #8  
Old 09-02-2007, 01:39 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
We didnt learn cos/sin in school yet, though I already know how it works. You can really learn alot through Graal, but I guess I cannot help you understand it, because my english is not enough for such things ;P
Reply With Quote
  #9  
Old 09-02-2007, 01:44 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Ok, some basic things I learned from playing with sin and cos in graal:
They are from the math term 'trigonometry' where radians is used instead of degrees.
Radians goes from 0 to PI*2.

For example, if you want your player to move in the direction that the player is facing, do this:

PHP Code:
temp.angle = (pi/* (player.dir 1));
temp.speed 1.5;

player.+= cos(temp.angle)*temp.speed;
player.-= sin(temp.angle)*temp.speed
However that will only move the player once, so it should probably be in a loop or when it is provoked by a key for example.
Cos belongs to the x-axis
Sin belongs to the y-axis

This is some simple basic stuff I first learned about cos and sin when I played around with it..
so I don't know if all above is fully correct, so if I'm not, someone else can correct me ;o
__________________
Reply With Quote
  #10  
Old 09-02-2007, 04:34 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Chompy View Post
Ok, some basic things I learned from playing with sin and cos in graal:
They are from the math term 'trigonometry' where radians is used instead of degrees.
Radians goes from 0 to PI*2.
Actually, trig uses degrees. I guess it varies from place to place, but at least in America it uses degrees.

But really, I forgot all the trig I learned in Geometry and Algebra 2. >.<
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #11  
Old 09-02-2007, 04:37 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by coreys View Post
Actually, trig uses degrees. I guess it varies from place to place, but at least in America it uses degrees.

But really, I forgot all the trig I learned in Geometry and Algebra 2. >.<
xD
__________________
Reply With Quote
  #12  
Old 09-02-2007, 04:57 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Kyranki View Post
My suggestion applied to both subjects.
I didn't know because you only said "Vectors" then said you should be in 10th grade.

Quote:
Originally Posted by Chompy View Post
Ok, some basic things I learned from playing with sin and cos in graal:
They are from the math term 'trigonometry' where radians is used instead of degrees.
Radians goes from 0 to PI*2.

For example, if you want your player to move in the direction that the player is facing, do this:

PHP Code:
temp.angle = (pi/* (player.dir 1));
temp.speed 1.5;

player.+= cos(temp.angle)*temp.speed;
player.-= sin(temp.angle)*temp.speed
so what does cos and sin really do, or should I not eally be worrying about them?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #13  
Old 09-02-2007, 06:41 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
sin and cos are properties of angles. If you have a right triangle such that angle a is opposite of side A, b opposite of B, and c, the right angle, opposite of the hypotenuse, C, sin(a) = A/C, cos(a) = B/C, sin(b)=B/C, cos(b)=A/C, sin(c)=1, and cos(c)=0.

Though I'm sure you haven't learned it, trigonometry is essential to spherical, polar, and cylindrical coordinate systems. Vector calculations rely heavily on trigonometry, as well as 3D graphics.

They're basically only ever used in graal for pretty light effects and movement systems.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #14  
Old 09-02-2007, 09:52 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Tolnaftate2004 View Post
They're basically only ever used in graal for pretty light effects and movement systems.
Yeah pretty much. Like that one stupid light in the graal.net snippet library that just goes around in a (sorta) circle.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #15  
Old 09-04-2007, 01:09 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Tolnaftate2004 View Post
sin and cos are properties of angles. If you have a right triangle such that angle a is opposite of side A, b opposite of B, and c, the right angle, opposite of the hypotenuse, C, sin(a) = A/C, cos(a) = B/C, sin(b)=B/C, cos(b)=A/C, sin(c)=1, and cos(c)=0.

Though I'm sure you haven't learned it, trigonometry is essential to spherical, polar, and cylindrical coordinate systems. Vector calculations rely heavily on trigonometry, as well as 3D graphics.

They're basically only ever used in graal for pretty light effects and movement systems.
I was thinking I'd need to use cos and sin for the melee system I need to make. Rather than hit right in front of the player, damage is done to everything that's in the sector in which the sword moves.
Reply With Quote
  #16  
Old 09-04-2007, 01:44 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Ya, you can do that. Or you can also specify a few check points (I did this once withe sword.gani, I opened the gani up in Graalshop and translated the pixel position of the tip of the sword into tiles for each frame, and did checks there.
Reply With Quote
  #17  
Old 09-04-2007, 01:58 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
That seems like a good alternative. However, I plan to use weapons which vary in length. It'd look silly if I had a large bamboo pole (there's a japanese word I'm trying to think of) that only did damage at the end of the pole. Obviously, I'm looking more towards doing damage if you're in the area of the sector rather than on the circumference.
Reply With Quote
  #18  
Old 09-04-2007, 02:14 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You can define the area of a circle you're willing to check by specifying a point A with an angle and radius, then check all along a circle until getting to point B, which would also be an angle with a radius. Something like:
PHP Code:
this.width=pi/2;
this.checkcount=10;
this.checkwidth=this.width/this.checkcount;
this.radius=5;
this.angle=((player.dir-1)%4)*(pi/2);
for (
i=0;i<this.checkcount;i++) {
  
triggeraction(player.x+cos(this.angle+(this.checkwidth*i))*this.radius,player.y-sin(this.angle+(this.checkwidth*i))*this.radius,"attack");

Or something like that.
Reply With Quote
  #19  
Old 09-04-2007, 05:50 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Grades of Math are different in every school so you can't really say "10th grade math".
__________________
Do it with a DON!
Reply With Quote
  #20  
Old 09-04-2007, 06:23 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
I got taught about basic trig, including cos/sin/tan functions, at around 13 years old and was a recurring subject until I'd finished school, which was about 3 months ago or so.

As soon as it comes up once in your syllabus, it's more than likely to reoccur in the future. For example, I'm taking Maths at Sixth-Form (which is like Year 12 and 13 of school) and trigonometry makes up a good part of it.
Reply With Quote
  #21  
Old 09-04-2007, 09:45 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Codein View Post
I got taught about basic trig, including cos/sin/tan functions, at around 13 years old and was a recurring subject until I'd finished school, which was about 3 months ago or so.

As soon as it comes up once in your syllabus, it's more than likely to reoccur in the future. For example, I'm taking Maths at Sixth-Form (which is like Year 12 and 13 of school) and trigonometry makes up a good part of it.
I'm learning 9th grade general stuff at age 12 so I guess I'll be learning next year.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #22  
Old 09-04-2007, 09:55 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Switch View Post
I'm learning 9th grade general stuff at age 12 so I guess I'll be learning next year.
I think Grade 8 is like Year 9 in England.
Reply With Quote
  #23  
Old 09-04-2007, 09:59 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Codein View Post
I think Grade 8 is like Year 9 in England.
I'm in 7th grade o_O
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #24  
Old 09-04-2007, 10:06 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Switch View Post
I'm in 7th grade o_O
Yeah, but you'll move on to 8th Grade sooner or later :P

Nothing is stopping you from learning though :P
Reply With Quote
  #25  
Old 09-04-2007, 10:18 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Codein View Post
Yeah, but you'll move on to 8th Grade sooner or later :P

Nothing is stopping you from learning though :P
Next year = 8th grade = I learn sin/cos in school
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #26  
Old 09-04-2007, 10:25 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Switch View Post
Next year = 8th grade = I learn sin/cos in school
Why wait if you have a desire to learn?
Reply With Quote
  #27  
Old 09-04-2007, 11:17 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Codein View Post
Why wait if you have a desire to learn?
Cuz I don't understand what the hell they're talkin about xD
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #28  
Old 09-05-2007, 12:44 AM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Quote:
Originally Posted by Switch View Post
Cuz I don't understand what the hell they're talkin about xD
Ever thought about googling it? If this yields no results, PM me :P
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:58 AM.


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