Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Hi, I need someone to critique my bullet hell test engine...  (Read 1885 times)
0 Members and 1 Guest are viewing this topic.
Offline relminator
« Posted 2013-03-04 14:32:00 »

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!
Offline theagentd
« Reply #1 - Posted 2013-03-04 16:27:45 »

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

Myomyomyo.
Offline tyeeeee1
« Reply #2 - Posted 2013-03-04 17:51:55 »

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.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline relminator
« Reply #3 - Posted 2013-03-05 01:39:30 »

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

Offline MindOfCorruption97

Senior Newbie





« Reply #4 - Posted 2013-03-05 02:44:12 »

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

Chaos is Beatiful...
For without Chaos the world will never spin...
Offline relminator
« Reply #5 - Posted 2013-03-05 05:56:02 »

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

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

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

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

http://www.youtube.com/watch?v=zFoulf_aixo
  

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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
 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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
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).
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #6 - Posted 2013-03-05 06:00:00 »

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

Smiley
Offline relminator
« Reply #7 - Posted 2013-03-05 06:13:38 »

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

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

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

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
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
Offline deepthought
« Reply #8 - Posted 2013-03-14 03:02:11 »

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

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Offline relminator
« Reply #9 - Posted 2013-03-14 10:05:27 »

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

Cool!!! I still use that language along with C++.  For testing stuff FB is quite cool!
Pages: [1]
  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.

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

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

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

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

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

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

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

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

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

Norakomi (37 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!