Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-26 14:25:55
I understood (but if not please tell me) that: is it a bug in the BufferCapabilities class? But if I use a library such as Java3D or LWOGL or another, do I solve my problem?
Another question:
1  
2  
3  
4  
5  
6  
7  
bufferStrategy.getCapabilities().getFrontBufferCapabilities().isAccelerated() returns true
bufferStrategy.getCapabilities().getBackBufferCapabilities().isAccelerated() returns true
bufferStrategy.getCapabilities().getFrontBufferCapabilities().isTrueVolatile() returns false
bufferStrategy.getCapabilities().getBackBufferCapabilities().isTrueVolatile() returns false

And:
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getAvailableAcceleratedMemory() returns (more or less) 119000000


Is it right? Or not? I mean I understood that the first 4 methods if Java uses Accelerated Memory they must return true, is it right? But in my case the third one and the forth one return false. Last strange thing is the result of the fifth method because it returns 119000000 so it seems that my graphic card has almost 128Mb RAM but in reality my ATi Mobility Radeon 9600 has only 64Mb RAM on my notebook...

Did I misunderstand something? Huh
2  Java Game APIs & Engines / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-23 18:25:32
I already tried this method but nothing doing. I also tried to search something about this problem and I found a bug report concerning this error, in Java 1.6.0 it is fixed but for my graphic card the problem still remains.

It's very probably that the created graphics drivers for my notebook (an ASUS As2500D) have some problems with OpenGL. It's only an assuption, because I do not find anything about that.
3  Java Game APIs & Engines / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-23 13:51:34
I also tried your method Kova, but at this point it seems there is some problems with accelerated images on my machine (a notebook with a Mobility Radeon 9600 and 64Mb VRam)... Huh Perhaps do I have to put some command flags? Such as opengl-pipeline or something like that?

UPDATE: Great Gaia! Every time I run my application with this flag -Dsun.java2d.opengl=true I got this error:

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x694085d0, pid=1952, tid=516
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode, sharing)
# Problematic frame:
# C  [atioglxx.dll+0x4085d0]
#
# An error report file with more information is saved as hs_err_pid1952.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#


 Cry
4  Java Game APIs & Engines / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-23 09:55:28
Well before the game loop I do this:
1  
2  
3  
frame.setVisible(true);
frame.createBufferStrategy(2);
graphics = (Graphics2D) frame.getBufferStrategy().getDrawGraphics();


and I use the object 'graphics' to draw everything and then when I finished I call frame.getBufferStrategy().show(). I think it's right or not?
I tried to hide all the unnecessary code for the drawing operation, but the CPU usage is still high.

Uh! Last thing I use Java 1.5.0 u11, I began with this version and I want to wait some time to pass to 1.6.0.

Thanx a lot to everybody! ^____^
5  Java Game APIs & Engines / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-22 13:53:15
Great...  Undecided I thought to have solved this problem in my code, so it seems there is still something wrong. Mmh... maybe when I load the Images? In your opinion is it better to load images with ImageIO? I said that because I load my images with ImageIcon and then I convert them in BufferedImage in this way:
1  
2  
3  
4  
5  
6  
7  
public static BufferedImage loadBufferedImage(String path) {
...
    ImageIcon i = new ImageIcon(path);
    BufferedImage bi = new BufferedImage(i.getIconWidth(), i.getIconHeight());
    bi.getImage().getGraphics().drawImage(i.getImage(), 0, 0, null); // image, width, height, image observer
   return bi;
}


but maybe it's not the right method...
6  Java Game APIs & Engines / Java 2D / Re: CPU usage in a pure Java2D game on: 2007-02-21 16:07:22
Whoa!  Shocked I don't understand anything, but if for you it's a help to understand...


388750 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, "D3D texture destination")
2 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgb, SrcOverNoEa, IntArgb)
765 calls to DXFillRect
1 call to GDIFillRect
760 calls to sun.awt.windows.Win32BlitLoops::Blit("Integer RGB DirectDraw", SrcNoEa, "Integer RGB DirectDraw")
389293 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntRgb)
2 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, SrcOver, IntArgb)
780116 total calls to 7 different primitives


