This commit is contained in:
Makussu 2023-10-21 00:41:17 +02:00
parent b269d39f62
commit ca87f13623
3 changed files with 48 additions and 16 deletions

View File

@ -35,7 +35,6 @@ void play() {
// calculate actual position on ground
// actualPos = height - pos.y;
background(255);
// player
rectMode(CENTER);
@ -85,8 +84,8 @@ void newJump() {
// TODO Collision erweitern wie in https://happycoding.io/tutorials/processing/collision-detection
void collisionTest() {
// Collision with baseline
if ( pos.y > 0.875*height - playerRadius/2 ) {
pos.set(pos.x, 0.875*height - playerRadius/2);
if ( pos.y > 0.850*height - playerRadius/2 ) {
pos.set(pos.x, 0.850*height - playerRadius/2);
}
// Collision with all the tiles bottom site

View File

@ -4,8 +4,8 @@ void setup() {
smooth(4);
drawBackground();
// level = loadJson("./saves/save.json");
level = loadJson("./saves/save.json");
}
// not done yet
@ -22,13 +22,14 @@ void saveFileChecker() {
void draw() {
// debug();
// if (ismenu) {
// mainMenu();
// } else if (isgame) {
// play();
// } else if (iseditor) {
// mapEditor();
// }
if (ismenu) {
mainMenu();
} else if (isgame) {
drawBackground();
play();
} else if (iseditor) {
mapEditor();
}
}
boolean ismenu = true;
@ -53,7 +54,7 @@ void mainMenu() {
}
}
// exit game
if (drawRectWithMouseColission(50, 50, 80, 40)) {
if (drawRectWithMouseColission(50, 100, 80, 40)) {
if (mousePressed) {
exit();
}

View File

@ -24,12 +24,44 @@ void generate_editor_tiles() {
}
void baseRect() {
line(0, 0.875*height, width, 0.875*height);
fill(100);
quad(0, 0.875*height, width, 0.875*height, width, height, 0, height);
line(0, 0.850*height, width, 0.850*height);
fill(255);
}
// Background
void drawBackground() {
color sky = color(94, 218, 252);
color sand = color(235, 218, 174);
color darksand = color(232, 177, 120);
color sea = color(51, 169, 255);
color seaend = color(146, 254, 255);
// sky
background(sky);
// sea
// for(int y = 400; y < 650; y++){
// float inter = map(y, 400, 650, 0, 1);
// color c = lerpColor(sea, seaend, inter);
// stroke(c);
// line(0, y, width, y);
// noStroke();
// }
fill(sea);
quad(0, 400, width, 400, width, 650, 0, 650);
// Beach
fill(sand);
quad(0, 650, width, 650, width, height, 0, height);
// Player stands on this
fill(darksand);
quad(0, 0.850*height, width, 0.850*height, width, height, 0, height);
fill(0);
}
void drawCloud() {
ellipse(224, 184, 220, 220);
}
//// This Handles loading and saving the level
// TODO Check if json is empty. If it is generate level
// int[][] level = new int[100][4];