Hi, I need someone to critique my bullet hell test engine...

Hello, I’ve just made a simple bullet hell test using a linked-array for constant time deletion and insertion. I am, however, quite unskilled in the Java language side of things so I need some suggestions for code correctness.

Here’s the binary + source:

http://rel.phatcode.net/junk.php?id=137

Right now, I’m quite impressed by Java’s speed + ease of use (I come from a C++ and BASIC background). But I would appreciate tips to make this faster (short of OpenGL).

Also why does the app always use GDI?

Thanks!

Game says 900 FPS, Fraps says 60 FPS, Task Manager says 1-2% CPU usage… >_>

It’s staying around 800FPS, CPU usage was 25% or below the entire time (that’s with all my usual programs running at the same time) and it was very smooth with no stuttering or anything. Also, there aren’t any source files in the folder; it’s just a jar, two .bat files and two images.

Sorry about that.

I uploaded a new zip with source (thanks for the heads up) Same link as above.

http://rel.phatcode.net/junk.php?id=137

theagentd: Thanks for testing.

BTW, the array in the ImageLoader is autogenerated by a texture packer application I made a while ago:

http://rel.phatcode.net/junk.php?id=106

About 600+ frames per second and CPU usage is about 2% or below.
Also, have you played a game called Touhou before?
Just curious. :smiley:

New upload using acceletated graphics:
http://rel.phatcode.net/junk.php?id=137

Nope, but I saw some really cool videos of it on youtube.

I’m one of the handful of guys who like shmups.

BTW, updated the upload. Should be 2x faster now as I’ve found a way to force accelerated sprites from this site:

http://www.cokeandcode.com/index.html?page=tutorials

somehow changing this code:


 for( int i = 0; i < numImages; i++ )
        {
        	
        	int j = i * 4;
            int x = texcoords[j];
            int y = texcoords[j+1];
            int w = texcoords[j+2];
            int h = texcoords[j+3];
            
            sprites[i] = image.getSubimage( x, y, w, h );
        
        }

to this:


GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        for( int i = 0; i < numImages; i++ )
        {
        	
        	int j = i * 4;
            int x = texcoords[j];
            int y = texcoords[j+1];
            int w = texcoords[j+2];
            int h = texcoords[j+3];
            
            BufferedImage im = image.getSubimage( x, y, w, h );
            sprites[i] = gc.createCompatibleImage( im.getWidth(),im.getHeight(),Transparency.BITMASK );
            sprites[i].getGraphics().drawImage( im,0,0,null );
    		
        }
        

Gave me about 2x performance boost on my dual-core 1.7 ghz laptop and 4x performance boost on my 1 ghz netbook (both with intel GFX). :*)

Try to test it again and see if the FPS gets higher. It should cap at about 900 because of the sleep(1).

Don’t use sleep!!! >_> It isn’t very precise.

Err… I only use sleep to minimize CPU hogging. If you looked at the code:


dt = getDeltaTime(getSystemTime());
			if (dt > Globals.FIXED_TIME_STEP)
				dt = Globals.FIXED_TIME_STEP;
			accumulator += dt;
			secondsElapsed += dt;

			while (accumulator >= Globals.FIXED_TIME_STEP) 
			{

				update();
				
				Graphics2D g2D = (Graphics2D) strategy.getDrawGraphics();
				g2D.setColor(Color.BLACK);
				g2D.fillRect(0, 0, Globals.SCREEN_WIDTH, Globals.SCREEN_HEIGHT);

				render(g2D);
				g2D.dispose();
				strategy.show();
				Toolkit.getDefaultToolkit().sync();
				
				accumulator -= Globals.FIXED_TIME_STEP;

			}



I used delta time to make the simulation run on a fixed timestep (60 FPS). So the simulation logic would run at 60 FPS but the actual game loop would run at different speeds on different computers.

I wrote this tutorial regarding that matter a few months ago:

http://games.freebasic.net/BASICGaming/Issue9/index.html#tutorial1

Free basic eh? I used to use that before I went into java. ;D

Cool!!! I still use that language along with C++. For testing stuff FB is quite cool!