PDA

View Full Version : Explain please?



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.

samuraiblood2
January 6th, 2011, 13:37
What exactly don't you understand? Saying 'you don't know why its made like' that is a pretty broad question.

Ishana
January 6th, 2011, 14:58
That was my bad :p

I meant that I want to know how does it cut it to pieces so that when you do


int [][] map = {{0, 1, 2, 3},{4, 5, 6, 7}, {8, 9, 10, 11}};

it will show like this
Only the registered members can see the link.

samuraiblood2
January 6th, 2011, 15:02
That was my bad :p

I meant that I want to know how does it cut it to pieces so that when you do


int [][] map = {{0, 1, 2, 3},{4, 5, 6, 7}, {8, 9, 10, 11}};

it will show like this
Only the registered members can see the link.

Mind showing the original image?

Ishana
January 6th, 2011, 15:50
your looking at it

this
Only the registered members can see the link.
is the original image

the source I have posted

cuts it to pieces..

example when you make map like this


int [][] map = {
{3, 2, 0, 1},
{1, 0, 0, 1},
{1, 1, 1, 1}
};

it will be like (nvm the cursor)
Only the registered members can see the link.

If you still don't understand I will just give you the link to the place I got it from :p

samuraiblood2
January 6th, 2011, 15:56
your looking at it

this
Only the registered members can see the link.
is the original image

the source I have posted

cuts it to pieces..

example when you make map like this


int [][] map = {
{3, 2, 0, 1},
{1, 0, 0, 1},
{1, 1, 1, 1}
};

it will be like (nvm the cursor)
Only the registered members can see the link.


Ahh, I was assuming you were trying to make the first image from the second.


If you still don't understand I will just give you the link to the place I got it from :pI think I get what you're trying to do now, but the link would still be useful.

Ishana
January 6th, 2011, 16:01
Only the registered members can see the link.

samuraiblood2
January 6th, 2011, 16:18
Only the registered members can see the link.

I couldn't watch more than three minutes of that before I decided he's an idiot. Ill see if I cant make my own code to split the image up like how you wanted.

Ishana
January 6th, 2011, 16:47
Thanks alot =)