I created this program to help draw a map in a text adventure I am creating. So far all it does is draw a black square of detentions you input. Is there a way to remove the space between each line so there aren't white lines running through the square?
Here is my code:
import java.util.Scanner;
public class MapGrid {
static String createGrid(int x, int y) {
String output = "";
String block = new String("\u2588\u2588"); //A string of two unicode block symbols: ██
if(x * y != 0) { //If neither x nor y is 0, a map of length x and height y will be returned
for(int n = 1; n <= y; n++) {
for(int i = 1; i <= x; i++) {
output += block;
}
output += "\n";
}
}
return output;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try(Scanner sc = new Scanner(System.in)) {
System.out.println("Please enter the length of your map");
int length = sc.nextInt();
System.out.println("Please enter the height of your map");
int height = sc.nextInt();
System.out.println(createGrid(length,height));
}
}
}
This is what it prints when the user inputs 5 and 5:
I took a screenshot because it was hard to see what I was talking about with this font
There is a small gap between each new line of blocks that makes it not look right. There probably isn't a way to fix this, but I thought I'd ask just in case there was.