Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
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: Problem with image drawing and FPS on: 2012-08-23 05:09:29
@Ultroman:
I'll check what you said, maybe there is something I can't think of right now.
The only thing that comes in mind is that I don't draw a specific area of the map size on the board. I draw all 1000 tiles, even though those that are not supposed to be drawn. Is it possible that causing the issue? In other words I am NOT implementing something like this: http://user-generated-content.java-gaming.org/img-vault/d7729d02ad9f36f000dfbbec5d2a51d10d7bde17a12ded3b82ec52acbd79de60.png . Instead all of my tiles are drawn.
2  Java Game APIs & Engines / Java 2D / Re: Problem with image drawing and FPS on: 2012-08-23 04:33:51
I think I found a temporary solution to my problem, although any other ideas are more than welcomed. My solution is to load images as ImageIcons. I tried to load a 100x100 map at 80 fps/ups and the results were the game to run at 50 fps and 80 ups.
3  Java Game APIs & Engines / Java 2D / Re: Problem with image drawing and FPS on: 2012-08-23 01:01:01
Below you can see the classes of the program. I made a small version of my game that runs in windowed mode (the same problem with fps dropping occurs in both full screen mode and NON full screen mode) which only paints the background and contains the classes that are needed to do that.

Game class:
http://pastebin.com/eiH2BDwL

gamePanel class (Most of the gaming loop code is taken from a book i've been reading):
http://pastebin.com/TDYhBAfC

World class:
http://pastebin.com/uVaWZWZa

Floor class:
http://pastebin.com/8FScvJay

Tile class:
http://pastebin.com/xztK6qyj

Map class:
http://pastebin.com/2HBnxYEN

The image i use is this one (to change the location within the program change the string in the beginning of the Floor class: 40th line)
http://desmond.imageshack.us/Himg822/scaled.php?server=822&filename=cursor82.png&res=landing

[EDIT:]
You can change the map size by modifying the mHeight and mWidth variables  at the very beginning of the World class.

I tried using volatileImages but didn't speed up my FPS value.
An alternative of Java2D like slick2D is not an option right now. I'd like to find a way to solve my problem using java2D. In case I can't find a solution, then I'll use another library like slick2D, etc.

By the way thanks everyone for your answers Smiley
4  Java Game APIs & Engines / Java 2D / Re: Problem with image drawing and FPS on: 2012-08-22 19:38:37
There are many draw functions used in the game, so here I am posting the one I think is the most responsible one.
The code to draw the "floor" of the map is the following:

Quote
   public void draw(Graphics g){
      Graphics2D g2d = (Graphics2D) g;

      //draw Floor
      for (int i = 0; i < floorAl.size(); i++){
         g2d.drawImage(floorAl.get(i).getImage(), null, floorAl.get(i).getX(), floorAl.get(i).getY());
      }
   }

floorAl is an ArrayList<Tile>, where all the Tile objects representing the floor are contained along with the their x,y positions and their BufferedImages.
The Tile class makes use of another class called BufferedImageLoader which is responsible for loading any BufferedImage passed as a parameter to the constructor.
5  Java Game APIs & Engines / Java 2D / Problem with image drawing and FPS on: 2012-08-22 19:11:32
I am developing a full screen exclusive mode isometric tile game from scratch -i.e. I don't use a game engine- and I have a problem when it comes to drawing "BufferedImages" and "Images" on screen. (I am using active rendering)

The default FPS value is set to 80, but when the map tiles are drawn on screen the FPS value drops at 60. The map size (=array's size) at the moment is 100 tiles (10 width * 10 height). If I change that to 100*100=1000 tiles then the FPS value drops to 0 and the game cannot be played.

The code I use to load buffered images is the following:

Quote
BufferedImage image= ImageIO.read(new File(file));

while the code to load Images is the following:

Quote
Image image= ImageIO.read(new File(file));

where file is a string containing the path to the image.
The size of the tile-image that it loaded is ~3KB.

Do you have any idea why does the FPS value drop? Or a different way to suggest on how to draw images without occuring problems to the FPS value?

Thanks in advance,
sp0wner
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.

E.R. Fleming (14 views)
2014-07-29 03:07:13

E.R. Fleming (4 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!