So what is that? Huh
7  Java Game APIs & Engines / Java 2D / CPU usage in a pure Java2D game on: 2007-02-21 15:46:08
Hi all.
I would talk about the CPU usage in a pure Java2D game (developed using only BufferStrategy or VolatileImage/BufferedImage).
In these months I'm developing a sort of wrapper library to simplify the implementation of 2D-games, but I got some problems concerning the CPU usage. For the creation of a Animation I instancied an ArrayList with the sequence of BufferedImages, every N milliseconds I change the index of the ArrayList to simulate the animation. Therefore in the Game Loop there is an update of Animation and a getCurrentImage method to show the animation on the screen (to do this I used a BufferStrategy).

With 50 Animations (composed by Images of 60 pixels by 60 pixels, more or less) and a 640 by 480 resolution with 32 bit of colors (full-screen mode) the CPU ratio (I watched it with TaskManager) is about 5%-10%; with 100 animations I got 50%-60%; with 150 animations I got 75%-85% and with more than 150 I always have 100%. The Animation is updated every 80 milliseconds.

The "engine" goes well and it's faster enough, but I would like to know if there is a way to decrease the CPU usage. I mean for example there is the way to show the Sprites and the rest splitting the Images in tiles, but this helps? Other methods?
8  Java Game APIs & Engines / Java Sound & OpenAL / Re: Playing SPC files? on: 2006-10-29 17:21:38
I know there is a plugin for WinAMP to play SPC files, is it possibile to use that in Java? It's a simple dll, maybe somehow... It should be nice to play SPC musics in Java... Wink
9  Game Development / Newbie & Debugging Questions / Re: A JCanvas on: 2006-10-19 14:32:40
Uuh... well I tried to use JPanel and it does not work with me, but it doesn't matter, I found the bug in my class... Grin How can I check if a component has a peer or not? I mean when I create for example a JPanel obj and I add it in the pane of a JFrame obj, there is a way to check the ComponentPeer of JPanel?
10  Game Development / Newbie & Debugging Questions / A JCanvas on: 2006-10-19 12:18:57
Hi all.
A simple question for a difficult answer (maybe). What is the best way to create a JCanvas? I mean in java.awt package there is the Canvas object but it is a Heavyweight object and it isn't a good idea to mix Lightweight objects with HW objs (do not respect the z-order). How can I do? I tried to create a new one which extends JComponent and implements some methods for the creation of  a BufferStrategy, but I got some problems to show images (they blink).

