I've come across a rather troubling point in my video game that I am building in Java. Before you go and set this as spam, please note that I have taken a look at both of these links and they have not helped me in any way:
- Drawing a transparent BufferedImage over a non-transparent BufferedImage
- Making a Certain Color on a BufferedImage Become Transparent
What I need to do is get the color 0xFF00FF from my sprites and set it to transparent so that the charecter shows up, not just the background behind him. Here's what I have:
(Sorry about not having enough "reputation", but here's a link to the image.) https://plus.google.com/photos/yourphotos?enfplm&hl=en&utm_source=lmnavbr&utm_medium=embd&utm_campaign=lrnmre&rtsl=1&partnerid=selm0&pid=5940308896707611042&oid=114903427794927596233
I have a main BufferedImage and a pixels[] array for the data in that image, and I render the level to the screen, and then render the player afterwards. Here's my method for updating the image before rendering it:
private void tickImage() {
final int centerY = (HEIGHT / 2) - (48 / 2);
final int centerX = (WIDTH / 2) - (48 / 2);
display.clear();
display.renderBlock(StoneBlock.block, xMove, yMove);
display.renderPlayer(knight, centerX, centerY);
for (int a = 0; a < pixels.length; a++) {
pixels[a] = display.pixels[a];
}
}
If you would like to look at the rest of the code, please, feel free to here:
https://github.com/NikolaAndMichael/WarDungeon/tree/master/WarDungeon/src/net/naprav/wardungeon
Thank you in advance.