i use the following to create the map
int[][] A = {
{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{12, 12, 12, 12, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{1, 1, 1, 1, 11, 5, 5, 5, 5, 5, 4, 5, 5, 5},
{3, 1, 1, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{3, 1, 1, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{1, 1, 1, 1, 11, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{1, 1, 1, 1, 11, 5, 5, 5, 5, 6, 12, 12, 12, 12},
{10, 10, 10, 10, 9, 5, 5, 5, 5, 13, 2, 2, 2, 2},
{5, 5, 5, 5, 5, 5, 5, 5, 5, 13, 2, 2, 3, 2},
{5, 5, 5, 5, 5, 5, 5, 5, 5, 13, 2, 2, 2, 2},
{5, 5, 5, 5, 5, 5, 5, 5, 5, 13, 2, 3, 2, 2},
{5, 4, 5, 5, 5, 5, 5, 5, 5, 13, 2, 2, 2, 2},
{5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 10, 10, 10, 10}
};
for(across = 0; across < width ; across++) {
for(vert = 0; vert < height ; vert++) {
if (A[vert][across] == 1)
{
g2.drawImage(gras,across*32,vert*32,this);
}
else if(A[vert][across]==2)
{
g2.drawImage(tree,across*32,vert*32,this);
}
else if(A[vert][across]==3)
{
g2.drawImage(mount,across*32,vert*32,this);
}
else if(A[vert][across]==4)
{
g2.drawImage(seamount,across*32,vert*32,this);
}
else if(A[vert][across]==5)
{
g2.drawImage(sea,across*32,vert*32,this);
}
else if(A[vert][across]==6)
{
g2.drawImage(sbr,across*32,vert*32,this);
}
else if(A[vert][across]==7)
{
g2.drawImage(sbl,across*32,vert*32,this);
}
else if(A[vert][across]==8)
{
g2.drawImage(str,across*32,vert*32,this);
}
else if(A[vert][across]==9)
{
g2.drawImage(stl,across*32,vert*32,this);
}
else if(A[vert][across]==10)
{
g2.drawImage(shoretop,across*32,vert*32,this);
}
else if(A[vert][across]==11)
{
g2.drawImage(shoreleft,across*32,vert*32,this);
}
else if(A[vert][across]==12)
{
g2.drawImage(shorebottom,across*32,vert*32,this);
}
else
{
g2.drawImage(shoreright,across*32,vert*32,this);
}
}
}
is there any way to set collision like J2ME?
// Returns to the previous position if there is an obstacle
if (map.getCell(shipX, shipY) == 4 || map.getCell(shipX, shipY) == 6 ||
map.getCell(shipX, shipY) == 7 || map.getCell(shipX, shipY) == 8
|| map.getCell(shipX, shipY) == 9 || map.getCell(shipX, shipY) == 10 ||
map.getCell(shipX, shipY) == 11 || map.getCell(shipX, shipY) == 12
|| map.getCell(shipX, shipY) == 13 || map.getCell(shipX, shipY) == 14)
{
shipX = preX;
shipY = preY;
like when it hits a certain location or a tile it will be stopped
from what i know j2me count by tile , mine is count by corrdinates
anyway to make a tile blocked?
thanks!