Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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 23110 times)
0 Members and 1 Guest are viewing this topic.
Offline 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!!!   Smiley
Offline cylab

JGO Ninja


Medals: 52



« 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 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 Duke




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!!!   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!
Legends of Yore - The Casual Retro Roguelike
Offline trembovetski

Senior Duke




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 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 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!
Offline 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!   persecutioncomplex
Offline 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  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.

 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (35 views)
2014-10-17 03:59:02

Norakomi (26 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (75 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
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!