Compare commits

...

9 Commits

Author SHA1 Message Date
Maximilian Ruhm
eafd6f3d92 finish 2023-10-23 19:11:26 +02:00
46cb3f22c4 editor fix 2023-10-23 00:42:12 +02:00
98e71893f4 maintheme 2023-10-22 23:20:16 +02:00
b78310728e sounds 2023-10-22 23:07:22 +02:00
82e3afcfe5 all work today 2023-10-22 22:58:49 +02:00
Maximilian Ruhm
a527307ee1 code quality 2023-10-22 14:02:08 +02:00
175c0d238e beautify and prepare for losing 2023-10-22 01:39:39 +02:00
Maximilian Ruhm
0db9e72d8d sun 2023-10-21 13:06:37 +02:00
92a6ace93b old map thing 2023-10-21 00:52:46 +02:00
9 changed files with 440 additions and 159 deletions

View File

@@ -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,6 +94,7 @@ 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);
@@ -100,6 +102,8 @@ void collisionTest() {
// 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;
}
} }
} }
} }

View File

@@ -1,7 +1,18 @@
// } else if (key == 'l') { // Here are all the keys that are used
// println(loadJSONArray("../map/map.json"));
boolean iseditorModeRect = true;
boolean iseditorModeSpike = false;
float volume = 0.2;
void keyPressed () { void keyPressed () {
if (key == 'm') {
if (volume == 0.2) {
volume = 0;
} else {
volume = 0.2;
}
gamesoundtrack.amp(volume);
}
if (ismenu) { if (ismenu) {
} else if (isgame) { } else if (isgame) {
if (key == CODED) { if (key == CODED) {
@@ -13,12 +24,25 @@ 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;
jumpsound.play();
}
} }
} else if (iseditor) { } else if (iseditor) {
if (key == 's') { if (key == 's') {
savetofile("save"); savetofile("save");
println("saved"); println("saved");
} else if (key == ' ') {
if(iseditorModeRect) {
iseditorModeRect = false;
iseditorModeSpike = true;
} else if (iseditorModeSpike) {
iseditorModeRect = true;
iseditorModeSpike = false;
}
println("mode changed");
} else if (key == CODED) { } else if (key == CODED) {
if (keyCode == RIGHT) { if (keyCode == RIGHT) {
screenx = screenx + 50; screenx = screenx + 50;
@@ -33,17 +57,30 @@ void keyPressed () {
} }
} }
// Add tiles in editor mode
int runnerRect = 0; int runnerRect = 0;
void mouseReleased() { void mouseReleased() {
if(iseditor) { if(iseditor) {
if (mouseButton == LEFT) { if (mouseButton == LEFT) {
if(iseditorModeRect) {
level[runnerRect][0] = mouseX+screenx; level[runnerRect][0] = mouseX+screenx;
level[runnerRect][1] = mouseY; level[runnerRect][1] = mouseY;
level[runnerRect][2] = 100; level[runnerRect][2] = 100;
level[runnerRect][3] = 50; level[runnerRect][3] = 50;
level[runnerRect][4] = 0;
println("generated");
runnerRect = runnerRect + 1;
println(runnerRect);
} else if (iseditorModeSpike) {
level[runnerRect][0] = mouseX+screenx;
level[runnerRect][1] = mouseY;
level[runnerRect][2] = 50;
level[runnerRect][3] = 50;
level[runnerRect][4] = 1;
println("generated"); println("generated");
runnerRect = runnerRect + 1; runnerRect = runnerRect + 1;
println(runnerRect); println(runnerRect);
} }
} }
}
} }

View File

@@ -1,24 +1,22 @@
import processing.sound.*;
SoundFile jumpsound;
SoundFile deathsound;
SoundFile gamesoundtrack;
void setup() { void setup() {
jumpsound = new SoundFile(this, "./sounds/jump.mp3");
deathsound = new SoundFile(this, "./sounds/fail.mp3");
gamesoundtrack = new SoundFile(this, "./sounds/maintheme.mp3");
gamesoundtrack.loop(1, 0.2);
size(800,800); size(800,800);
frameRate(60); frameRate(60);
smooth(4); smooth(4);
level = loadJson("./saves/save.json"); level = loadJson("./saves/save.json");
} }
// not done yet
void saveFileChecker() {
File f = dataFile("./saves/save.json");
String filePath = f.getPath();
boolean exist = f.isFile();
println(filePath, exist);
if (!exist) {
}
};
void draw() { void draw() {
// debug(); // debug();
@@ -36,32 +34,57 @@ boolean ismenu = true;
boolean isgame = false; boolean isgame = false;
boolean iseditor = false; boolean iseditor = false;
// 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);
textAlign(CENTER);
text("Exit", 50, 110);
// Text in corner
textAlign(LEFT);
fill(0);
textSize(20);
text("m - mute audio", 10, 700);
} }
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;
@@ -69,18 +92,33 @@ void menuButton() {
isgame = false; isgame = false;
moveTilesBack(tilespeed); moveTilesBack(tilespeed);
savetofile("save"); savetofile("save");
screenx = 0;
} }
} }
fill(0);
textSize(40);
textAlign(CENTER);
text("Exit", 50, 50+10);
} }
// Map Editor Mode
void mapEditor() { void mapEditor() {
background(255); background(255);
baseRect(); baseRect();
generate_editor_tiles(); generate_editor_tiles();
// generate_tiles(); // generate_tiles();
menuButton(); menuButton();
// Texts at Top
textAlign(RIGHT);
textSize(20);
text("SPACE - Toggle between rect and triangle", 790, 50);
text("Left Click - Place block", 790, 70);
text("Right Click - Delete Block", 790, 90);
text("Arrows - Move right and left", 790, 110);
} }
// Rectangle with editor colission
boolean drawRectWithMouseColission(int x, int y, int rectwidth, int rectheight) { boolean drawRectWithMouseColission(int x, int y, int rectwidth, int rectheight) {
// Draw A Rect // Draw A Rect
rectMode(CENTER); rectMode(CENTER);
@@ -94,6 +132,34 @@ boolean drawRectWithMouseColission(int x, int y, int rectwidth, int rectheight)
} }
} }
// Triangle with editor colission
boolean drawTriangleWithMouseColission(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(mouseX, mouseY, x+rectwidth/2, y-rectheight/2) < rectheight/1.5) {
return true;
} else {
return false;
}
}
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
void debug() { void debug() {
// println(screenoffset); // println(screenoffset);
// println(level[0][0]); // println(level[0][0]);

View File

@@ -1,15 +1,31 @@
// BUG level editor x position bleibt ingame
// TODO Completly rework colission
// TODO Die when touching triangle
// moveTilesBack() and High Score Tracking
// No Unlimited Jumping
int screenx = 0; int screenx = 0;
// level generation // level generation for playable
void generate_tiles() { void generate_tiles() {
stroke(0);
for (int i = 0; i < level.length; i++ ) { for (int i = 0; i < level.length; i++ ) {
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 {
if (drawTriangleWithPlayerColission(level[i][0] -screenx, level[i][1], level[i][2], level[i][3])) {
moveTilesBack(tilespeed);
deathsound.play();
}
}
} }
} }
// Generate the tiles for Editor View (tiles that are deletable with mouse)
void generate_editor_tiles() { void generate_editor_tiles() {
for (int i = 0; i < 100; i++ ) { for (int i = 0; i < 100; i++ ) {
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]);
if(level[i][4] == 0) {
if (drawRectWithMouseColission(level[i][0]-screenx, level[i][1], level[i][2], level[i][3])) { if (drawRectWithMouseColission(level[i][0]-screenx, level[i][1], level[i][2], level[i][3])) {
if (mousePressed && iseditor) { if (mousePressed && iseditor) {
if (mouseButton == RIGHT) { if (mouseButton == RIGHT) {
@@ -17,6 +33,20 @@ void generate_editor_tiles() {
level[i][1] = 0; level[i][1] = 0;
level[i][2] = 0; level[i][2] = 0;
level[i][3] = 0; level[i][3] = 0;
level[i][4] = 0;
}
}
}
} else {
if (drawTriangleWithMouseColission(level[i][0]-screenx, level[i][1], level[i][2], level[i][3])) {
if (mousePressed && iseditor) {
if (mouseButton == RIGHT) {
level[i][0] = 0;
level[i][1] = 0;
level[i][2] = 0;
level[i][3] = 0;
level[i][4] = 0;
}
} }
} }
} }
@@ -28,45 +58,76 @@ void baseRect() {
fill(255); fill(255);
} }
// Background // Draws all the Background elements like sea and Beach
void drawBackground() { void drawBackground() {
color sky = color(94, 218, 252); color sky = color(94, 218, 252);
color sand = color(235, 218, 174); color sand = color(235, 218, 174);
color darksand = color(232, 177, 120); color darksand = color(232, 177, 120);
color darkersand = color(166, 110, 51);
color sea = color(51, 169, 255); color sea = color(51, 169, 255);
color seaend = color(146, 254, 255); color seaend = color(146, 254, 255);
color sun = color(247, 178, 2);
// sky // sky
background(sky); background(sky);
// sea // sea
// for(int y = 400; y < 650; y++){ for(int y = 400; y < 650; y++){
// float inter = map(y, 400, 650, 0, 1); float inter = map(y, 400, 650, 0, 1);
// color c = lerpColor(sea, seaend, inter); color c = lerpColor(sea, seaend, inter);
// stroke(c); stroke(c);
// line(0, y, width, y); line(0, y, width, y);
// noStroke(); noStroke();
// } }
fill(sea);
quad(0, 400, width, 400, width, 650, 0, 650);
// Beach // Beach
fill(sand); fill(sand);
quad(0, 650, width, 650, width, height, 0, height); quad(0, 650, width, 650, width, height, 0, height);
// Player stands on this // Player stands on this
fill(darksand); fill(darksand);
quad(0, 0.850*height, width, 0.850*height, width, height, 0, height); quad(0, 0.850*height, width, 0.850*height, width, height, 0, height);
//sun
fill(sun);
ellipse(130, 100, 70, 70);
randomSeed(0);
drawPalm(100, 700);
drawPalm(200, 700);
drawPalm(300, 700);
drawPalm(400, 700);
fill(0, 200);
stroke(darkersand);
for (int i = 0; i < 500; i++) {
point(random(0, width), random(700, 800));
}
stroke(0);
fill(0); fill(0);
} }
// No Clouds yet
void drawCloud() { void drawCloud() {
ellipse(224, 184, 220, 220); ellipse(224, 184, 220, 220);
} }
// Draws a slightly randomised Palm
void drawPalm(int startingpoint_x, int startingpoint_y) {
fill(108, 88, 51);
float randomnumber = int(random(10, 16));
float schwanken = int(random(-2, 2));
int offset = 8;
PVector endpoint = new PVector(startingpoint_x, startingpoint_y - randomnumber * offset);
for (int i = 0; i <= randomnumber; i++) {
triangle(endpoint.x+i*schwanken, endpoint.y+i*offset, endpoint.x+10+i*schwanken, endpoint.y+10+i*offset, endpoint.x+20+i*schwanken, endpoint.y+i*offset);
}
fill(93, 133, 47);
quad(endpoint.x+10, endpoint.y, endpoint.x - 12, endpoint.y - 8, endpoint.x - 50, endpoint.y + 20, endpoint.x - 5, endpoint.y + 12);
quad(endpoint.x+10, endpoint.y, endpoint.x + 22, endpoint.y - 8, endpoint.x + 60, endpoint.y + 20, endpoint.x + 15, endpoint.y + 12);
}
//// This Handles loading and saving the level //// This Handles loading and saving the level
// TODO Check if json is empty. If it is generate level
// int[][] level = new int[100][4];
JSONArray json; JSONArray json;
// This saves the Current save to file
int savetofile(String filename) { int savetofile(String filename) {
json = new JSONArray(); json = new JSONArray();
@@ -77,6 +138,7 @@ int savetofile(String filename) {
mapsave.setInt(1, level[i][1]); mapsave.setInt(1, level[i][1]);
mapsave.setInt(2, level[i][2]); mapsave.setInt(2, level[i][2]);
mapsave.setInt(3, level[i][3]); mapsave.setInt(3, level[i][3]);
mapsave.setInt(4, level[i][4]);
json.setJSONArray(i, mapsave); json.setJSONArray(i, mapsave);
} }
@@ -84,8 +146,13 @@ int savetofile(String filename) {
return 1; return 1;
} }
boolean checkSaveFile(String filepath) {
return new File(dataPath(filepath)).exists();
}
// 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")) {
JSONArray values = loadJSONArray(jsonfile); JSONArray values = loadJSONArray(jsonfile);
// println(values.size()); // println(values.size());
@@ -99,12 +166,17 @@ int[][] loadJson(String jsonfile) {
int y = jsontoarray.getInt(1); int y = jsontoarray.getInt(1);
int rectwidth = jsontoarray.getInt(2); int rectwidth = jsontoarray.getInt(2);
int rectheight = jsontoarray.getInt(3); int rectheight = jsontoarray.getInt(3);
int isspike = jsontoarray.getInt(4);
// arrayfromjson_x[i] = x;
arrayfromjson[i][0] = x; arrayfromjson[i][0] = x;
arrayfromjson[i][1] = y; arrayfromjson[i][1] = y;
arrayfromjson[i][2] = rectwidth; arrayfromjson[i][2] = rectwidth;
arrayfromjson[i][3] = rectheight; arrayfromjson[i][3] = rectheight;
arrayfromjson[i][4] = isspike;
} }
return arrayfromjson; return arrayfromjson;
} else {
int[][] arrayfromjson = new int[100][5];
return arrayfromjson;
}
} }

