old map thing
This commit is contained in:
parent
ca87f13623
commit
92a6ace93b
60
map/map.pde
60
map/map.pde
@ -1,7 +1,6 @@
|
||||
JSONArray json;
|
||||
|
||||
void setup() {
|
||||
size(800,800);
|
||||
// void setup() {
|
||||
// size(800,800);
|
||||
// json = loadJSONArray("map.json");
|
||||
|
||||
// JSONObject values = json.getJSONObject(1);
|
||||
@ -9,46 +8,49 @@ void setup() {
|
||||
// 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 draw() {
|
||||
// background(255);
|
||||
// generate_tiles();
|
||||
// }
|
||||
|
||||
void generate_tiles() {
|
||||
for (int i = 0; i < tiles_x.length; i++ ) {
|
||||
rect(tiles_x[i], tiles_y[i], tilesize.x, tilesize.y);
|
||||
for (int i = 0; i < level.length; i++ ) {
|
||||
rect(level[i][0]-screenx, level[i][1], level[i][2], level[i][3]);
|
||||
}
|
||||
}
|
||||
|
||||
void mouseReleased() {
|
||||
tiles_x = (int[])append(tiles_x, mouseX);
|
||||
tiles_y = (int[])append(tiles_y, mouseY);
|
||||
|
||||
println(tiles_x);
|
||||
int runnerRect = 0;
|
||||
void mouseReleased() {
|
||||
level[runnerRect][0] = mouseX+screenx;
|
||||
level[runnerRect][1] = mouseY;
|
||||
level[runnerRect][2] = 50;
|
||||
level[runnerRect][3] = 50;
|
||||
println("generated");
|
||||
runnerRect = runnerRect + 1;
|
||||
println(runnerRect);
|
||||
}
|
||||
|
||||
void keyPressed() {
|
||||
if (key == 's') {
|
||||
println("saved");
|
||||
int[][] level = new int[100][4];
|
||||
JSONArray json;
|
||||
|
||||
int savetofile(String filename) {
|
||||
json = new JSONArray();
|
||||
|
||||
for (int i = 0; i < tiles_x.length; i++) {
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
|
||||
JSONArray mapsave = new JSONArray();
|
||||
mapsave.setInt(0, tiles_x[i]);
|
||||
mapsave.setInt(1, tiles_y[i]);
|
||||
mapsave.setInt(0, level[i][0]);
|
||||
mapsave.setInt(1, level[i][1]);
|
||||
mapsave.setInt(2, level[i][2]);
|
||||
mapsave.setInt(3, level[i][3]);
|
||||
|
||||
json.setJSONArray(i, mapsave);
|
||||
}
|
||||
saveJSONArray(json, "map.json");
|
||||
}
|
||||
saveJSONArray(json, filename + ".json");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screenx = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user