Graal Forums  

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

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
Reply


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 12:06 AM.


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