Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Java 2D rotation problem?  (Read 4041 times)
0 Members and 1 Guest are viewing this topic.
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Posted 2002-10-21 11:48:14 »

How does the rotate funtionc in java really work? It seems to me that if you are rotating images, after you have rotated about 180 degrees the image flips so basically my image can never be backwards. I'm rotating my image according to the mouse and in this case using ready made graphics doesn't work very well space wise, besides its not going to be seamless compared to the mouse.

Now the problem remains. I need to rotate my graphics object, but is it going to be fast enough if I rotate the images pixel by pixel with the trigonometric transformations using the image object?


I'm already having flickering problems(don't know its speed specific problem) with even clearRect and clipping.
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #1 - Posted 2002-10-25 11:42:58 »

Since the the 2d rotate is a horrible cheater I'm implementing the pixel grabber thing for the images that turn around.

I need to know these things before I conclude anything.
How fast is the pixel grabber function? Lets say that I make make an array which stores 360/5=72 images which all are for the different positions of the mouse, now I take this array and recall the right image every time the mouse comes to its area. This doesn't sound good to me, it is kind of complicated, but sure, if it is fast I'll go for it.

The other method is that the program dynamically creates images every time the mouse moves to right position. This way the image is created each time the mouse is moved. This sounds good, but lets say if I have 35 other sprites, perhaps even more, which are animated and are using the exatly same strategy, wouldn't it get slow? I think yes.

Does anyone have any experiences on this that you could possibly share? Does anyone know what is the pixel rotation math? Currently I have tried to do all kinds of fomulas, but the one I succeeded can be used only for 90 degree rotation since it blurs or craps up everything else.
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #2 - Posted 2002-10-25 12:57:33 »

I figured the rotation alright, I will post the code later. Thanks anyway. Still I needs to know how fast the pixel grabbing is compared to affine transform?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #3 - Posted 2002-10-25 15:23:51 »

OK the math is fine, but I still have same sort of problem as with graphics2D rotate. I'm using this to get the cords of my mouse
1  
rotateAngle=(int)java.lang.Math.round((java.lang.Math.atan((276-mouseY)/(376-mouseX)))*180/java.lang.Math.PI);


The problem doesn't seem to be with the rotation functions, because when I tried andle = x++ in thread rotations everything worked out fine. When I use the code from above it seems to be it can't draw certain areas.

I'm going to bed, perhaps tomorrow, will be better for this.
Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #4 - Posted 2002-10-26 04:54:51 »

My bad... There is absolutely nothing wrong with the java rotation. It doesn't cheat.

As my mind has been clarified with some natural sleep I immediatly found the problem. The problem how I calculate the cords of the mouse as I concluded last night.

Lets take example where mouse is at negative x and negative y side of the cordinates(I'm using polar)
atan((376 -400)/(276-400))

Now the negatives are going to take out each other and hence the angle which should be negative is now positive.

I'm sorry to flood this board with my stuff.. I'm going to take my design doc elsewhere. Thanks anyway.

Offline Captain-Goatse

Junior Duke




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #5 - Posted 2002-10-27 07:04:35 »

::)Mission Accomplished - Problem solved  Roll Eyes

I had to use atan2 instead of atan1, too bad I had figured out formulas for it before I realized that i was supposed to do so. Posting code to frequently asked pretty soon. The image rotation and the mouse angle.

Thanks!
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.

Longarmx (37 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (27 views)
2014-10-15 16:18:58

TehJavaDev (52 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (77 views)
2014-10-11 22:30:10
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!