rebuild and map editor
This commit is contained in:
18
map/map.json
Normal file
18
map/map.json
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
[
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
417,
|
||||
414
|
||||
],
|
||||
[
|
||||
602,
|
||||
165
|
||||
],
|
||||
[
|
||||
308,
|
||||
296
|
||||
]
|
||||
]
|
||||
54
map/map.pde
Normal file
54
map/map.pde
Normal file
@@ -0,0 +1,54 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user