Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 2 3 [4]
  ignore  |  Print  
  World Rally Driver 4K  (Read 19813 times)
0 Members and 1 Guest are viewing this topic.
Offline Ranger
« Reply #90 - Posted 2009-01-21 14: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 Knight


Medals: 30



« Reply #91 - Posted 2009-01-21 14: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

Senior Member




If only I knew what I'm talking about!


« Reply #92 - Posted 2009-01-22 08: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! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #93 - Posted 2009-01-22 08: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
« Reply #94 - Posted 2009-02-13 05: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
« Reply #95 - Posted 2009-02-24 23: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
« Reply #96 - Posted 2009-02-28 23: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]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (32 views)
2013-05-17 21:29:12

alaslipknot (41 views)
2013-05-16 21:24:48

gouessej (71 views)
2013-05-16 00:53:38

gouessej (69 views)
2013-05-16 00:17:58

theagentd (78 views)
2013-05-15 15:01:13

theagentd (73 views)
2013-05-15 15:00:54

StreetDoggy (113 views)
2013-05-14 15:56:26

kutucuk (137 views)
2013-05-12 17:10:36

kutucuk (137 views)
2013-05-12 15:36:09

UnluckyDevil (145 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.187 seconds with 22 queries.