Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1589 times)
0 Members and 1 Guest are viewing this topic.
Offline Dreamcatchermatt

Junior Devvie

« Posted 2010-04-21 13: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.

Offline Eli Delventhal

JGO Kernel

Medals: 42
Projects: 11
Exp: 10 years

Game Engineer

« Reply #1 - Posted 2010-04-21 14: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 Spiffy Duke »

Medals: 319
Projects: 25
Exp: 22 years

Coder, Trainee Pixel Artist, Game Reviewer

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

This might help:


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

JGO Kernel

Medals: 57
Projects: 11

Monkey for a head

« Reply #3 - Posted 2010-04-21 14: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).

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  

EgonOlsen (42 views)
2018-06-10 19:43:48

EgonOlsen (22 views)
2018-06-10 19:43:44

EgonOlsen (43 views)
2018-06-10 19:43:20

DesertCoockie (197 views)
2018-05-13 18:23:11

nelsongames (124 views)
2018-04-24 18:15:36

nelsongames (123 views)
2018-04-24 18:14:32

ivj94 (863 views)
2018-03-24 14:47:39

ivj94 (124 views)
2018-03-24 14:46:31

ivj94 (768 views)
2018-03-24 14:43:53

Solater (140 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!