public void drawMap(Graphics g, Image tileImages[]){
int drawDistanceX = 60;
int drawDistanceY = 60;
if (keyStatus == "DOWN"){
switch(key){
case 100:
if (mapX < mapWidth-20){mapX++; break;}
case 97:
if (mapX > 0){mapX--; break;}
}
}
if (mapWidth > 20){drawDistanceX = 20;}else{drawDistanceX = mapWidth;}
if (mapHeight > 15){drawDistanceY = 15;}else{drawDistanceY = mapHeight;}
for (int y = 0; y < drawDistanceY;y++){
for (int x = 0; x < drawDistanceX; x++){
if (mapTiles[x+(int)mapX][y+(int)mapY][0] > 0){
g.drawImage(tileImages[mapTiles[x+(int)mapX][y+(int)mapY][0]],x*16,y*16,null);
}
}
}
}