Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: Quality scaling of 2D images? on: 2003-09-13 05:22:20
Yeah - unfortunately that seems to use the same code (or at least produces the same result) as a 'drawImage' with width/height parameters - rather poor quality Sad

If you try it, you should see a marked difference between that and using 'Image.getScaledInstance'.

Let me know if you don't...
2  Java Game APIs & Engines / Java 2D / Quality scaling of 2D images? on: 2003-09-13 04:54:29
Dear all,

Has anybody figured out how to scale large (2000x2000) 2D images in Java (using AWT, Java2D or JAI) to the same quality as that produced by, say, Paint Shop Pro or PhotoShop?

The Internet is awash with people who have discovered that...

1  
image.getScaledInstance


...produces significantly better results (on a par with Paint Shop or PhotoShop) than, say...

1  
graphics.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR );


...but the former seems like a really old implementation, is very slow and (worst of all) doesn't co-exist very well with things like...

1  
2  
graphics.translate( iX, iY );
graphics.scale( dX, dY );


Sad

So, the 'getScaledInstance' anamoly aside, how do you get good, smooth scaled large images out of Java?

If you have a large, cartoony image (like a line drawing, but with colours) how do you resize it down to as good a job as Paint Shop Pro does?
3  Game Development / Shared Code / Re: A New Timer Algorithm on: 2003-05-20 01:04:00
Has anyone else noticed that this timer class (as opposed to TheLorax's one) causes your CPU usage to jump to 100%?

I did a pretty direct apples-to-apples replacement of SleepTimer with AdvancedTimer, and suddenly my CPU usage was off the scale (though, to be fair, my machine was still as responsive as usual, so maybe it's doing something very low priority).

Possibly it's because SleepTimer uses 'Thread.sleep' whereas this implementation uses 'Thread.yield' in a tight loop which might mean, if there's no other thread to yield to (i.e. they're all waiting on this timer!) that loop would just go nuts waiting for the clock to tick round?

Is this just me?
4  Game Development / Shared Code / Code request: NIO sockets on: 2002-11-10 20:36:53
Could anybody post some code to handle non-blocking Sockets with 1.4's NIO, as opposed to the 'traditional' approach of starting a new Thread for each connection (which quickly breaks under hundreds of Threads)?

A simple chat server (similar to the thousands of 'traditionally' written ones that are already out there) would be ideal.

Thanks.
5  Game Development / Shared Code / Re: BufferStrategy based buffer flipping on: 2002-11-08 01:12:44
In line with swpalmer, is there some native 'magic' that happens when you use BufferStrategies?

If I'm developing a straightforward applet with VolatileImages, is there any benefit to going with triple buffering as opposed to 'manual' double buffering (given that you can't sync to the retrace)?

And, if there IS, is this benefit only available if you use a BufferStrategy (as opposed to, say, 'drawImage'ing the buffers yourself)?

Is all this BufferStrategy stuff really only of benefit to full screen (where we DO, I presume, get some native 'magic')?
6  Java Game APIs & Engines / Java 2D / Re: Tricks to get smooth animation on: 2002-11-04 21:45:11
Michael,

I too found, when I originally profiled my application, that creating Rectangles (specifically, calling Area.addOp) is pretty costly - I mentioned that a little while ago on this board.

I found since then, however (with a bit of digging) that you can easily just...

a) Create a GeneralPath object OUTSIDE the main loop
b) Reset it on every iteration (no Object creation)
c) Manually called 'lineTo', 'lineTo', 'lineTo', 'closePath' to add each rectangle to the GeneralPath
d) Check other affected actors with GeneralPath.intersects(x,y,w,h) - and remember to blit them, but don't increase the clipping rectangle for them
d) Call setClip on the finished GeneralPath
e) Blit away!

I think this is pretty optimal 'dirty rectangle' code (you don't create any objects), works well with VolatileImages, and is certainly a significant speed increase in my app.

Richard.
7  Java Game APIs & Engines / Java 2D / Re: Tricks to get smooth animation on: 2002-11-03 20:10:26
This depends a lot on the type of animations you're doing. For example:

1) If you're not scrolling the screen, then it's likely that not ALL of your screen is changing each frame. In PacMan, for example, only Pac and the Ghosts and maybe a pill or two change each frame - large portions of the screen (though WHICH large portions varies) remain the same.

Therefore, you can do quite a bit with 'dirty rectangles' and 'setClip', updating only those parts of the screen which absolutely need it.

2) Using Java's built-in 'sleep' or 'wait' is never going to be as good as the 'hires Timer hack' on the 'Shared Code' section of these boards, which in turn is never going to be as good as a native hi-res timer. Being able to reliably space your frames 'exactly' the same amount of time apart increases the smoothness of your animation a great deal.

3) The quality of your graphics is unlikely to affect their speed unless you're rendering them each frame, in which case...

4) ...cache as many things as you can within temporary Images, ready to be quickly 'drawImage'd to the screen. Expire your caches when images in them aren't used (to save memory)

