78 lines
1.4 KiB
Plaintext

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() {
// rectMode(CENTER);
// rect(50, 50, 100, 50);
// textAlign(CENTER);
// fill(0);
// text("test", 50, 50);
// noFill();
// play();
// helper();
if (ismenu) {
mainMenu();
} else if (isgame) {
play();
} else if (iseditor) {
mapEditor();
}
}
boolean ismenu = true;
boolean isgame = false;
boolean iseditor = false;
void mainMenu() {
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 mapEditor() {
background(255);
generate_tiles();
}
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 - 2/rectwidth && mouseX < x + rectwidth/2) && (mouseY > y - rectheight/2 && mouseY < y + rectheight/2)) {
return true;
} else {
return false;
}
}