Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 3 [4]
  Print  
  World Rally Driver 4K  (Read 17138 times)
0 Members and 3 Guests are viewing this topic.
Offline Ranger

Sr. Member
**

Posts: 340
Medals: 1



« Reply #90 on: 2009-01-21 08:02:45 »

Edit: And in case you aren't already doing it, use BufferedImage.getSubimage() for this.

Sweet!  Never realised this method existed!  Thanks again!!!   Smiley
Offline cylab

JGO Kernel
*****

Posts: 1940
Medals: 27



« Reply #91 on: 2009-01-21 08:14:43 »

Ah, now I understand, but it shouldn't matter. Just offset the subimage: (x-354, y-354+oy) to (x+354, y+354+oy) where oy=[distance car to center]=440-250=190. Use Graphics2D.rotate(double theta, double x, double y) to do the rotation out of the center.

Edit: no, this was too simplistic, since I didn't account the current car direction... but sqrt(250^2 + 440^2) * 2 is also wrong Wink The easy way would be to use a subimage where the car-position is virtually in the center of the rect to rotate, so if the position is (250,440), then the subimage at least has to be 880x880. The diagonale is then sqrt(2*880^2)=1244 Undecided

If you want to optimize this you could calculate the minimal needed subimage and use an out-of-center-rotation by projecting the rotated viewport-corners to the source image coordinate system, but the math for this could get a bit more complicated...

Mathias - I Know What [you] Did Last Summer!
Offline trembovetski

JGO Strike Force
***

Posts: 926


If only I knew what I'm talking about!


« Reply #92 on: 2009-01-22 02:07:17 »

Sweet!  Never realised this method existed!  Thanks again!!!   Smiley

Why use getSubImage when you can just do a drawImage with 8 parameters (dst, src rects)?
http://java.sun.com/javase/6/docs/api/java/awt/Graphics.html#drawImage(java.awt.Image,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20int,%20java.awt.image.ImageObserver)

Using getSubImage can have some non-obvious side effects in some cases.

Dmitri
Games published by our own members! Go get 'em!
Offline trembovetski

JGO Strike Force
***

Posts: 926


If only I knew what I'm talking about!


« Reply #93 on: 2009-01-22 02:09:41 »

Ah, now I understand, but it shouldn't matter. Just offset the subimage: (x-354, y-354+oy) to (x+354, y+354+oy) where oy=[distance car to center]=440-250=190. Use Graphics2D.rotate(double theta, double x, double y) to do the rotation out of the center.

Edit: no, this was too simplistic, since I didn't account the current car direction... but sqrt(250^2 + 440^2) * 2 is also wrong Wink The easy way would be to use a subimage where the car-position is virtually in the center of the rect to rotate, so if the position is (250,440), then the subimage at least has to be 880x880. The diagonale is then sqrt(2*880^2)=1244 Undecided

If you want to optimize this you could calculate the minimal needed subimage and use an out-of-center-rotation by projecting the rotated viewport-corners to the source image coordinate system, but the math for this could get a bit more complicated...

Behold the AffineTransform.transform(array[], array[]) methods, which can transform your coordinates for you..

Dmitri
Offline Ranger

Sr. Member
**

Posts: 340
Medals: 1



« Reply #94 on: 2009-02-12 23:20:19 »

Just noticed there is a comment http://www.java4k.com/index.php?action=games&method=view&gid=197 saying it is not possible to paste text into a Java window on a Mac.  Is that true?  Can somebody with a Mac confirm this for me?  Ie: Can you load a replay ok on a Mac?

Thanks!
Offline Ranger

Sr. Member
**

Posts: 340
Medals: 1



« Reply #95 on: 2009-02-24 17:27:26 »

I have confirmed that it is not possible to paste text into a Java window on the Mac platform.  Sorry Mac users, you will not be able to load replays.

...I hope none of the judges use Macs!   persecutioncomplex
Offline Ranger

Sr. Member
**

Posts: 340
Medals: 1



« Reply #96 on: 2009-02-28 17:39:20 »

Huge thanks to Paladin (a coding Guru who I've worked with and who wrote Ice Fighters).  I've been able to squeeze more bytes out and put back the good awesome looking textures.

Unfortunately, sorry Mac users, doing a forced copy / paste takes an enormous amount of bytes which I just don't have.  And hey, Spiderball 4k worked the same way (using an InputDialog), and nobody complained about that? ...or did they  persecutioncomplex
1  
2  
3  
4  
5  
6  
// Copy
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(str, null);

// Paste
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
str = (String)t.getTransferData(DataFlavor.stringFlavor);


Anyway, good luck to all!  I see via the java4k site we have a record amount of games!   Shocked  Awesome!   Grin
Pages: 1 2 3 [4]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.071 seconds with 19 queries.