I show you what I've done:
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  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
public class JCanvas extends JComponent 
   [INNER CLASSES]

   private static final long serialVersionUID = 123456789L;
   private static final Dimension MINIMUM_SIZE = new Dimension(320, 200);
   
   transient ComponentPeer peer;
   private static VolatileImage vImage;
   private BufferStrategy strategy = null;
   
   public JCanvas() {
      super();
   }
     
   public void initStrategy() {
      if (this.getMinimumSize().height >= MINIMUM_SIZE.height && this.getMinimumSize().width >= MINIMUM_SIZE.width) {
         this.createBufferStrategy(2);
         this.strategy = this.getBufferStrategy();
      }
   }
   
    public BufferStrategy getBufferStrategy() {
        if (this.strategy == null) {
            createBufferStrategy(1);
        }
        return this.strategy;
    }
     
   public Graphics getBufferedGraphics() {
      return this.strategy != null ? this.strategy.getDrawGraphics() : this.getGraphics();
   }
   
   public void paintComponent(Graphics g) {
      super.paintComponent(g);
   }
   
   void createBufferStrategy(int numBuffers) {
      BufferCapabilities bufferCaps;
      if (numBuffers > 1) {
         // Try to create a page-flipping strategy
        bufferCaps = new BufferCapabilities(
                     new   ImageCapabilities(true),
                     new ImageCapabilities(true),
                     BufferCapabilities.FlipContents.UNDEFINED);
         try {
            createBufferStrategy(numBuffers, bufferCaps);
            return;   // Success
        } catch   (AWTException e) {
            // Failed
        }
      }
      // Try a blitting (but still accelerated) strategy
     bufferCaps = new BufferCapabilities(
                  new   ImageCapabilities(true),
                  new ImageCapabilities(true), null);
      try {
         createBufferStrategy(numBuffers, bufferCaps);
         return;   // Success
     } catch   (AWTException e) {
         // Failed
     }
      // Try an unaccelerated   blitting strategy
     bufferCaps = new BufferCapabilities(
                  new   ImageCapabilities(false),
                  new ImageCapabilities(false), null);
      try {
         createBufferStrategy(numBuffers, bufferCaps);
         return;   // Success
     } catch   (AWTException e) {
         // Failed
     }
      // Code   should never reach here   (an   unaccelerated blitting
     // strategy   should always work)
     throw new InternalError("Could not create a   buffer strategy");
   }
   
   public void createBufferStrategy(int numBuffers, BufferCapabilities caps)
   throws AWTException
   {
      // Check arguments
     if (numBuffers < 1) {
         throw new IllegalArgumentException("Number of buffers must be at least 1");
      }
      if (caps ==   null) {
         throw new IllegalArgumentException("No capabilities   specified");
      }
      // Destroy old buffers
     if (this.strategy instanceof FlipBufferStrategy) {
         ((FlipBufferStrategy) this.strategy).destroyBuffers();
      }
      if (numBuffers == 1) {
         this.strategy = new SingleBufferStrategy(caps);
      } else {
         // assert numBuffers > 1;
        if (caps.isPageFlipping()) {
            this.strategy = new FlipBufferStrategy(numBuffers,   caps);
         } else {
            this.strategy = new BltBufferStrategy(numBuffers, caps);
         }
      }
   }
   
   protected void destroyBuffers() {
      if (peer !=   null) {
         peer.destroyBuffers();
      } else {
         throw new IllegalStateException("Component must   have a valid peer");
      }
   }
}
11  Discussions / General Discussions / Re: j2me KVM on PSP on: 2006-10-16 12:22:45
Interesting - though not particularly useful ^_^
[...]

Quote...

There is already Lua and it's enough for PSP, I think.
12  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-10-04 18:39:05
Well I got some problems when I want to extend a Singleton Class. AriesGame is a Singleton Class and if you want to add the events (in the method events()) you must extend the super class AriesGame. Or are there other ways to do that? That is, are there other ways to extend a Singleton Class?
13  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-09-28 08:06:02
I know to put the name of library before the name of object is not good, but the library is not still been released and there are many things to change! Maybe this is one! Smiley
14  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-09-27 23:13:34
@SluX: I wish I had! Smiley I have a lot of questions about optimization... Grin

Hiya,

Your project sounds almost exactly like an existing mature java 2D games library which is targeted toward begginers and java programs with no game development experience.

http://www.goldenstudios.or.id/

You might want to see if this project satisfies your wants.

Well I know it, but I think there are some steps of the creation of a game that could be easier than those of GTGE. It's a my personal opinion! For example the creation of an Animated Sprite in my library is more logical than GTGE (if you think the contrary just tell me! Smiley ):

