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   
Pages: [1]
  ignore  |  Print  
  Dynamic Damage (modifying a bitmap)  (Read 910 times)
0 Members and 1 Guest are viewing this topic.
Offline Dreamcatchermatt

Junior Member





« Posted 2010-04-21 15:30:23 »

Hi all,

I've been thinking about how to get my sprites to show 'damage' effects based on their HP. If it helps you get a better image in your head, the sprites are space ships in a top-down space battles game.

what I have been thinking, is to have a number of damage 'decal' images that i can use, and then overlay these onto my main ship sprite.

When a ship takes a hit, it gets a random decal sprite, adds it to the ship sprite's image (ignoring anything that falls onto a transparrent part of the base image), to give the illusion of a damaged ship hull.

What would be a good way of doing this? Are there any image modification librarys that would be idea for this?

i'm using PNG images, (rendered out from Inkscape on default settings) and things like fire, smoke and small bits of wreckage would be handled seperately by the particle engine. All this is for is dynamicaly modifying the base sprite image in real-time, cheaply.

another application I am interested in using this for is when a ship exploads, the sprite image is broken up randomly into 3 or 4 peices that then drift apart (and become a harvistable item for resources). Along each 'cut' edge, damage sprites would be added to make it look like there is twisted mettal and the ship's insides pulled out.

Thanks,
Matt
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2010-04-21 16:15:00 »

The best way would just be to draw the decal on top of the ship sprite every frame. Modifying bitmaps directly is expensive and unnecessary.

See my work:
OTC Software
Offline kevglass

JGO Kernel


Medals: 120
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #2 - Posted 2010-04-21 16:20:34 »

This might help: http://positech.co.uk/cliffsblog/index.php?s=Damage+textures

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2010-04-21 16:46:02 »

The 'best' way is going to depend on what graphics api you're using, and what tradeoffs between cpu time and memory you're willing to make.

If you're drawing via OpenGL, and can expect a non-crappy graphics card then you can compose the damage textures onto your sprite on the fly using a fragment shader. That'll be quickest in terms of cpu and very light on memory (since you only have to hold the original sprites and damage sprites).

If you're using Java2D, then i've found it's actually plenty fast enough to composite images together on the fly so you could take a copy of your base sprite and apply damage sprites ontop of it as they occur, then use the damaged version of the sprite. Obviously this is going to require more memory than doing things on the fly though.

Or you could just draw the damage sprite on top while drawing everything else. That'll work, but won't give you the same amount of control over the effect (you can't actually carve out chunks of damage, you can only make things dirtier).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
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.

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

Riven (38 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

Cero (60 views)
2014-07-16 00:42:17

Riven (57 views)
2014-07-14 18:02:53
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!