Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (652)
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  
  Problem with color picker thing. [SOLVED :D]  (Read 1687 times)
0 Members and 1 Guest are viewing this topic.
Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Posted 2012-05-09 01:51:44 »

So, in the tile based game I am working on, I wanted to make my sprites have 4 gray scale colors, and then have each tile or entity set the colors when the object is created. I then load the colors and set the pixels to reflect what entity is being drawn. I am doing this so that I can have multiple monsters use the same art, but just change the color. I also just wanted to see if I could do it.

As it turns out, everything was working perfectly, until I tried to make the zombie use the same art as the player, but with different colors. When I start the game with the zombies using the same art, it will not appear at all for the zombies (the zombies only have one image, while the player has a whole walk cycle) and when the player gets to that image in his walk cycle, it doesn't show up at all, and looks like he is temporarily invisible.

I can't pinpoint what is making this happen, so I am asking you guys for a bit of help. I will enclose a link to a .zip that contains two .jars (one without zombies that works and one with zombies that doesn't work) and my eclipse work space with source.

I also should note that everything was rendering properly before I tried this out.

The only source files that should be needed are,,,, and maybe

Thanks so much,


Download files here.

Check out my website!
Offline jonjava
« Reply #1 - Posted 2012-05-09 09:31:34 »

Intentional medal there...

I haven't looked at the code (lazy), could you post some of the relevant drawing code?

What you want to do is get the pixels from the grey scale image and before drawing them adjust the colours.

Offline Luckssmith

Junior Newbie

Medals: 1

« Reply #2 - Posted 2012-05-10 01:34:08 »

I think the zombies and the first image of the player walk cycle don't appear because you are setting it to invisible colors in your zombie class:
public Zombie(int x, int y) {
      super(x, y, 0, 3);
      cols[0] = 255;
      cols[1] = 50;
      cols[2] = 100;
      cols[3] = 150;

Change that to something like this and your zombies and player should appear.
cols[0] = 0xff000000;
cols[1] = 0xff000065;
cols[2] = 0xff705200;
cols[3] = 0xffD35100;

However since you are always using the same source image ( sheet.sprites ), the first draw2(...) call will overwrite the grey scale pixels permanently making your check for the grey colors useless. That's why the first image of the players walk cycle disappeared when you added the zombies.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Reply #3 - Posted 2012-05-10 01:35:34 »

Ah, thanks.

Is there anyway to do this without overwriting the pixels on the actual image? I know this can be done, but I have no idea how.


Check out my website!
Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Reply #4 - Posted 2012-05-14 23:43:51 »

Never mind, I fixed it.

When I compare the image that it has loaded to the default colors, since it sets the image to the colors of the last image it used, I simply change the colors it is comparing against to the ones it just got done setting the image to.

Thanks for the help.


Check out my website!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

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

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

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

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

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

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

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

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

BurntPizza (25 views)
2015-07-24 06:06:53

NoxInc (33 views)
2015-07-22 22:16: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!