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 (534)
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 1400 times)
0 Members and 1 Guest are viewing this topic.
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Posted 2012-05-09 03: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 Zombie.java, Entity.java, Screen.java, Level.java, and maybe Player.java.

Thanks so much,

-Nathan

Download files here.

Check out my website!
Offline jonjava
« Reply #1 - Posted 2012-05-09 11: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 03: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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
public Zombie(int x, int y) {
      super(x, y, 0, 3);
      newWaitTime();
     
      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.
1  
2  
3  
4  
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: 4
Projects: 2


Nathan Kramber


« Reply #3 - Posted 2012-05-10 03: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.

-Nathan

Check out my website!
Offline StonePickaxes

JGO Coder


Medals: 4
Projects: 2


Nathan Kramber


« Reply #4 - Posted 2012-05-15 01: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.

-Nathan

Check out my website!
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 (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

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

Riven (56 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!