55 lines
963 B
Plaintext
55 lines
963 B
Plaintext
JSONArray json;
|
|
|
|
void setup() {
|
|
size(800,800);
|
|
// json = loadJSONArray("map.json");
|
|
|
|
// JSONObject values = json.getJSONObject(1);
|
|
|
|
// int x = values.getInt("x");
|
|
// print(x);
|
|
|
|
}
|
|
|
|
void draw() {
|
|
background(255);
|
|
generate_tiles();
|
|
}
|
|
|
|
PVector tilesize = new PVector(50, 50);
|
|
int[] tiles_x = {50};
|
|
int[] tiles_y = {50};
|
|
void pickTiles() {
|
|
|
|
}
|
|
|
|
void generate_tiles() {
|
|
for (int i = 0; i < tiles_x.length; i++ ) {
|
|
rect(tiles_x[i], tiles_y[i], tilesize.x, tilesize.y);
|
|
}
|
|
}
|
|
|
|
void mouseReleased() {
|
|
tiles_x = (int[])append(tiles_x, mouseX);
|
|
tiles_y = (int[])append(tiles_y, mouseY);
|
|
|
|
println(tiles_x);
|
|
}
|
|
|
|
void keyPressed() {
|
|
if (key == 's') {
|
|
println("saved");
|
|
json = new JSONArray();
|
|
|
|
for (int i = 0; i < tiles_x.length; i++) {
|
|
|
|
JSONArray mapsave = new JSONArray();
|
|
mapsave.setInt(0, tiles_x[i]);
|
|
mapsave.setInt(1, tiles_y[i]);
|
|
|
|
json.setJSONArray(i, mapsave);
|
|
}
|
|
saveJSONArray(json, "map.json");
|
|
}
|
|
}
|