Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (552)
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.

Thanks.
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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
public byte[] loadFile(URL a_fileLocation)
            throws
            Exception
    {
        byte[] byteArray = null;

        try
        {

            // 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 = io.read(byteArray, offset, byteArray.length - offset)) >=
                               0)
            {
                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
           io.close();


        }
        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: http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar, version: null]
network: Connecting http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar with proxy=DIRECT
network: ResponseCode for http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar : 200
network: Encoding for http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar : null
network: Disconnect connection to http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar
network: Connecting http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar 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: http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar
   Content-Length: 348,751
   Content-Encoding: null
network: Wrote URL http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar 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: http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar, version: null]
network: Connecting http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar with proxy=DIRECT
network: ResponseCode for http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar : 304
network: Encoding for http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar : null
network: Disconnect connection to http://www.smerc.com/decades_latest/ExternalResources/InitialLoadingResources.jar
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?

Thanks.
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=
            GraphicsConfiguration.createCompatibleImage(loadedImage.getWidth(null),
                                                    loadedImage.getHeight(null),
                                                    Transparency.TRANSLUCENT);

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?

Thanks.

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?
Thanks.
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?
Thanks.

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?

Thanks.
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.

CopyableCougar4 (22 views)
2014-08-22 19:31:30

atombrot (34 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (25 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (26 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (41 views)
2014-08-06 19:49:38
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!