Original Post
Im making a lemming game, and want to use a collision mask "image" for collision detection, ala worms.
I have a material-interface wich contains 8 diffrent materials a pixel can be (byte), and each material have a int describing its color (int rgb).
I have a 2-dimension-array, byte[width][height] for the pixels on the screen.
When debugging i want to print the pixels in the right color on my screen (swing, jpanel).
Since graphics didnt have a way to draw/fill a point/pixel, i tried with creating rectangles with the size 1x1 and graphics.setColor() before i fill the rectangle:
for (..) {
for (..) {
g.setColor( new Color( int[][] ) )
g.fillRect( x, y, 1, 1);
}
}
Doing it this way, it was very slow and used 99% of my cpu, since i call the paint method every 80 ms, and does this each time..
I then tried to make a Image with ImageIcon(byte[]), and also testet with bufferedImage/Raster, but i had problems getting it to work.
My question is this:
1: What is the best way to display my array of pixels? Is there
2: Is there any tutorials or codes i can look at who does this? (I tried gooogling for a few hours, but didnt find anything usefull)
3: Any good hints for my collision mask?
[edited by - Eventh on April 22, 2004 7:38:51 AM]
[edited by - Eventh on April 22, 2004 7:39:26 AM]
[edited by - Eventh on April 22, 2004 7:39:55 AM]