Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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  
  rotation creates garbage?  (Read 2274 times)
0 Members and 1 Guest are viewing this topic.
Offline Fiola

Junior Newbie

Java games rock!

« Posted 2004-01-08 05:41:17 »

Hello everyone, i am makinga top down view shooter game and i currently have the character facing where ever the mouse it. I am doing so using the graphics2d rotation method. It works fine and all, but i noticed that around the edge of the image there are white pixels scattered. Is this normal? Is there any way to get rid of it?
Thanks a lot in advanced!
Offline Herkules

Senior Devvie

Friendly fire isn't friendly!

« Reply #1 - Posted 2004-01-08 05:56:12 »

Do you use a certain library to do that?

Sounds like the 'dirty rectangle' is too small during rotation. Is there a call to repaint(rect) in play somehwere?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Fiola

Junior Newbie

Java games rock!

« Reply #2 - Posted 2004-01-08 17:24:21 »

well, here's my code

public void paint(Graphics g) 
     //draw the background
     Graphics2D g2d = (Graphics2D)g;
     AffineTransform origXform = g2d.getTransform();
     AffineTransform newXform = (AffineTransform)(origXform.clone());

     //Center of rotation is the center of player
     newXform.rotate(GetAngle(), playerX, playerY);
     //draw image of player
     int x = (playerX - Lil_Man.getWidth(this)/2);
     int y = playerY - Lil_Man.getWidth(this)/2;

     g2d.drawImage(Lil_Man, x, y, this);


thanks a lot for any help!

[edit]: the getAngle() method returns a double of how much angle is needed to rotate to face the mouse
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder

Got any cats?

« Reply #3 - Posted 2004-01-08 20:33:24 »

My guess (and its only that, a guess) is that you are using color-key transparency and when you rotate anti-aliasing shifts the color of the edge pixels enough to show up.

If so one solution would be to make your bounding box larger then necessary and leave the edges out when you BLT.

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!
Offline Fiola

Junior Newbie

Java games rock!

« Reply #4 - Posted 2004-01-08 23:51:41 »

well, after reading your post i decided to try to use a different format for the image. I switched from using gif, to using png, and now it doesn't have the white pixels around the edge anymore! Cheesy Thanks a lot!

Now i have another quesetion. When i rotate the image, the image gets aliased, is there a method or something that i can call to get it anti aliased?
Thanks a lot in advanced!
Pages: [1]
  ignore  |  Print  

hadezbladez (335 views)
2018-11-16 13:46:03

hadezbladez (177 views)
2018-11-16 13:41:33

hadezbladez (336 views)
2018-11-16 13:35:35

hadezbladez (81 views)
2018-11-16 13:32:03

EgonOlsen (2175 views)
2018-06-10 19:43:48

EgonOlsen (2203 views)
2018-06-10 19:43:44

EgonOlsen (1376 views)
2018-06-10 19:43:20

DesertCoockie (2008 views)
2018-05-13 18:23:11

nelsongames (1646 views)
2018-04-24 18:15:36

nelsongames (2296 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!