Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Rotation to slope

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 08-22-2012, 02:07 AM PM User | #1 Scriptr Regular Coder   Join Date: Oct 2011 Posts: 106 Thanks: 12 Thanked 0 Times in 0 Posts Rotation to slope I am making an Asteroids-like game in OpenGL, using LWJGL. I have a box and control handling. Next step: Motion. I have it set so that left arrow rotates left and right arrow rotates right. Now I need Up arrow to go. I have it set to go straight if it is headed straight up, down, left, or right: Code: ```public void go(){ float r = -(this.r) % 360; r = r < 0 ? 360 + r : r; float dx, dy; System.out.println(r); if(r == 0){ y += 10; return;} if(r == 90){ x += 10; return;} if(r == 180){ y -= 10; return;} if(r == 270){ x -= 10; return;} }``` but now what if it is at an angle? I need to do several things:Determine slope Convert it to `delta Y / delta X` Find the equivalent fraction whose numerator and denominator are `a` and `b` in a pythagorean triple where `c = 10` (or close) Then I can adjust its position by those amounts How should I approach this problem? I am aware that slope is equal to `tan(Θ)`, but I have no clue where to begin making it into a fraction. I could loop through all possible fractions until I get one that is equivalent and a pythagorean triple, but (correct me if I'm wrong) that wouldn't be fast enough for use in a game (currently 20 ticks per second)
 08-28-2012, 02:06 AM PM User | #2 Scriptr Regular Coder   Join Date: Oct 2011 Posts: 106 Thanks: 12 Thanked 0 Times in 0 Posts I continued to do research, and as my search got less and less specific, I found an example for Flash AS3 (see link). Unless this is helpful to people who come across it later, please delete this thread.

 Bookmarks

 Thread Tools Rate This Thread 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 :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 08:56 PM.