AriesSprite is a class that contains a group of AriesAnimation but each AriesAnimation contains an another group of sub-type of animations, AriesAnim. Why? Well think about an isometric game like Ultima or Syndacate, you know that the main character can turn right, left, up and down (and half-positions: left/up, right/down, etc...), ok? When you create an AriesAnimation you define an animation for all these positions and each single position has an AriesAnim. The creation of the sprite is more articulate, but when you will understand its logic you will have no problems. I show you an example (I'm gonna use some AriesClasses):
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  
...
AriesAnim walkright = new AriesAnim(AriesTools.loadImage("c:\images\walkright01.png"), AriesTools.loadImage("c:\images\walkright02.png"));
walkright.setSpeed(200);
walkright.setRepeat(true);

AriesAnim walkleft = new AriesAnim(AriesTools.loadImage("c:\images\walkleft01.png"), AriesTools.loadImage("c:\images\walkleft02.png"));
walkright.setSpeed(200);
walkright.setRepeat(true);

AriesAnim stand = new AriesAnim(AriesTools.loadImage("c:\images\stand"));

AriesAnimation walking = new AriesAnimation(4); // how many directions the character has? 4 is the minimum.
// when we add an AriesAnim to AriesAnimation we must specify the direction association, EAST for the RIGHT, WEST for the LEFT, NORTH for UP and SOUTH for DOWN, the default direction is EAST
walking.addAnim(AriesDirections.EAST, walkright);
walking.addAnim(AriesDirections.WEST, walkleft);

AriesAnimation standing = new AriesAnimation(4);
// here we associate the AriesAnim "stand" to default direction
standing.addAnim(stand);

// the final step, we create the sprite and add the animations
AriesSprite mario = new AriesSprite();
mario.addAnimation("walking", walking);
mario.addAnimation("standing", standing);
...
game.store.addObject("mario", mario);
...

public void events() {
    if (keyboard.isPressed(keyboard.KEY_RIGHT)) {
        game.store.getSprite("mario").setDirection(AriesDirections.EAST);
        game.store.getSprite("mario").setAnimation("walking").startAnimation();
    }

    if (keyboard.isPressed(keyboard.KEY_LEFT)) {
        game.store.getSprite("mario").setDirection(AriesDirections.WEST);
        game.store.getSprite("mario").setAnimation("walking").startAnimation();
    }

    // here we do not have to worry about to set the direction, because when a direction is not found the engine use the default
   if (keyboard.notTouched) {
        game.store.getSprite("mario").setAnimation("standing").startAnimation();
    }
}

// and that's all.


So what do you think? If the final user must worry only for the events and not to draw the graphics or other is better or not? Smiley
In Aries library the final user do not have to learn the logic of the creation of game, his own only one worry is his creative mind! ^___^

(I hope to have written right... I'm not an english user... Embarrassed )
15  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-09-27 18:59:01
Well nothing special, but an opinion if the library could be useful for someone, for example Smiley
The structure of the project is big, maybe if I post a Class Diagram (or something like that) and I explain what the library does I will receive a feedback... Cheesy
16  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-09-27 18:17:21
Uuh... Huh
Well... What do you think about that? Mmh... Nothing? Isn't it interesting? Or is there something else?
17  Game Development / Game Play & Game Design / Re: A new game library: Aries! on: 2006-09-27 14:30:38
Obviously here we have a simple example there are other objects that you can create/use: AriesBackground, AriesSprite and AriesTimer (I know they are not many but be patient! Smiley ). If you are interested about this project I will show you other kind of examples!
18  Game Development / Game Play & Game Design / A new game library: Aries! on: 2006-09-27 14:20:55
Hi all!
I'm developing a new library for the creation of 2D games in Java. The main goal of the project is to give anyone the opportunity to create a game, without the need to spend a lot of time learning how game programming works. The only prerequisite is some basic java programming knowledge. The libray do not use any particular technology or other libraries (ie LWJGL, JME, ecc...), but only pure Java. The library is not ready for a release yet, but I want to know if the project might be interesting for you or not!

I give you an example what Aries can do:
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  
public class MyGame extends AriesGame {
    private AriesPicture p1 = new AriesPicture(200, 200);    

    public MyGame() {
        game = this;            // this operation is very important when you extends the class AriesGame

        game.set(AriesGame.S_640BY480, AriesGame.FULLSCREEN);    // set up the game
       p1.drawString(0, 10, "A simple java game!");        // draw a String in the AriesPicture
       p1.drawRectangle(0, 0, 199, 199, false);        // draw a Rectangle in the AriesPicture, the 'false' determines if the shape is filled or not, in this case: not.
       p1.setPosition(100, 150);        // the position on the screen
       game.store.addObject("p1", p1);        // add the object in the game
       game.start();        // start the game :)
   }

    // this method manages the events in the game and you can manage all the game by a sequence of IF-ELSE
   // if event occurs you can manage it in this simple way
   public void events() {
        // if the space bar is hit
       if (keyboard.isTyped(keyboard.KEY_SPACE)) {
            game.store.getPicture("p1").clear();        // clear the picture
           game.store.getPicture("p1").drawString(0, 10, "You hit the Space Key");        // draw a string
       }

        // if the wheel of mouse is moved up
       if (mouse.isWheelUp()) {
            game.store.getPicture("p1").move(0, -150);        // move the picture 0 pixel for X and -150 pixel for Y
       }

        // if I'm holding pressed the Shift Key and I click on the Button 1 of mouse
       if (keyboard.isPressed(keyboard.KEY_SHIFT) && mouse.isClicked(mouse.BUTTON1)) {
            game.store.getPicture("p1").move(50, 30);        // move the picture 50 pixel for X and 30 pixel for Y
       }
    }
   
    public static void main(String[] args) {
       new MyGame();
    }
}


this is the result:
19  Java Game APIs & Engines / Java 2D / Re: Some problems about GIF images... on: 2006-09-11 15:11:13
Understood.
I will try, thanks man! Wink
20  Java Game APIs & Engines / Java 2D / Some problems about GIF images... on: 2006-09-11 13:34:22
Hi there! I got some problems with GIF images format.
In my J2D application (a simple game) I load some PNG images (24 bit colors), but since the execution was slow I switched the format of images in GIF format (8 bit colors). Here I met the problems. Before the switching, all the PNG images were loaded on the screen without problems, now the GIF images are loaded sometimes yes sometimes no. And I do not understand why. The method to load the images is the same:

   public static Image loadImage(URL path) {
      try {
         return new ImageIcon(path).getImage();
      } catch (Exception e) {   
         Log.errln(ERROR + "exception: " + e);
      }
      
      return null;
   }

   public static BufferedImage toBufferedImage(Image image) {
      BufferedImage bi = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
      bi.getGraphics().drawImage(image, 0, 0, null);
      bi.getGraphics().dispose();
      
      return bi;
   }


I load the image in Image Object after I convert it in BufferedImage. Are the methods right or not?
21  Java Game APIs & Engines / Java 2D / Re: clip an image on: 2006-09-01 14:09:02
Nobody knows?
22  Java Game APIs & Engines / Java 2D / Re: clip an image on: 2006-08-30 03:00:08
Hi! I come from Italy and I'm working on a project about Java2D for university.
I'm developing a game and I want to know if my "drawing-engine" is good or not.

I do not know how you create a Sprite but in my case I create an ArrayList of BufferedImage and each element is a Frame of this Sprite. Every n milliseconds the Frame changes and is drawn with drawImage(...) of a Graphics with a double-buffering strategy. The game with 640 by 480 resolution goes well, but can I do something else to increase the performance? Ah I also use the getSubImage() method to draw parts of the sprites (always using drawImage() in this way g.drawImage(image.getSubImage(0, 0, 20, 20), 0, 12, null)).

Thanks in advance for all replies!
23  Java Game APIs & Engines / JInput / A simple keyboard manager on: 2006-07-01 16:26:08
Hi! I'm new.
I have a simple question: where may I find a tutorial that explains how to make a simple keyboard manager? I asked that because I am able to find tutorial about gamepad and joystick only.

Thanks in advance!
Alexian
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.

BurntPizza (12 views)
2014-09-21 02:42:18

BurntPizza (11 views)
2014-09-21 01:30:30

moogie (13 views)
2014-09-21 00:26:15

UprightPath (23 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (40 views)
2014-09-12 09:08:26

Norakomi (70 views)
2014-09-10 13:57:51

TehJavaDev (96 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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!