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 04-29-2006, 10:11 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Scripting movement.

Hello,

Is there any way to just advance the player foreward without reading player x y. Like just if the player is facing north east and the player just presses the up arrow and he moves foreward, north east. Then he rotates and turns south west and pushes the up and the player moves south west.

Is there anyway to do this?
__________________
Deep into the Darkness peering...
Reply With Quote
  #2  
Old 04-29-2006, 10:20 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Angel_Light
Hello,

Is there any way to just advance the player foreward without reading player x y. Like just if the player is facing north east and the player just presses the up arrow and he moves foreward, north east. Then he rotates and turns south west and pushes the up and the player moves south west.

Is there anyway to do this?
disabledefmovement; will disable the default movement, and then you can script your own movement system from there using keypressed/keydown, and by altering the player's X and Y manually. You will have to do manual onwall detection, swimming, sleeping, and sword use also, though.
__________________
Skyld
Reply With Quote
  #3  
Old 04-29-2006, 10:52 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Angel_Light
Hello,

Is there any way to just advance the player foreward without reading player x y. Like just if the player is facing north east and the player just presses the up arrow and he moves foreward, north east. Then he rotates and turns south west and pushes the up and the player moves south west.

Is there anyway to do this?
For what you're talking about, you'd have to do something like:
player.x += cos(this.angle);
player.y += -sin(this.angle);

this.angle being the angle the player is facing.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #4  
Old 04-30-2006, 02:55 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
ok thank you two

EDIT: Ok i got the image to move but it only moves horzontaly. No matter what direction the player faces. :/
I believe the player.y is being read.
__________________
Deep into the Darkness peering...

Last edited by Angel_Light; 04-30-2006 at 04:28 AM..
Reply With Quote
  #5  
Old 05-01-2006, 09:30 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm will become famous soon enough
Maybe it's not -sin(this.angle).
Maybe it's just sin(this.angle). Or tan(this.angle). Play around with it, it's been years since I did the X and Y of a sin of an angle (and even then I stood on the shoulders of Sardon)
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #6  
Old 05-01-2006, 01:20 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
One problem tho. I'm still Algebra 1. -_- I havent learn sin cos or tan...
__________________
Deep into the Darkness peering...
Reply With Quote
  #7  
Old 05-01-2006, 08:13 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Quote:
Originally Posted by Angel_Light
One problem tho. I'm still Algebra 1. -_- I havent learn sin cos or tan...
Aw, that's so cute.
I see no reason for tan in a movement system.

x,y -> cos(angle), single(angle)
cos is for the x-axis, sin is for the y-axis.
Graal uses angles in radians (0 to pi*2), instead of degrees (0 to 360)
However, if you don't understand radians, you can use the 'degtorad(angle)' function to convert degrees to radian.

player.x += cos(angle) will move the player's x at that angle.
player.y -= sin(angle) will move the player's y at that angle.

The the angle 0 is facing right, then cos(0), -sin(0) will be -1, 0
The angle pi*.25 (.785), or 45 degrees if you prefer that, is between the directions right and up. So, if you use cos(.785), -sin(.785), the player will move to the upper-right.

You could use getangle(gotox - player.x, gotoy - player.y) to find the angle from one point to another.

Oyah, this stuff is trigonometry, not algebra.
Reply With Quote
  #8  
Old 05-01-2006, 09:18 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Just to clarify, player.y -= sin(angle) is the same as player.y += -sin(angle), Tyhm, you shouldn't post if you don't know what you're talking about. It's not helping anything.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #9  
Old 05-02-2006, 12:58 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Sweet. A Math Teacher on Graal =B Thanks, i think i'm getting it.....
__________________
Deep into the Darkness peering...
Reply With Quote
  #10  
Old 05-02-2006, 02:58 AM
Shaun Shaun is offline
Registered User
Shaun's Avatar
Join Date: Jul 2003
Location: Canada
Posts: 1,070
Shaun will become famous soon enough
Wait wait, who's the math teacher in this post?
Reply With Quote
  #11  
Old 05-02-2006, 03:19 AM
Blitz_Hunter Blitz_Hunter is offline
dot dot dot
Blitz_Hunter's Avatar
Join Date: Oct 2002
Location: Missouri
Posts: 601
Blitz_Hunter is on a distinguished road
Send a message via AIM to Blitz_Hunter
probably yen
__________________
-em3ricR-
Reply With Quote
  #12  
Old 05-02-2006, 03:52 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Yup
__________________
Deep into the Darkness peering...
Reply With Quote
  #13  
Old 05-02-2006, 05:28 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
tan...if you ever needed to divide the change in y movement by the change in x movement...
__________________
Reply With Quote
  #14  
Old 05-02-2006, 06:00 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by ApothiX
Just to clarify, player.y -= sin(angle) is the same as player.y += -sin(angle), Tyhm, you shouldn't post if you don't know what you're talking about. It's not helping anything.
I honestly think all he was trying to do was encourage him to play around a little with the script (Judging by him saying he didnt know much about the topic himself) thats all.
Reply With Quote
  #15  
Old 05-02-2006, 06:27 AM
pacMASTA pacMASTA is offline
British Guy
pacMASTA's Avatar
Join Date: Aug 2003
Location: California
Posts: 377
pacMASTA has a little shameless behaviour in the past
Send a message via AIM to pacMASTA Send a message via MSN to pacMASTA
Quote:
Originally Posted by Yen
Aw, that's so cute.
I see no reason for tan in a movement system.

x,y -> cos(angle), single(angle)
cos is for the x-axis, sin is for the y-axis.
Graal uses angles in radians (0 to pi*2), instead of degrees (0 to 360)
However, if you don't understand radians, you can use the 'degtorad(angle)' function to convert degrees to radian.

player.x += cos(angle) will move the player's x at that angle.
player.y -= sin(angle) will move the player's y at that angle.

The the angle 0 is facing right, then cos(0), -sin(0) will be -1, 0
The angle pi*.25 (.785), or 45 degrees if you prefer that, is between the directions right and up. So, if you use cos(.785), -sin(.785), the player will move to the upper-right.

You could use getangle(gotox - player.x, gotoy - player.y) to find the angle from one point to another.

Oyah, this stuff is trigonometry, not algebra.
Yen you surpise me. Anyway Graal math is screwed up I've never asked graal but i think its a Hybrid version of Trignonometry; Theirs tons of things for starters wtf is up with the X and Y plane?
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 09:22 PM.


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