Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 / J2ME / What does the jvm do when it outputs "basic: Stopping applet..." on: 2007-06-21 23:22:31
I have an applet running in a browser.
Sometimes when I try to close the browser ( Firefox & IE ) they freeze.
The last line I see in the jvm output is "basic: Stopping applet..."

What methods of my applet is the jvm trying to call when it is stopping the applet?
2  Java Game APIs & Engines / Java 2D / Re: Custom Font on: 2007-06-17 05:04:30
Currently I have something working very much like the second option you mentioned.
I'll guess I'll just stay with that for now.

3  Game Development / Networking & Multiplayer / Can't read file on server more than once on: 2007-06-15 19:40:08
I have an applet which uses a few external jars after loading.

The first time I load the applet everything works fine. But if I try to load the applet again it breaks because I can't fully read the jar files.  I only manage to make only one IOStream  read call and then the next read() returns -1.

Closing and opening the browser doesn't help.
I can only load the applet again if I replace the jar file on the server with a new copy.

The code I'm using for loading the files:

public byte[] loadFile(URL a_fileLocation)
        byte[] byteArray = null;


            // Create URL Connectioin
            URLConnection urlConnection = a_fileLocation.openConnection();
            // Get the length of the downloaded file
            int length = urlConnection.getContentLength();

            // Create the byte array the for the incoming data
            byteArray = new byte[length];

            System.out.println("file length is " + length + " bytes");

            // open the connection
            InputStream io = urlConnection.getInputStream();

            System.out.println("IoStream available = " + io.available());
            int offset = 0;
            int numRead = 0;

            while (offset < byteArray.length
                    (numRead =, offset, byteArray.length - offset)) >=
                offset += numRead;

                System.out.println("offset = " + offset);


            System.out.println("Total array length is " + byteArray.length);
            System.out.println("Last amount read = " + numRead);
            System.out.println("Total read " + offset);

            // close the connection

        catch (Exception ex)
            throw new Exception(ex.getMessage().concat(
                    "@ ImageLoader: loadImageFile( " +
                    a_fileLocation + " )"));
        return byteArray;

This is what I get when the applet works

network: Cache entry found [url:, version: null]
network: Connecting with proxy=DIRECT
network: ResponseCode for : 200
network: Encoding for : null
network: Disconnect connection to
network: Connecting with proxy=DIRECT
file length is 348751 bytes
IoStream available = 8476
offset = 8476
offset = 74176
offset = 139876
offset = 205576
offset = 271276
offset = 336976
offset = 348751
Total array length is 348751
Last amount read = 11775
Total read 348751
network: Downloading resource:
   Content-Length: 348,751
   Content-Encoding: null
network: Wrote URL to File C:\Documents and Settings\Dan\Application Data\Sun\Java\Deployment\cache\6.0\49\5da74fb1-5bcb2cd8-temp

....and this is what I get with subsequent loads when the applet crashes;

network: Cache entry found [url:, version: null]
network: Connecting with proxy=DIRECT
network: ResponseCode for : 304
network: Encoding for : null
network: Disconnect connection to
file length is 348751 bytes
IoStream available = 346674
offset = 346674
Total array length is 348751
Last amount read = -1
Total read 346674

Am I not closing the jar correctly? What's stopping me from fully reading the file again?

4  Java Game APIs & Engines / Java 2D / Re: Painting optimization on: 2007-06-14 19:08:37
And when you said that you "are using Awt.Containers/Components for the different screens/game elements", do you mean that you are drawing sprites using them, or just for other methods. Either way you may find that you are drawing all of the screen elements each frame due to [say] having transparent layers and not specifying update regions when you are updating.

I use containers/components for painting as well. I just call repaint()  whenever they are modified.
I thought that would take care of clipping the drawing regions. I think it doesn't actually matter because I end up ignoring all the paint() calls other than the one in the main loop which calls the paints the top container. This probably results in painting everything again.
If I go with passive rendering I end up getting some flicker in some containers. I presume thats because the paint() thread can't access all the components all the time.

I'm not sure I understand how keldon85 improved performance. Is it just by initializing the image through the initializeGraphics ( int[] buffer ) call? Does this result in the image being rendered faster every paint() call? Currently I just read pngs to a Java.Image and then paint the image to a BufferedImage to get it accelerated.

Image loadedImage= Toolkit.getDefaultToolkit().createImage(byte[]);