5) Use double buffering, or triple buffering if your frame rendering time can get quite high...

6) ...and use VolatileImages (hardware accelerated) to reduce frame rendering time

Just my two cents Smiley
8  Game Development / Shared Code / Re: Code Request: Plugin Detection on: 2002-10-31 01:42:41
markuskidd,

You need to take a step back and think about what you're asking here.

First, the 'codebase' line you're referring to is an attribute of an 'object' tag. That tag, in turn, is an ActiveX command that will ONLY be understood by Internet Explorer and ONLY on Win32. So, you've no need to worry about Mac/Linux users Smiley

(as an aside, the original ActiveX downloading spec allowed you to specify different ActiveX binaries for different platforms, but seeing as how Microsoft have discontinued IE for Unix...

http://www.microsoft.com/unix/ie/default.asp

...I don't think this will be a problem going forward!)

The 'embed' tag (which only Netscape 4.7x understands) DOES have a 'pluginspage' attribute which will automatically redirect the user to 'java.sun.com/getjava' if you want (not in the example given by ap_kelly, but I'm sure you can tweak that).

Outside of the 'automatic downloading' world, you can simply offer a link to 'Get Java' (Sun has a Java Banner Program you can sign up for), much as you would Shockwave.

Personally, I'm not a big fan of the converter either. A much better way is to use the standard JSP taglibs (they have an 'embed applet' tag). However, neither of those produce as robust a solution as is discussed on...

http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html

...(which features my favourite quote 'Although this tag seems complicated compared to the old APPLET tag, it is not.'), so you can always implement your own JSP taglib to do that.

In fact, if JSP is the way to go for you, I can post such a taglib here.

As proof all this really does work, please feel free to check out my site at...

http://www.juliannegiffin.com
9  Game Development / Performance Tuning / Re: micro optimizations on: 2002-10-30 19:19:04
First, I'm not going to pretend I've done any timings on this BUT, in the general case, this code would seem to be optimal (addressing your concerns EgonOlsen)...

1  
2  
3  
4  
5  
6  
int a[] = new int[1000000];
int j = -1;
for (int i = a.length; --i >= 0;) {
j++;
// Do stuff
}


...where you use 'j' (not 'i') as your regular loop counter (then you don't have to reverse your arrays or anything).

This seems like such a general case that I'd be tempted to think compilers could optimize this like this anyway, but then again they're probably not sure whether 'a.length' will remain constant for every iteration of the loop (unless it was declared final or something).

I agree with leknor that most machine languages have special instructions for testing zero, as opposed to loading a value into a register (which itself may require a function call or two) and then checking it.

Mind you, these sorts of micro optimizations are pretty academic - they're harder to read and not going to gain you anything over simply writing a better algorithm Smiley
10  Game Development / Performance Tuning / Re: micro optimizations on: 2002-10-29 02:49:33
No problem. Interestingly, your other example (which you don't like to use because it's hard to read) looks like it would solve this...

1  
2  
3  
4  
int a[] = new int[1000000]; 
for (int i = a.length; --i >= 0;) {
// Do stuff
}  


...because the evaluation (and hence the decrement) gets done before the first time through the loop.

Anyway, thank you for the code - I'm busy changing all my loops now to see what impact it has Smiley
11  Java Game APIs & Engines / Java 2D / Re: Simple game framework? on: 2002-10-28 23:16:18
Great!

Thanks purely to the input from these boards, I have implemented hi(gher)-res timers, triple buffering and hardware acceleration into my applet.

However, I'm concerned that this opens the door for all sorts of compatibility problems, so would appreciate it if anybody out there could stop by my site and see if the applet works (no full-screen, no Java Web Start, no hassle!)...

http://www.juliannegiffin.com

(click on the 'House of Cards' link)

I'd rather not post this on the 'look at my Java game' forum because I'm looking for feedback from people that understand what effect timers, triple buffering and accelerated images have Smiley
12  Game Development / Performance Tuning / Re: micro optimizations on: 2002-10-28 23:06:16
Are your two examples equivalent?

Code:
int a[] = new int[1000000];
for (int i = 0; i < a.length; i++) {
// Do stuff
}  

Code:
int a[] = new int[1000000];
for (int i = a.length; i >= 0; i--) {
// Do stuff
}  

Given that the first loop does an iteration where 'i' equals '0', won't the second loop do an iteration where 'i' equals 'a.length'?

And won't, therefore, this break?
13  Java Game APIs & Engines / Java 2D / Re: Simple game framework? on: 2002-10-23 23:13:35
That is indeed a very smooth running game! Allow me to add my kudos to the pile Smiley

There seems to be some cleverness with a 'high resolution timer' class: could I trouble you with a couple of questions about it?

1) What is its history? Who was the author (someone's name is quoted)?
2) Why, in the PacMan game itself, do you worry about timing frames and 'ticks'? What are the ticks used for?

Many thanks.
14  Game Development / Shared Code / Could anybody post the PacMan applet? on: 2002-10-23 02:07:10
Could anybody post the PacMan applet that generated so much kudos back on the old boards?
15  Java Game APIs & Engines / Java 2D / Re: Simple game framework? on: 2002-10-22 23:25:37
>Create the game around some other class, which has the
>initialize, start, stop and destroy events.

While it's true to say that designing around an applet limits you to applet-based games, it's ALSO true to say that the more generic you go (with software in general) the higher the learning curve (to tailor it back down again to your specific needs) and the fewer the opportunities for performance improvements.

For example, as I stated when I started this thread, I'm only interested in the (large) class of games that fall into the 'applet-based, not everything on the screen moves' category (such as PacMan, Space Invaders, etc.). I think these are achievable in Java.

I'm not, for example, interested in scrolling games because:

a) you can't do any 'dirty rectangle' stuff then
b) you could easily argue that Java doesn't have all the necessary mechanisms for 'real' scrolling anyway

