Hey guys so I thought of an idea and so far I've made some progress. I want to be able to change my levels terrain based on coordinates. The coordinates are selected based on where you click and is added on an ArrayList of Points. These points are then sorted by their x value and then drawn as follows:
public Image renderTerrain() throws SlickException {
Image image = new Image(MAP_WIDTH, MAP_HEIGHT);
Graphics gr = image.getGraphics();
int startx = 0;
int starty = 0;
for(Point point : points) {
starty = (int) point.getY();
int tox = (int) point.getX();
int toy = (int) point.getY();
for(int x = startx; x < tox; x++) {
for(int y = starty; y < MAP_HEIGHT; y++) {
gr.drawLine(x,y,x,y);
}
}
startx = tox;
}
gr.flush();
return image;
}
This would render something like so:
However What I want to achieve is like so.
What alterations would I need to make in order to achieve this?
Thanks.