Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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  
  how do I rotate a filled rectangle  (Read 1562 times)
0 Members and 1 Guest are viewing this topic.
Offline luisoft

JGO Coder

Projects: 6
Exp: 10 years

Java games rock!

« Posted 2005-04-07 10:09:47 »


I am using MIDP1. I have a filled rectangle and I need to rotate it. How can I do that since the Graphics object does not have a rotate method?

I have tried to rotate it manually using sin and cos, but then the rectangle moved in a circle path. Angry and is not what I wanna. I wanna move the filled rectangle around its axis.

I am working on 2D.
Offline xdebugx

Senior Newbie

Down with the classes, equal methods for all.

« Reply #1 - Posted 2005-04-08 23:24:48 »

You can find many sites out there that are devoted to this type of subject.  Here is a link that might be helpful:  

Also, your not going to be able to use sin and cos as there is no built in functions for that in midp.  What you can do is write a simple program in C or some other language to print out a list of sin and cos computations for each degree of rotation and then put those into your midp program and use it in a lookup table.

Offline davidaprice

Junior Devvie

« Reply #2 - Posted 2005-04-11 05:29:01 »

Sounds like luisoft's problem is not the maths but the fact that MIDP's fillRectangle doesn't handle rotation.

You'll probably achieve what you want by splitting the rectangle into two triangles and using fillTriangle for each. The edge where the two triangles meet will be drawn twice, but this shouldn't be a problem since MIDP 2.0 doesn't support XOR mode or semi-transparent colours.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline luisoft

JGO Coder

Projects: 6
Exp: 10 years

Java games rock!

« Reply #3 - Posted 2005-04-11 09:45:52 »

yeah my problem is exactly that. Why they have put a fillTriangle and not a fillPolygon? Angry I will try your solution davidaprince. I've also heard about a implementation of a fillPolygon for J2ME that is opensource, but I really don't know how fast it is.
Offline davidaprice

Junior Devvie

« Reply #4 - Posted 2005-04-12 05:24:19 »

Maybe because fillTriangle is much easier to implement than fillPolygon  Wink. And if you have fillTriangle, you can implement fillPolygon trivially, at least for convex polygons (actually, rectangle is just a special case of this).

But I agree, they ought to include fillPolygon in MIDP 3.0. If you're using a Nokia device, this feature is already available in the Nokia UI API.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (17 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (29 views)
2015-07-25 00:14:37

BurntPizza (40 views)
2015-07-24 22:06:39

BurntPizza (24 views)
2015-07-24 06:06:53

NoxInc (27 views)
2015-07-22 22:16:53

NoxInc (18 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!