>Search the old board for solutione (and perhaps paste them
>here for reference)

There was a newbie PacMan game that got a lot of kudos on the old board, but its code has long since disappeared. Regardless, I expect better versions have now been created with, say, triple buffering?

>I fear that trying to keep all the information in this thread will
>be difficult - perhaps create a small webpage?...

With respect, I think the java-gaming.org forum is EXACTLY the place for this discussion. It'd be great if the site owner's could see fit to produce a 'definitive' (if such a thing is possible, and I would think it is for the category of games I have described) article, but until then this thread would hopefully be the best place.
16  Java Game APIs & Engines / Java 2D / Re: Simple game framework? on: 2002-10-22 02:20:11
Could I humbly request this thread return to the topic of discussion? Smiley

As has been resolved, LWJGL is not really that suitable for lightweight, purely 2d graphics and sound, at least not without SPGL, and either way not really for small, downloadable applets.

Any framework that satisfies the general need is going to have to be pretty small, and run inside a browser (i.e. not full screen). To reiterate, it would need to:

* Handle the main 'move/test/redraw' loop
* Have a base 'applet' (or whatever) class and a base 'actor' (or whatever) class, whereby actors have abstract methods like 'move' and 'paint', and the applet takes care of moving and painting them each frame
* How to keep the frame rate smooth
* Discussion over the impact of using Collections vs. arrays of primitive types
* Discussion over different techniques for 'only redrawing what has changed'
* Can you use VolatileImage effectively with applets and one-bit transparency? What about if you mix in some alpha transparency too - do you have to forgo VolatileImage completely? What is the fastest BufferedImage image type?
* Other optimizations

I have recently had a good deal of success with my own framework by going around the Area class altogether. I have found I can get significant improvements by manually creating a GeneralPath (of multiple rectangles) and assigning that as a clipping shape.

I think a framework or an article bringing together the collective knowledge of people on these boards would be invaluable, and achievable given how mature this topic should be.

As a starting point: what framerate is realistic for a PacMan-like, browser-based applet?
17  Java Game APIs & Engines / Java 2D / Simple game framework? on: 2002-10-17 02:23:08
Hello all,

I would love to see an article/discussion on java-gaming.org about constructing a simple, practical 2D game framework.

Target games would be things like Space Invaders, Breakout, PacMan, card games, etc. (scrolling is not a priority). After all these years, this is a topic that surely must have been resolved into a 'best case' answer!

Specifically, I would like the framework to:

* Handle the main 'move/test/redraw' loop
* Have a base 'applet' (or whatever) class and a base 'actor' (or whatever) class, whereby actors have abstract methods like 'move' and 'paint', and the applet takes care of moving and painting them each frame
* How to keep the frame rate smooth
* Discussion over the impact of using Collections vs. arrays of primitive types
* Discussion over different techniques for 'only redrawing what has changed'
* Can you use VolatileImage effectively with applets and one-bit transparency? What about if you mix in some alpha transparency too - do you have to forgo VolatileImage completely? What is the fastest BufferedImage image type?
* Other optimizations

I have constructed such a framework myself, and my main performance bottleneck seems to be because I try to construct an 'optimal' clipping shape (consisting only of the rectangles of actors that have moved) and the java 'Area' (specifically, sun.awt.geom.AreaOp.AddOp) class seems pretty slow (however, it's a good deal faster than doing multiple rectangular copyAreas).

I would gladly submit the source for my framework, but would prefer not to slant the opening discussion Smiley
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

Grunnt (16 views)
2014-09-23 14:38:19

radar3301 (14 views)
2014-09-21 23:33:17

BurntPizza (31 views)
2014-09-21 02:42:18

BurntPizza (22 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (29 views)
2014-09-20 20:14:06

BurntPizza (33 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (75 views)
2014-09-10 13:57:51

TehJavaDev (105 views)
2014-09-10 06:39:09
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!