Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (604)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (654)
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  
  Combining Images  (Read 1439 times)
0 Members and 1 Guest are viewing this topic.
Offline wutalife

Junior Newbie

Java games rock!

« Posted 2005-01-17 15:53:26 »

Hello everyone. I'm working on a tile-based game, but it is running extremely slowly. I'm hoping you all can help me out with speeding it up.

Right now, the background is made up of dozens of invididual tile images that are read from a file. I create a BufferedImage called background and then draw all the tiles onto the BufferedImage using g.drawImage. Since the background never changes after it is first created, I then just draw the background onto the screen whenever it updates.

However, I found the program ran faster if I drew the individual tiles to the screen for each update rather than the background BufferedImage. I'm assuming I did something wrong, because it doesn't make sense that a lot of small images would be drawn faster than one big image.

Is there a problem with the way I created the background BufferedImage? I appreciate any help anyone can give.
Offline Ceranith

Senior Newbie

« Reply #1 - Posted 2005-01-17 16:52:15 »

I don't know how you're creating your images, but images greater than 256x256 aren't going to be accelerated anyway. So it being slower is to be expected.
Offline gamehacer2000

Senior Newbie

Me? I'm no one; yet, i'm somebody.

« Reply #2 - Posted 2005-01-17 16:52:39 »

Actually drawing several small images is faster. The memory consumption per image is width*height*depth. A 640x480  image at 16-bit depth takes up 600 KB of space. Add in the amount of space for your tiles and a huge chunk of ram is being taken up. Also, the BufferedImage probably is not being accelerated (It's being created in System Ram). My advice is either draw onto a VolatileImage which so long as you have a mediocre graphics card will be accelerated or get rid of the background image all together.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wutalife

Junior Newbie

Java games rock!

« Reply #3 - Posted 2005-01-17 21:48:24 »

Thanks for the help. I kept the tiles as BufferedImages and drew them onto a VolatileImage, which I then display. This made things a lot faster.

But now I'm running into another problem. I want to display semi-transparent images on top of the background image, so it would give one of the tiles a reddish or bluish tint, but it displays the semi-transparent BufferedImage as opaque. This didn't happen when the background was  BufferedImage. Is it possible to display a semi-transparent BufferedImage on a VolatileImage?
Offline gamehacer2000

Senior Newbie

Me? I'm no one; yet, i'm somebody.

« Reply #4 - Posted 2005-01-17 22:34:47 »

It should be possible to draw semi-transparent tiles onto a VolatileImage. However, the VolatileImage you are drawing onto can not be transparent unless you want to lose hardware accleration (Support for hardware acceleration of translucent and transparent VolatileImages is not completed yet.) Hopefully with Mustang, Sun will have complete support for hardware accleration of images.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

bilznatch (24 views)
2015-08-04 11:03:17

SHC (39 views)
2015-08-01 03:58:20

Jesse (24 views)
2015-07-29 04:35:27

Riven (46 views)
2015-07-27 16:38:00

Riven (25 views)
2015-07-27 15:35:20

Riven (27 views)
2015-07-27 12:26:13

Riven (18 views)
2015-07-27 12:23:39

BurntPizza (41 views)
2015-07-25 00:14:37

BurntPizza (54 views)
2015-07-24 22:06:39

BurntPizza (33 views)
2015-07-24 06:06:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!