Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Basic question, a beginner !  (Read 2863 times)
0 Members and 1 Guest are viewing this topic.
Offline alvaro

Junior Newbie




Java games rock!


« Posted 2003-11-10 06:40:41 »

Hi,

can somebody tell me when this formula can be used, where can I get more information about it?

dir_x =  Math.cos(alpha*(Math.PI/180));
dir_y =  Math.sin(alpha*(Math.PI/180));
....

ball.pos_x+=dir_x ...
ball.pos_y+=dir_y ...

regards
Alvaro

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2003-11-10 06:58:39 »

Looks like an equation to generate a unit circle, what do you actually want it to do?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Herkules

Senior Devvie




Friendly fire isn't friendly!


« Reply #2 - Posted 2003-11-10 07:02:00 »

You use it when calculating the x/y translation when you have a angle of direction given in degrees [0,360].

Did I get the question right?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2003-11-10 07:12:09 »

/me slaps forehead
Oh  yeah, convert an angle to a vector, that makes more sense. I had assumed that the alpha meant it was being interpolated over, instead its actually an input angle.

Guessing the question is still the tricky part though Wink

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline cfmdobbie

Senior Devvie


Medals: 1


Who, me?


« Reply #4 - Posted 2003-11-10 12:48:43 »

Okay, while we're playing some kind of bizzare Jeopardy, try this:

Programmer Tom is writing some code and uses the decimal number 1597463007.  What is his method likely intended to do? Grin

Hellomynameis Charlie Dobbie.
Offline kevglass

« JGO Spiffy Duke »


Medals: 196
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2003-11-10 16:19:04 »

Random number generator Smiley

Kev

Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2003-11-10 17:25:23 »

Thats fundemental trig.  Try any trigonometry textbook.

Alpha is your angle of direction in degrees.  pi/180 is a conversion from degress to radians, which is what all of the trig functions want.

sin == opposite/hypotenuse == Y part of that angle (assuming a total movement of 1,  hypotenuse is actually the total distance moved, opposite is the Y component.)  Note that this assumes a
trig style coordinate system where poitive Y is at the top and negative Y at the bottom.  if you are working in screen space you'll need to reverse it.

cos == adjacent/hypotenuse == X part of that component.

So your simple answer is. given a ship position x,y  and angle of motion alpha,  that math calculates the new position if the ship moves 1 unit in alpha direction.

Basic trig.  if you can't handle this you will have a LOT of "fun" trying to write game code....

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2003-11-10 17:28:56 »

Btw...

This question has nothing to do with physcis and really belongs in "Newless Clubies" which is our total beginner topic.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline alvaro

Junior Newbie




Java games rock!


« Reply #8 - Posted 2003-11-11 10:54:51 »

thank Jeff, you give me the answer I was looking for. Your answer about radians makes completly sence.

regards

Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2003-11-12 00:43:48 »

Glad I could help.

JK

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!