all work today
This commit is contained in:
parent
a527307ee1
commit
82e3afcfe5
@ -13,7 +13,7 @@
|
|||||||
float speed = 20;
|
float speed = 20;
|
||||||
float gravitation = 9.81;
|
float gravitation = 9.81;
|
||||||
float jumpheight;
|
float jumpheight;
|
||||||
float jumpcooldown = 12;
|
boolean canjump = true;
|
||||||
|
|
||||||
// for moving x-axis (mostly depracted)
|
// for moving x-axis (mostly depracted)
|
||||||
// But dont delete yet!!
|
// But dont delete yet!!
|
||||||
@ -23,12 +23,12 @@ int playerRadius = 25;
|
|||||||
|
|
||||||
// float actualPos;
|
// float actualPos;
|
||||||
|
|
||||||
PVector tilesize = new PVector(50, 50);
|
PVector tilesize = new PVector(100, 50);
|
||||||
|
|
||||||
int[][] level;
|
int[][] level;
|
||||||
|
|
||||||
int tilesmoved = 0;
|
int tilesmoved = 0;
|
||||||
int tilespeed = 3;
|
int tilespeed = 4;
|
||||||
|
|
||||||
// The actual game
|
// The actual game
|
||||||
void play() {
|
void play() {
|
||||||
@ -86,6 +86,7 @@ void collisionTest() {
|
|||||||
// Collision with baseline
|
// Collision with baseline
|
||||||
if ( pos.y > 0.850*height - playerRadius/2 ) {
|
if ( pos.y > 0.850*height - playerRadius/2 ) {
|
||||||
pos.set(pos.x, 0.850*height - playerRadius/2);
|
pos.set(pos.x, 0.850*height - playerRadius/2);
|
||||||
|
canjump = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collision with all the tiles bottom site
|
// Collision with all the tiles bottom site
|
||||||
@ -93,13 +94,16 @@ void collisionTest() {
|
|||||||
boolean xSideEdges = pos.x > level[i][0] - tilesize.x/2 && pos.x < level[i][0] + tilesize.x/2;
|
boolean xSideEdges = pos.x > level[i][0] - tilesize.x/2 && pos.x < level[i][0] + tilesize.x/2;
|
||||||
boolean ySideEdges = pos.y < level[i][1] + tilesize.y/2 && pos.y > level[i][1] - tilesize.y/2;
|
boolean ySideEdges = pos.y < level[i][1] + tilesize.y/2 && pos.y > level[i][1] - tilesize.y/2;
|
||||||
|
|
||||||
|
if (level[i][4] == 0) {
|
||||||
// Bottom
|
// Bottom
|
||||||
if ( (xSideEdges) && (ySideEdges)) {
|
if ( (xSideEdges) && (ySideEdges)) {
|
||||||
pos.set(pos.x, level[i][1] + tilesize.y/2);
|
pos.set(pos.x, level[i][1] + tilesize.y/2);
|
||||||
}
|
}
|
||||||
// Top
|
// Top
|
||||||
if ( (xSideEdges) && (pos.y < level[i][1] + tilesize.y/2 && pos.y > level[i][1] - tilesize.y/2 - playerRadius)) {
|
if ( (xSideEdges) && (pos.y < level[i][1] + tilesize.y/2 && pos.y > level[i][1] - tilesize.y/2 - playerRadius)) {
|
||||||
pos.set(pos.x, level[i][1] - tilesize.y/2 - 15);
|
pos.set(pos.x, level[i][1] - tilesize.y/2 - 15);
|
||||||
|
canjump = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,10 @@ void keyPressed () {
|
|||||||
// pos.x = pos.x + direction.x * speed;
|
// pos.x = pos.x + direction.x * speed;
|
||||||
// }
|
// }
|
||||||
} else if (key == ' ') {
|
} else if (key == ' ') {
|
||||||
jumpspeed =+ 30;
|
if(canjump) {
|
||||||
|
jumpspeed =+ 31;
|
||||||
|
canjump = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (iseditor) {
|
} else if (iseditor) {
|
||||||
if (key == 's') {
|
if (key == 's') {
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
import processing.sound.*;
|
||||||
|
SoundFile jumpsound;
|
||||||
|
SoundFile deathsound;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
size(800,800);
|
size(800,800);
|
||||||
frameRate(60);
|
frameRate(60);
|
||||||
@ -25,30 +29,48 @@ boolean iseditor = false;
|
|||||||
|
|
||||||
// This is the start screen and main menu. It has a few Buttons
|
// This is the start screen and main menu. It has a few Buttons
|
||||||
void mainMenu() {
|
void mainMenu() {
|
||||||
background(14, 181, 59);
|
background(246, 244, 235);
|
||||||
|
|
||||||
|
fill(116, 155, 194);
|
||||||
|
textSize(128);
|
||||||
|
textAlign(CENTER);
|
||||||
|
text("p4dash", width/2, height/2 - 100);
|
||||||
// go to game
|
// go to game
|
||||||
if (drawRectWithMouseColission(width/2, height/2, 100, 100)) {
|
fill(70, 130, 169);
|
||||||
|
if (drawRectWithMouseColission(width/2, height/2, 300, 100)) {
|
||||||
if (mousePressed) {
|
if (mousePressed) {
|
||||||
ismenu = false;
|
ismenu = false;
|
||||||
isgame = true;
|
isgame = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// go to menu
|
fill(0);
|
||||||
if (drawRectWithMouseColission(width/2, height/2+200, 100, 100)) {
|
textSize(40);
|
||||||
|
text("Play", width/2, height/2);
|
||||||
|
// go to editor
|
||||||
|
fill(70, 130, 169);
|
||||||
|
if (drawRectWithMouseColission(width/2, height/2+200, 300, 100)) {
|
||||||
if (mousePressed) {
|
if (mousePressed) {
|
||||||
ismenu = false;
|
ismenu = false;
|
||||||
iseditor = true;
|
iseditor = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fill(0);
|
||||||
|
textSize(40);
|
||||||
|
text("Editor", width/2, height/2+200);
|
||||||
|
fill(145, 200, 228);
|
||||||
// exit game
|
// exit game
|
||||||
if (drawRectWithMouseColission(50, 100, 80, 40)) {
|
if (drawRectWithMouseColission(50, 100, 80, 40)) {
|
||||||
if (mousePressed) {
|
if (mousePressed) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fill(0);
|
||||||
|
textSize(40);
|
||||||
|
text("Exit", 50, 110);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menuButton() {
|
void menuButton() {
|
||||||
|
fill(145, 200, 228);
|
||||||
if (drawRectWithMouseColission(50, 50, 80, 40)) {
|
if (drawRectWithMouseColission(50, 50, 80, 40)) {
|
||||||
if (mousePressed) {
|
if (mousePressed) {
|
||||||
ismenu = true;
|
ismenu = true;
|
||||||
@ -58,6 +80,9 @@ void menuButton() {
|
|||||||
savetofile("save");
|
savetofile("save");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fill(0);
|
||||||
|
textSize(40);
|
||||||
|
text("Exit", 50, 50+10);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map Editor Mode
|
// Map Editor Mode
|
||||||
@ -97,6 +122,19 @@ boolean drawTriangleWithMouseColission(int x, int y, int rectwidth, int rectheig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean drawTriangleWithPlayerColission(int x, int y, int rectwidth, int rectheight) {
|
||||||
|
// Draw A Rect
|
||||||
|
rectMode(CENTER);
|
||||||
|
triangle(x - rectwidth/2, y, x + rectwidth/2, y, x, y - rectheight);
|
||||||
|
|
||||||
|
// Check it for collission
|
||||||
|
if(dist(pos.x, pos.y, x+rectwidth/2, y-rectheight/2) < rectheight/2) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// These are my Debugger Functions
|
// These are my Debugger Functions
|
||||||
void debug() {
|
void debug() {
|
||||||
// println(screenoffset);
|
// println(screenoffset);
|
||||||
|
|||||||
14
game/map.pde
14
game/map.pde
@ -13,7 +13,9 @@ void generate_tiles() {
|
|||||||
if (level[i][4] == 0) {
|
if (level[i][4] == 0) {
|
||||||
rect(level[i][0]-screenx, level[i][1], level[i][2], level[i][3]);
|
rect(level[i][0]-screenx, level[i][1], level[i][2], level[i][3]);
|
||||||
} else {
|
} else {
|
||||||
triangle(level[i][0]-level[i][2]/2 -screenx, level[i][1], level[i][0]+level[i][2]/2, level[i][1], level[i][0], level[i][1]-level[i][3]);
|
if (drawTriangleWithPlayerColission(level[i][0] -screenx, level[i][1], level[i][2], level[i][3])) {
|
||||||
|
moveTilesBack(tilespeed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,14 +86,16 @@ void drawBackground() {
|
|||||||
fill(sun);
|
fill(sun);
|
||||||
ellipse(130, 100, 70, 70);
|
ellipse(130, 100, 70, 70);
|
||||||
|
|
||||||
|
|
||||||
fill(0);
|
|
||||||
|
|
||||||
randomSeed(0);
|
randomSeed(0);
|
||||||
drawPalm(100, 700);
|
drawPalm(100, 700);
|
||||||
drawPalm(200, 700);
|
drawPalm(200, 700);
|
||||||
drawPalm(300, 700);
|
drawPalm(300, 700);
|
||||||
drawPalm(400, 700);
|
drawPalm(400, 700);
|
||||||
|
|
||||||
|
fill(darksand);
|
||||||
|
point(500, 770);
|
||||||
|
|
||||||
|
fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No Clouds yet
|
// No Clouds yet
|
||||||
@ -144,7 +148,7 @@ boolean checkSaveFile(String filepath) {
|
|||||||
|
|
||||||
// Check if there already is a safefile and load it if it is possible. If not load empty array
|
// Check if there already is a safefile and load it if it is possible. If not load empty array
|
||||||
int[][] loadJson(String jsonfile) {
|
int[][] loadJson(String jsonfile) {
|
||||||
if (checkSaveFile("./saves/save.json")) {
|
if (!checkSaveFile("./saves/save.json")) {
|
||||||
JSONArray values = loadJSONArray(jsonfile);
|
JSONArray values = loadJSONArray(jsonfile);
|
||||||
// println(values.size());
|
// println(values.size());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user