Pages: [1]
  Print  
Author Topic: motion_add();  (Read 2729 times)
Offline (Male) RetroX
Posted on: August 09, 2008, 10:18:53 AM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Here's how you can recreate it, since it isn't done yet:
Code: [Select]
// Syntax: motion_add(direction,speed)
// Adds a set motion to the current motion

// Calculate where the object would travel at the different speeds
x1=cos(degtorad(direction))*speed;
y1=-sin(degtorad(direction))*speed;
x2=cos(degtorad(argument0))*argument1;
y2=-sin(degtorad(argument0))*argument1;

// Add up the two coordinates
x3=x1+x2;
y3=y1+y2;

// Set the new speed to the distance to the new coordinates
speed=point_distance(0,0,x3,y3);

// Find out what direction the new coordinates are from our position
direction=point_direction(0,0,x3,y3);

I believe that should work.
« Last Edit: August 09, 2008, 10:20:31 AM by RetroX » Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) TGMG
Reply #1 Posted on: August 09, 2008, 02:36:42 PM

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
Doesn't this work?:
direction+argument0
speed+argument1
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Male) RetroX
Reply #2 Posted on: August 09, 2008, 02:51:01 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
No, motion_add adds a new motion to the existing one.  To put it this way, let's say we have a block moving at a speed of 2 and in direction 0 (right).  If we add a motion of 1 in direction 180 (left) then the block will continue moving in the same direction, only with a speed of 1.  If we add that same motion again, the block will come to a complete halt.

That is what motion_add() is for.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) TGMG
Reply #3 Posted on: August 09, 2008, 04:02:38 PM

Developer
Joined: Jun 2008
Posts: 107

View Profile WWW Email
Thanks RetroX, never actually used that function but i see now it could be quite useful  :)
Logged
me
GMbed 2.0 :: Embed you gm games in websites.
Offline (Female) serprex
Reply #4 Posted on: August 17, 2008, 03:52:05 PM
Smooth ER
Developer
Joined: Apr 2008
Posts: 106

View Profile WWW
Couldn't you just add x2 and y2 to x1 and y1?
Logged
Offline (Male) RetroX
Reply #5 Posted on: September 05, 2008, 06:13:18 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
I assemble code.  I don't "save space" like you do.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #6 Posted on: November 16, 2008, 04:35:50 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2946

View Profile Email
No, assemblers assemble code. You just write it.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Pages: [1]
  Print