Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (121)
games submitted by our members
Games in WIP (577)
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  
  What are some ways I can get Blue Fiend to quit hogging resources and CPU?  (Read 1558 times)
0 Members and 1 Guest are viewing this topic.
Offline CyanPrime
« Posted 2009-04-04 00:07:26 »

Can some people go through the source, and make some changes and tell me how they made Blue Fiend hog less CPU and RAM?

http://prime.turquoisegrotto.com/java/bluefiend.java
Offline zammbi

JGO Coder


Medals: 4



« Reply #1 - Posted 2009-04-04 02:20:10 »

Without looking too closely, I had noticed a few things.

I haven't noticed a BufferStrategy.

When creating loading/creating images use "createCompatibleImage", like so:
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  
   private static BufferedImage loadImage(final String imageName){
      final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      final GraphicsDevice myDevice = env.getDefaultScreenDevice();
      final GraphicsConfiguration graphicConf = myDevice.getDefaultConfiguration();

      final ClassLoader classLoad = ImageProcess.class.getClassLoader();
      Graphics2D g2d = null;

      BufferedImage img;
      try {
         img = ImageIO.read(classLoad.getResource("Images/"+imageName));
      } catch (final IOException e) {
         //System.err.println(imageName + " image failed to load.");
         return null;
      }
      final BufferedImage copy = graphicConf.createCompatibleImage(img.getWidth(), img.getHeight(),java.awt.Transparency.OPAQUE);
      g2d = copy.createGraphics();
      g2d.drawImage(img,null,0,0);

      img.flush();
      img = null;

      g2d.dispose();
      g2d = null;
      return copy;
   }

And don't use alpha when possible. So only create alpha "createCompatibleImage" when you need it to have alpha.
That might help a little.

Current project - Rename and Sort
Offline pjt33
« Reply #2 - Posted 2009-04-04 07:19:45 »

Have you profiled it? VisualVM is a decent profiler, and once you know where the biggest issues are you'll be able to ask more specific questions which people may be more inclined to answer. At present you're asking such an open-ended question that it sounds to me as though it would take a few hours to get useful results, and as you yourself have recently observed in another thread the only person who cares that much about your game is you.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CyanPrime
« Reply #3 - Posted 2009-04-04 19:53:47 »

Have you profiled it? VisualVM is a decent profiler, and once you know where the biggest issues are you'll be able to ask more specific questions which people may be more inclined to answer. At present you're asking such an open-ended question that it sounds to me as though it would take a few hours to get useful results, and as you yourself have recently observed in another thread the only person who cares that much about your game is you.
Ah, this seems like it'll be a nice tool onc3e I get it to work better. I got this info from it.

http://imgur.com/F5M4K.png
http://imgur.com/F5MWC.png

When I was moving in the game the floats got a lot of live bytes.
Offline appel

JGO Wizard


Medals: 51
Projects: 4


I always win!


« Reply #4 - Posted 2009-04-06 13:43:26 »

The motionblur effect can be easily replicated using a simple double-buffering trick, instead of applying some blur filter on all things.

E.g.

1. Use a single graphics context that all these items will be rendered into.
2. Fill the graphics context with a (e.g.) 10% translucent black color
3. Draw all the objects onto the graphics context
4. Display results
5. Go to step 2 and repeat.

For every iteration of the game loop the previous screen is darkened by 10%, mimicking the motion blur effect.


Check out the 4K competition @ www.java4k.com
Check out GAMADU (my own site) @ http://gamadu.com/
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.

theagentd (16 views)
2014-10-25 15:46:29

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (45 views)
2014-10-16 15:22:06

Norakomi (34 views)
2014-10-16 15:20:20

lcass (39 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (68 views)
2014-10-14 00:35:47

TehJavaDev (60 views)
2014-10-14 00:32:37

BurntPizza (74 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!