Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums [AS3] Help w/ Ship Movement
 User Name Remember Me? Password
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 Thread Tools Rate Thread Display Modes
 06-15-2008, 09:39 PM #1 rosem Member   Join Date: Mar 2007 Location: Big Rapids, MI Posts: 47 [AS3] Help w/ Ship Movement Hey Everyone, I was wondering if anyone could point me in the right direction for figuring out the movement of a ship in a game I'm building. Basically I want to ship to continuously move around on the stage, and head in whatever direction it's pointing in. Any links, etc.. would be greatly appreciated. Any ideas? Thanks, Mike
 06-15-2008, 09:46 PM #2 rosem Member   Join Date: Mar 2007 Location: Big Rapids, MI Posts: 47 Actually if anyone can recommened some good tutorials or books on the subject as well, that would be great. I'm realizing that I want this thing to fly more like a plane, so it's going to need a lot of tuning...
 06-15-2008, 11:23 PM #3 lordofduct Senior Member     Join Date: Feb 2008 Location: West Palm Beach, FL Posts: 3,872 I'm assuming you mean where pushing say up, it moves in the direction the ship is facing. left and right rotate the ship. And down moves in reverse direction of the direction the ship is pointing. You can use a bunch of trig to pull this off, but you should always avoid trig unless necessary (sin, cos, tan... etc). I'd use a vector... you don't have a vector class, so just use the point class or 2 variables representing 2 slots of a vector. For Vectors there are a few things you should know that make them so great. Vectors are denoted in math: where i is the amount of magnitude in the x direction and j is the amount of magnitude in the y direction A) vectors have magnitude and direction. Magnitude is the amount of "force" the vector has (hence in physics they say a vector has force and direction... not accurate though as force is a physical action... and Vectors don't have to represent physical forces). Direction is which way you are moving... it could be viewed kind of like 'slope' as well. There is no position to the vector, it is 100% free floating, which means you can apply the magnitude and direction of the vector to any object no matter where it stands. i.e. a mass can have the force of gravity applied to it anywhere on earth... <0, -9.8> meters per second squared B) The unit vector is a vector who has the direction, but who's magnitude is 1. These vectors can be easily manipulated because of the identity theorem (x * 1 = x). Thusly if you have a unit vector you can multiply it by any 'speed' and get a vector with that magnitude with very little work. We use pythagorean theorem to get the unit vector. unit vector of = / sqrt(i^2 + j^2) thusly the unit vector of <5,5> is <5,5> / sqrt(50) = <.7071, .7071> SO: if you make a unit vector represent the direction your ship is facing you can do several things. When updating position forward you just add the vector * speed to the position of the object. Subtract when moving backwards. And rotate the vector when turning (which does use trig as it is faster then resolving unit vectors) here is a vector class I wrote filled with useful methods. www.lordofduct.com/storage/Vector2.as it could use some more tweeking to make it user friendly to most. Just keep in mind, base methods always change the vector you run the method from, static methods should be used if you want to return a new vector with out effecting the inputs. __________________ www.lordofduct.com - come read my blog! If you want to know how to program, take a math class, take a lot of math classes!

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

 Similar Threads Thread Thread Starter Forum Replies Last Post AdamSchroeder General Chat 0 12-18-2007 09:16 PM Murphy1976 Gaming and Game Development 2 05-31-2007 11:20 PM UzumakiJr Site Check 0 12-16-2006 08:48 PM Unknowner Gaming and Game Development 6 07-24-2006 08:28 AM pyrokinesis Gaming and Game Development 3 07-22-2006 04:31 PM

All times are GMT. The time now is 10:57 PM.

///

## Categories

 Contact Us - Home Page - Archive - Privacy Statement - Top

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.