BufferedImage  bufImage=

bufImage.getGraphics().drawImage(im, 0, 0, null);

5  Java Game APIs & Engines / Java 2D / Re: Painting optimization on: 2007-06-14 15:56:33
Thanks for the quick replies.
I'll try profiling the paint method and also try using the BufferStrategy.

Orangy Tang, how much performance increase should I expect from converting  to LWGL?

Kova, are you using Awt Containers/components in your game? Are you repainting the whole 1024*768 every update?


6  Java Game APIs & Engines / Java 2D / Painting optimization on: 2007-06-14 14:28:31
My game is running too slow.
When I run a profiler I see that graphics2d.paint() takes most of the cpu time. The size of the game panel is 1024*768.
I am double buffering and using BufferedImages created via GraphicsConfiguration.createCompatibleImage().

The game has several screens which include buttons and animations.
I am using Awt.Containers/Components for the different screens/game elements because its easier then to manage them on screen and also receive mouse clicks on the buttons.

In order to have to program paint only after I update the game I don't forward the update() call in the double buffered screen to the paint() call but rather call the paint() method myself ( with getGraphics() )after each game update in the main run() loop. ( Active Rendering )

It seems to me like I'm painting a lot. Each screen has an 1024*786 background which I'm painting every iteration in the run() method. I have to paint at least some of that image again and again because I have animations playing in front of it.

I don't want to use LWGL because I want the program to be multi platform. How much faster will the program run if I do switch to lwgl ?

Will abandoning AWT containers/components increase the game speed? If so is there any library for handling painting in a way that minimizes the number of paint calls/ minimizes the areas repainted?

Any suggestions?
7  Java Game APIs & Engines / Java 2D / Custom Font on: 2007-05-29 13:30:01
I have a set of pngs I'd like to use as a font in my application.
Any implementation suggestions?
8  Java Game APIs & Engines / Java 2D / Re: Tinting Images on: 2007-05-25 22:18:01
Is there any way of doing this to an entire graphics context instead of a specific image?
I'm looking for something like a customized Composite.

I have this snippet:

public class TintingComposite implements Composite

  int m_r;
  int m_g;
  int m_b;

  double m_newColorPercentage; // 0-1
  double m_oldPercentage;//0-1

  public TintingComposite(Color a_color, double a_dPercentage)
    m_newColorPercentage = a_dPercentage;
    m_oldPercentage = 1 - m_newColorPercentage;

    m_r = (int) (a_color.getRed() * m_newColorPercentage);
    m_g = (int) (a_color.getGreen() * m_newColorPercentage);
    m_b = (int) (a_color.getBlue() * m_newColorPercentage);


  public CompositeContext createContext(ColorModel srcColorModel,
                                        ColorModel dstColorModel,
                                        RenderingHints hints)
    return new CompositeContext()
      public void compose(Raster src, Raster dstIn, WritableRaster dstOut)
        for (int x = 0; x < dstOut.getWidth(); x++)
          for (int y = 0; y < dstOut.getHeight(); y++)
            // Get the source pixels
            int[] srcPixels = new int[4];
            src.getPixel(x, y, srcPixels);
            //blend in the new r,g,b but keep the alpha
            srcPixels[0] = (int) (srcPixels[0] *
                                  m_oldPercentage + m_r) & 0xff;
            srcPixels[1] = (int) (srcPixels[1] *
                                  m_oldPercentage + m_g) & 0xff;
            srcPixels[2] = (int) (srcPixels[2] *
                                  m_oldPercentage + m_b) & 0xff;
            dstOut.setPixel(x, y, srcPixels);

      public void dispose()


The only problem is that I whenever I try to set a pixel which has an alpha different from 1, I end up making it opaque.
I suspect my problem is that when I call dstOut.getNumBands() it returns 3 while src.getNumBands() returns 4.

Any idea? Alternatives?

9  Java Game APIs & Engines / Java 2D / Tinting Images on: 2007-05-25 19:09:10
I have a set of images which I want to tint with different colors.
I know I can make the whole image gray with this code:

BufferedImage   source  = .....;

BufferedImageOp op = new ColorConvertOp(  ColorSpace.getInstance(ColorSpace.CS_GRAY), null);

op.filter(source, source);

This will result in the image being tinted with different shades of gray.

Is there any way to do this with another color other than gray?

Pages: [1]
EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!