void setup() { size(800,800); frameRate(60); smooth(4); // saveFileChecker(); level = loadJson("./saves/save.json"); } void saveFileChecker() { File f = dataFile("./saves/save.json"); String filePath = f.getPath(); boolean exist = f.isFile(); println(filePath, exist); if (!exist) { } }; void draw() { // play(); // helper(); debug(); if (ismenu) { mainMenu(); } else if (isgame) { play(); } else if (iseditor) { mapEditor(); } } boolean ismenu = true; boolean isgame = false; boolean iseditor = false; void mainMenu() { background(14, 181, 59); if (drawRectWithColission(width/2, height/2, 100, 100)) { if (mousePressed) { ismenu = false; isgame = true; } } if (drawRectWithColission(width/2, height/2+200, 100, 100)) { if (mousePressed) { ismenu = false; iseditor = true; } } } void menuButton() { if (drawRectWithColission(50, 50, 80, 40)) { if (mousePressed) { ismenu = true; iseditor = false; isgame = false; moveTilesBack(); } } } void mapEditor() { background(255); baseline(); generate_editor_tiles(); // generate_tiles(); menuButton(); } boolean drawRectWithColission(int x, int y, int rectwidth, int rectheight) { // Draw A Rect rectMode(CENTER); rect(x, y, rectwidth, rectheight); // Check it for collission if((mouseX > x - rectwidth/2 && mouseX < x + rectwidth/2) && (mouseY > y - rectheight/2 && mouseY < y + rectheight/2)) { return true; } else { return false; } } void debug() { // println(screenoffset); // println(level[0][0]); } // Neat helper function, that gives us coordinates of point while clicking void helper() { if (mousePressed == true){ println(mouseX, mouseY); } }