Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
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  
  Changing colors or adding things in an image while running.Is it possible?  (Read 1002 times)
0 Members and 1 Guest are viewing this topic.
Avenger
Guest
« Posted 2006-03-29 01:51:36 »

Hey all,
Me and a friend are trying to make a game , him with his drawings and photoshop knowledge and me with my amateur programming.What a duo ^_^ .

So anyway to my question.We wanted to make a character who will .. let's say equip weapons .... or wear new clothes for example.We are talking for 2D platform look.At first I thought of making lots of images holding various weapons .. and being dressed in various armors/clothes ... then I realized how hard that would be cause all these would need to be animated for walking , crouching jumping(not needed but nice for effect).

So I got this problem ... how can I do this?Can I change things in an image while the program is running?Or should I just make many many images as I suggested above?

Thanks in advance for any tips/advice Smiley
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2006-03-29 02:09:52 »

a) Weapons

You draw the character and the weapons seperately.

b) Tinting

Use a mask for tinting the spritesheet (only required when changing the color). You can tint in realtime if you're using opengl.

弾幕 ☆ @mahonnaiseblog
Offline moogie

JGO Knight


Medals: 11
Projects: 6
Exp: 10 years


Java games rock!


« Reply #2 - Posted 2006-03-29 02:18:37 »

If you are using java 2D:

It really depends on your source graphics as to the best way.

If your graphaics are full 24bit (32?) then you can use the setRGB() of the the Buffered Image which holds the graphic.

If your graphic is 8bit and uses a palette such as GIF or 8bit PNG then you would want to create a new Buffered Image using a IndexColorModel set to your new palette. (i am not sure you can direclty swap in a new IndexColorModel.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Avenger
Guest
« Reply #3 - Posted 2006-03-29 02:29:40 »

Not even 30 minutes passed and already 2 replies.I expected no less from this friendly community Smiley Thanks Guys!

But ( there is always this but :/ ) as I said I am completely new to this thing and there are some words you said with which I am not familiar with.Or maybe it is cause english is not my mother language and I just don't know these words ^_^

So .. what is tinting?And what do you mean by using a mask.Here I should also say that it is 2D platform game , no 3D nothing Smiley ,cause I saw the word openGl in there :p

As for you moogie , again I sound as noobish as I can sound .... what do you mean by source graphics?Do you mean the image I am using?All the images are .png   or .gif  images scanned and then fixed and shaded following some tutorials I saw linked in Java2D forums.   

Going to sleep now , it is 3:30 here in Greece , got university tomorrow morning :/  .I will check again in the morning Smiley .Thanks again for the fast replies.
Offline moogie

JGO Knight


Medals: 11
Projects: 6
Exp: 10 years


Java games rock!


« Reply #4 - Posted 2006-03-29 02:59:52 »

Yes, the source graphics are the files which you load. i.e. man.gif, sword.png.

If these graphics are the full 16million colors i.e 24bit then you will have a harder time changing the colours of items as no doubt you will have shaded the parts of the image you want changed.

One way is to make a mask image for each of the graphics which is a map of the parts of the image you want differently coloured where each pixel determines how to modify a base colour. e.g.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
Original      Mask          New
000111000     000000000     000111000
000111000     000000000     000111000
000050000     000010000     000030000
011656110     000212000     011434110
000060000     000020000     000040000
000080000     000040000     000060000
000909000     000505000     000707000
001000100     000000000     001000100
010000010     000000000     010000010


In the above example the base colour changed from 4 to 2. In a RGB image you would want to have a mask for each colour component (or store the mask as a RGB image itself)

for an 8bit image you need only make a new palette reflecting the new colours you want changed, however this will mean that these colours cannot be used in the graphic in areas which you do not want the colour changed. e.g. a graphic of a car and the tires are black but the body is black also and they are currenttly using the same pallette index. thus to change the the body colour to yellow would also change the tires to yellow. You will need to have the tires and the body use different palette indecies which may or may not have the same colour.
Offline woogley
« Reply #5 - Posted 2006-03-29 03:24:02 »

if you want to change the color in real time, you could change the hue of the overall image by passing it through an RGBImageFilter

I did this once with a bouncing balls application. basically, it took this image:



and turned it into multi-colored balls by changing the hue of the image (which modifies the entire image around the color wheel)

I wrote this code a few years ago, so you'll have to excuse the amateurity of it Wink
http://woogley.net/misc/BallBounce/ - knock yourself out Tongue
Avenger
Guest
« Reply #6 - Posted 2006-03-29 11:51:58 »

Hm ... because I barely understand what you say .. is there any tutorial regarding this I could look.Thanks for the source code woogley Smiley
And when I say I barely understand I mean all those mask things and the rest.Which I suppose are basics to do with images .. but he he I think I need more studying at this Smiley
Offline woogley
« Reply #7 - Posted 2006-03-29 15:59:17 »

uhhmm you probably might want to get comfortable with BufferedImage - you two will be tight friends in this project.

czech out: http://java.sun.com/docs/books/tutorial/2d/images/index.html
Offline cylab

JGO Knight


Medals: 34



« Reply #8 - Posted 2006-03-29 17:02:35 »

You might want to look at several of these tutorials: How can I learn the basics of Java imaging?

Mathias - I Know What [you] Did Last Summer!
Avenger
Guest
« Reply #9 - Posted 2006-03-29 18:14:28 »

Thanks for the tutorials people Smiley  I know how to use buffered image to an extent , (aka double buffering) but from there and on nothing else Smiley SOOOOO I hope I can improve with those tutorials Wink

Thanks a lot Smiley , study time ^_^
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.

xsi3rr4x (81 views)
2014-04-15 18:08:23

BurntPizza (73 views)
2014-04-15 03:46:01

UprightPath (84 views)
2014-04-14 17:39:50

UprightPath (67 views)
2014-04-14 17:35:47

Porlus (84 views)
2014-04-14 15:48:38

tom_mai78101 (107 views)
2014-04-10 04:04:31

BurntPizza (167 views)
2014-04-08 23:06:04

tom_mai78101 (263 views)
2014-04-05 13:34:39

trollwarrior1 (214 views)
2014-04-04 12:06:45

CJLetsGame (223 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!