Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (754) Games in Android Showcase (229) games submitted by our members Games in WIP (842) 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 51768 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 Kernel

Medals: 180

 « 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

 DesertCoockie (20 views) 2018-05-13 18:23:11 nelsongames (68 views) 2018-04-24 18:15:36 nelsongames (65 views) 2018-04-24 18:14:32 ivj94 (748 views) 2018-03-24 14:47:39 ivj94 (79 views) 2018-03-24 14:46:31 ivj94 (595 views) 2018-03-24 14:43:53 Solater (95 views) 2018-03-17 05:04:08 nelsongames (168 views) 2018-03-05 17:56:34 Gornova (378 views) 2018-03-02 22:15:33 buddyBro (1038 views) 2018-02-28 16:59:18
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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