Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (575) Games in Android Showcase (154) games submitted by our members Games in WIP (623) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: 1 2 3 [4]
 ignore  |  Print
 World Rally Driver 4K  (Read 24053 times) 0 Members and 1 Guest are viewing this topic.
Ranger
 « Reply #90 - Posted 2009-01-21 13: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!!!
cylab

JGO Ninja

Medals: 78

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

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!
trembovetski

Senior Devvie

If only I knew what I'm talking about!

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

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

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
trembovetski

Senior Devvie

If only I knew what I'm talking about!

 « Reply #93 - Posted 2009-01-22 07: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 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

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
Ranger
 « Reply #94 - Posted 2009-02-13 04: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!
Ranger
 « Reply #95 - Posted 2009-02-24 22: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!
Ranger
 « Reply #96 - Posted 2009-02-28 22: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
 1  2  3  4  5  6 `// CopyToolkit.getDefaultToolkit().getSystemClipboard().setContents(str, null);// PasteTransferable 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!     Awesome!
Pages: 1 2 3 [4]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 BurntPizza (29 views) 2015-04-23 03:42:11 theagentd (34 views) 2015-04-22 16:23:07 Riven (48 views) 2015-04-16 10:48:47 Duke0200 (59 views) 2015-04-16 01:59:01 Fairy Tailz (41 views) 2015-04-14 20:13:12 Riven (43 views) 2015-04-12 21:36:37 bus hotdog (60 views) 2015-04-10 02:39:32 CopyableCougar4 (66 views) 2015-04-10 00:51:04 BurntPizza (69 views) 2015-04-06 22:06:58 ags1 (67 views) 2015-04-02 10:58:48
 theagentd 23x BurntPizza 16x wessles 15x kingroka123 11x alwex 11x 65K 11x kevglass 8x Rayvolution 8x Roquen 7x chrislo27 7x Hanksha 7x Riven 7x Olo 7x Ecumene 7x ra4king 7x KevinWorkman 6x
 How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21Resources for WIP gamesby kpars2014-12-18 10:26:14Understanding relations between setOrigin, setScale and setPosition in libGdx2014-10-09 22:35:00Definite guide to supporting multiple device resolutions on Android (2014)2014-10-02 22:36:02List of Learning Resources2014-08-16 10:40:00List of Learning Resources2014-08-05 19:33:27
 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