Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (672)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (727)
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  
  perfectly Rotating obejcts 2D  (Read 1957 times)
0 Members and 1 Guest are viewing this topic.
Offline Cero
« Posted 2007-07-10 04:14:32 »

Assuming I have a method for rotating my object/picture thing
rotate(int rotation); // 0 - 360... 0 = looks down, 90 = looks left, 180 = looks up, 270 = looks right

now the image is for example in the center of the screen and on mouse click or move, whatever, should the image rotate so that it look towards the cursor (mouse position)
you sure understand what i mean.

now... I just cannot comeup with a algorithm to do that, someone got an idea ? =)

Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #1 - Posted 2007-07-10 05:22:08 »

You only need java.awt.geom.AffineTransform and Math.atan2.

atan2 gives you the angle and AffineTransform allows you to rotate/translate the image.

弾幕 ☆ @mahonnaiseblog
Offline Cero
« Reply #2 - Posted 2007-07-10 16:18:08 »

ya, like i said i already got the rotating method, and i managed to do it with atan2, thanks a lot =D

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline keldon85

Senior Devvie

Medals: 1

« Reply #3 - Posted 2007-07-10 19:41:17 »

You write weird, I can't understand a word you're saying, sorry! Please rephrase it so that it makes more sense Smiley

Offline Cero
« Reply #4 - Posted 2007-07-10 20:58:54 »

Hm,  my first post ?
because you cannot mean the second now oO

Well I got a rotating Image Method using java.awt.geom.AffineTransform
and wanted to know, how to rotate an image in the very direction of the mouse cursor, example: you move the cursor around and the image, a space ship rotates looking in the direction of the mouse cursor.

however using Math.atan2 and thanks to oNyx that succeeded.

Offline keldon85

Senior Devvie

Medals: 1

« Reply #5 - Posted 2007-07-10 21:17:54 »

Oh right, yes Atan2 will do that. But dude, your first pose was weird  Grin

Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

IanParcs (45 views)
2016-04-18 14:18:53

KaiHH (45 views)
2016-04-18 08:35:41

KaiHH (75 views)
2016-04-15 12:43:58

theagentd (76 views)
2016-04-14 02:16:17

theagentd (90 views)
2016-04-14 02:15:43

IanParcs (104 views)
2016-04-12 03:51:16

IanParcs (47 views)
2016-04-12 03:50:03

IanParcs (43 views)
2016-04-12 03:49:54

IanParcs (38 views)
2016-04-12 03:49:52

IanParcs (48 views)
2016-04-12 03:49:52
Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30 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‑
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!