Hi,
I am very new with game programing and gtge and I find the whole idea behind GTGE to be very good. I have two questions:
1) If I create a sprite and initialize it with a png image, the image borders look very bad although the image itself is ok. I attached the png I am using and a screenshot with the rendered sprite in the game window.
The code I am using is this one:
public class MyGame extends Game{
public static void main(String[] args) {
GameLoader loader = new GameLoader();
loader.setup(new MyGame(), new Dimension(400, 300), false);
loader.start();
}
Sprite hero;
@Override
public void initResources() {
hero = new Sprite(getImage("media/Char1.png"), 100, 10);
}
@Override
public void update(long elapsedTime) {
hero.update(elapsedTime);
}
@Override
public void render(Graphics2D g) {
hero.render(g);
}
}
I have tested this code in Kubuntu and Ubuntu (Karmic), with and without desktop effects enabled and I always get this bad rendered image. I created the image with Inkscape and exported it to png with Inkscape itself.
2) I want to make this sprite move, like when I type the down key, the sprite should move down and so on. I succeeded in doing this by following the tutorial. Now I want my sprite to change animation depending on the direction it is moving. I would use for this a selfmade png-spritesheet with say 12 images on it (3 for every direction). The sprite should stay still if the user doesn't type any arrow key and should animate according to the pushed key.
My question is how do I do that: animate while some key is pushed and stop animation on keyboard idle.
I managed to move the sprite by downloading the sourse of Warlok (which is a great game) and looking at the code. Thanks for opensourceing the code!
Does anyone have the afore mentioned problem with png Graphics? In pure swing aplications my pictures are shown with clear borders, only when I load them into a gtge Game class they have bad borders which make the game look terrible.
It is possible to do palette-swapping, but not especially easy. If you have indexed-colour images, your best bet is probably to load the file into memory, alter the PLTE chunk, and then re-load the image. If you want to get fancy you can try making a packed binary file with PNG chunks that you mix-and-match into a well-formed PNG file within a scrap byte[] and then pass to the loading routine. You can even edit colours at runtime, but then you will also need to calculate some checksums.
she got used to carrying a louis vuitton speedy with her,meless yet resolutely modern, this Croco Louis Vuitton Seasonal Collection louis vuitton neverfull handbag is ideal both for traveling.Designer Inspired Black louis vuitton evidence Sunglasses These Designer Inspired Black .Learn about the hottest pradaaccessories of the season. Visit our active Prada Forum!