View File

@@ -1,599 +1,699 @@
[ [
[ [
405, -28,
595, 0,
50, 0,
50 0,
0
], ],
[ [
823, -28,
337, 0,
50, 0,
50 0,
0
], ],
[ [
1002, 649,
560, 677,
50, 50,
50 50,
1
], ],
[ [
885, -28,
678, 0,
50, 0,
50 0,
0
], ],
[ [
1027, -28,
338, 0,
50, 0,
50 0,
0
], ],
[ [
929, 580,
686, 391,
100,
50, 50,
50 0
], ],
[ [
925, 265,
322, 310,
100,
50, 50,
50 0
], ],
[ [
1024, 543,
717, 479,
50, 50,
50 50,
1
], ],
[ [
927, 278,
344, 402,
50, 50,
50 50,
1
], ],
[ [
1013, 1394,
564, 429,
100,
50, 50,
50 0
], ],
[ [
825, 1469,
463, 574,
100,
50, 50,
50 0
], ],
[ [
1012, 1742,
454, 644,
100,
50, 50,
50 0
],
[
1597,
453,
100,
50,
0
], ],
[ [
1622, 1622,
495, 652,
100,
50, 50,
50 0
],
[
1687,
130,
50,
50
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,
0 0
], ],
[ [
-109,
0, 0,
0, 0,
0, 0,

BIN
game/sounds/fail.mp3 Normal file

Binary file not shown.

BIN
game/sounds/jump.mp3 Normal file

Binary file not shown.

BIN
game/sounds/maintheme.mp3 Normal file

Binary file not shown.

View File

@@ -1,7 +1,6 @@
JSONArray json;
void setup() { // void setup() {
size(800,800); // size(800,800);
// json = loadJSONArray("map.json"); // json = loadJSONArray("map.json");
// JSONObject values = json.getJSONObject(1); // JSONObject values = json.getJSONObject(1);
@@ -9,46 +8,49 @@ void setup() {
// int x = values.getInt("x"); // int x = values.getInt("x");
// print(x); // print(x);
} // }
void draw() { // void draw() {
background(255); // background(255);
generate_tiles(); // generate_tiles();
} // }
PVector tilesize = new PVector(50, 50);
int[] tiles_x = {50};
int[] tiles_y = {50};
void pickTiles() {
}
void generate_tiles() { void generate_tiles() {
for (int i = 0; i < tiles_x.length; i++ ) { for (int i = 0; i < level.length; i++ ) {
rect(tiles_x[i], tiles_y[i], tilesize.x, tilesize.y); 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() { int[][] level = new int[100][4];
if (key == 's') { JSONArray json;
println("saved");
int savetofile(String filename) {
json = new JSONArray(); json = new JSONArray();
for (int i = 0; i < tiles_x.length; i++) { for (int i = 0; i < level.length; i++) {
JSONArray mapsave = new JSONArray(); JSONArray mapsave = new JSONArray();
mapsave.setInt(0, tiles_x[i]); mapsave.setInt(0, level[i][0]);
mapsave.setInt(1, tiles_y[i]); mapsave.setInt(1, level[i][1]);
mapsave.setInt(2, level[i][2]);
mapsave.setInt(3, level[i][3]);
json.setJSONArray(i, mapsave); json.setJSONArray(i, mapsave);
} }
saveJSONArray(json, "map.json"); saveJSONArray(json, filename + ".json");
} return 1;
} }
int screenx = 0;