Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Scripting movement. (https://forums.graalonline.com/forums/showthread.php?t=65733)

Angel_Light 04-29-2006 10:11 PM

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?

Skyld 04-29-2006 10:20 PM

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.

ApothiX 04-29-2006 10:52 PM

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.

Angel_Light 04-30-2006 02:55 AM

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.

Tyhm 05-01-2006 09:30 AM

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)

Angel_Light 05-01-2006 01:20 PM

One problem tho. I'm still Algebra 1. -_- I havent learn sin cos or tan...

Yen 05-01-2006 08:13 PM

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.

ApothiX 05-01-2006 09:18 PM

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.

Angel_Light 05-02-2006 12:58 AM

Sweet. A Math Teacher on Graal =B Thanks, i think i'm getting it.....

Shaun 05-02-2006 02:58 AM

Wait wait, who's the math teacher in this post?

Blitz_Hunter 05-02-2006 03:19 AM

probably yen

Angel_Light 05-02-2006 03:52 AM

Yup ^^

ZeLpH_MyStiK 05-02-2006 05:28 AM

tan...if you ever needed to divide the change in y movement by the change in x movement...

Andy0687 05-02-2006 06:00 AM

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.

pacMASTA 05-02-2006 06:27 AM

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?


All times are GMT +2. The time now is 07:04 PM.

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