Ishana
January 6th, 2011, 13:06
Can anyone explain this please?
I don't get it at all :p
I know what it does but I don't know why it was made like that :p
AMG I am confused
Only the registered members can see the link.
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class gui extends JPanel {
int row,column;
BufferedImage tileSet;
int [][] map = {
{3, 2, 0, 1},
{1, 0, 0, 1},
{1, 1, 1, 1}
};
public gui(){
try {
tileSet = ImageIO.read(new File("tile.png"));
} catch (IOException e) {}
}
public void updateGui(){
repaint();
}
public void paintComponent(Graphics g) {
for (row=0; row < map.length; row++){
for (column=0; column < map[row].length; column++){
g.drawImage(tileSet, column*32, row*32, column *32+32, row*32+32, map[row][column]*32, 0, map[row][column]*32+32, 32, null);
}
}
}
}
screenshot of what it looks like
Only the registered members can see the link.
I don't get it at all :p
I know what it does but I don't know why it was made like that :p
AMG I am confused
Only the registered members can see the link.
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class gui extends JPanel {
int row,column;
BufferedImage tileSet;
int [][] map = {
{3, 2, 0, 1},
{1, 0, 0, 1},
{1, 1, 1, 1}
};
public gui(){
try {
tileSet = ImageIO.read(new File("tile.png"));
} catch (IOException e) {}
}
public void updateGui(){
repaint();
}
public void paintComponent(Graphics g) {
for (row=0; row < map.length; row++){
for (column=0; column < map[row].length; column++){
g.drawImage(tileSet, column*32, row*32, column *32+32, row*32+32, map[row][column]*32, 0, map[row][column]*32+32, 32, null);
}
}
}
}
screenshot of what it looks like
Only the registered members can see the link.