Compare commits
19 Commits
73cb60941d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eafd6f3d92 | ||
| 46cb3f22c4 | |||
| 98e71893f4 | |||
| b78310728e | |||
| 82e3afcfe5 | |||
|
|
a527307ee1 | ||
| 175c0d238e | |||
|
|
0db9e72d8d | ||
| 92a6ace93b | |||
| ca87f13623 | |||
| b269d39f62 | |||
|
|
ff4d996155 | ||
| d991e79538 | |||
| 53b9f7b136 | |||
| 22a429cba8 | |||
|
|
cd98f3bc12 | ||
| c3f0390160 | |||
| c5d00cdfc2 | |||
| 40e00559c6 |
0
game/background.pde
Normal file
0
game/background.pde
Normal file
109
game/game.pde
Normal file
109
game/game.pde
Normal file
@@ -0,0 +1,109 @@
|
||||
//TODO
|
||||
//- Start Screen
|
||||
//- Level Editor (click with mouse spawns or deletes tiles)
|
||||
// - Hotkey to slide the window right and left
|
||||
// - Find a way to make menus
|
||||
//- Movement berechnen mit move = gravitation - speed
|
||||
// - Jump als Zahl, die langsam kleiner wird
|
||||
//
|
||||
// Make Colission better:
|
||||
// - https://happycoding.io/tutorials/processing/collision-detection
|
||||
|
||||
// jumping related
|
||||
float speed = 20;
|
||||
float gravitation = 9.81;
|
||||
float jumpheight;
|
||||
boolean canjump = true;
|
||||
|
||||
// for moving x-axis (mostly depracted)
|
||||
// But dont delete yet!!
|
||||
// PVector direction = new PVector(0,0);
|
||||
PVector pos = new PVector(220, 50);
|
||||
int playerRadius = 25;
|
||||
|
||||
// float actualPos;
|
||||
|
||||
PVector tilesize = new PVector(100, 50);
|
||||
|
||||
int[][] level;
|
||||
|
||||
int tilesmoved = 0;
|
||||
int tilespeed = 4;
|
||||
|
||||
// The actual game
|
||||
void play() {
|
||||
// calculate actual position on ground
|
||||
// actualPos = height - pos.y;
|
||||
|
||||
|
||||
// player
|
||||
rectMode(CENTER);
|
||||
rect(pos.x, pos.y, playerRadius, playerRadius);
|
||||
|
||||
moveTiles(tilespeed);
|
||||
baseRect();
|
||||
newJump();
|
||||
collisionTest();
|
||||
generate_tiles();
|
||||
|
||||
helper();
|
||||
menuButton();
|
||||
|
||||
fill(0);
|
||||
text(tilesmoved, 700, 50);
|
||||
tilesmoved = tilesmoved + tilespeed;
|
||||
fill(255);
|
||||
}
|
||||
|
||||
|
||||
void moveTiles(int tilesspeed) {
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
level[i][0] = level[i][0] - tilesspeed;
|
||||
}
|
||||
}
|
||||
void moveTilesBack(int tilespeed) {
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
level[i][0] = level[i][0] + tilesmoved;
|
||||
}
|
||||
tilesmoved = 0;
|
||||
}
|
||||
|
||||
// Handles Jumping
|
||||
float movement;
|
||||
float jumpspeed;
|
||||
void newJump() {
|
||||
movement = gravitation - jumpspeed;
|
||||
pos.set(pos.x, pos.y + movement);
|
||||
if (jumpspeed > 0) {
|
||||
jumpspeed--;
|
||||
}
|
||||
}
|
||||
|
||||
// This is an absolute mess
|
||||
|
||||
// TODO Collision erweitern wie in https://happycoding.io/tutorials/processing/collision-detection
|
||||
void collisionTest() {
|
||||
// Collision with baseline
|
||||
if ( pos.y > 0.850*height - playerRadius/2 ) {
|
||||
pos.set(pos.x, 0.850*height - playerRadius/2);
|
||||
canjump = true;
|
||||
}
|
||||
|
||||
// Collision with all the tiles bottom site
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
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;
|
||||
|
||||
if (level[i][4] == 0) {
|
||||
// Bottom
|
||||
if ( (xSideEdges) && (ySideEdges)) {
|
||||
pos.set(pos.x, level[i][1] + tilesize.y/2);
|
||||
}
|
||||
// Top
|
||||
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);
|
||||
canjump = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
game/keys.pde
Normal file
86
game/keys.pde
Normal file
@@ -0,0 +1,86 @@
|
||||
// Here are all the keys that are used
|
||||
|
||||
boolean iseditorModeRect = true;
|
||||
boolean iseditorModeSpike = false;
|
||||
float volume = 0.2;
|
||||
|
||||
void keyPressed () {
|
||||
if (key == 'm') {
|
||||
if (volume == 0.2) {
|
||||
volume = 0;
|
||||
} else {
|
||||
volume = 0.2;
|
||||
}
|
||||
gamesoundtrack.amp(volume);
|
||||
}
|
||||
if (ismenu) {
|
||||
} else if (isgame) {
|
||||
if (key == CODED) {
|
||||
// if (keyCode == RIGHT) {
|
||||
// direction.x = +1;
|
||||
// pos.x = pos.x + direction.x * speed;
|
||||
// } else if (keyCode == LEFT) {
|
||||
// direction.x = -1;
|
||||
// pos.x = pos.x + direction.x * speed;
|
||||
// }
|
||||
} else if (key == ' ') {
|
||||
if(canjump) {
|
||||
jumpspeed =+ 31;
|
||||
canjump = false;
|
||||
jumpsound.play();
|
||||
}
|
||||
}
|
||||
} else if (iseditor) {
|
||||
if (key == 's') {
|
||||
savetofile("save");
|
||||
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) {
|
||||
if (keyCode == RIGHT) {
|
||||
screenx = screenx + 50;
|
||||
println("moved right!");
|
||||
println(screenx);
|
||||
} else if (keyCode == LEFT) {
|
||||
screenx = screenx - 50;
|
||||
println("moved right!");
|
||||
println(screenx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add tiles in editor mode
|
||||
int runnerRect = 0;
|
||||
void mouseReleased() {
|
||||
if(iseditor) {
|
||||
if (mouseButton == LEFT) {
|
||||
if(iseditorModeRect) {
|
||||
level[runnerRect][0] = mouseX+screenx;
|
||||
level[runnerRect][1] = mouseY;
|
||||
level[runnerRect][2] = 100;
|
||||
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");
|
||||
runnerRect = runnerRect + 1;
|
||||
println(runnerRect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
173
game/main.pde
Normal file
173
game/main.pde
Normal file
@@ -0,0 +1,173 @@
|
||||
import processing.sound.*;
|
||||
SoundFile jumpsound;
|
||||
SoundFile deathsound;
|
||||
SoundFile gamesoundtrack;
|
||||
|
||||
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);
|
||||
frameRate(60);
|
||||
smooth(4);
|
||||
|
||||
level = loadJson("./saves/save.json");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// debug();
|
||||
|
||||
if (ismenu) {
|
||||
mainMenu();
|
||||
} else if (isgame) {
|
||||
drawBackground();
|
||||
play();
|
||||
} else if (iseditor) {
|
||||
mapEditor();
|
||||
}
|
||||
}
|
||||
|
||||
boolean ismenu = true;
|
||||
boolean isgame = false;
|
||||
boolean iseditor = false;
|
||||
|
||||
// This is the start screen and main menu. It has a few Buttons
|
||||
void mainMenu() {
|
||||
background(246, 244, 235);
|
||||
|
||||
fill(116, 155, 194);
|
||||
textSize(128);
|
||||
textAlign(CENTER);
|
||||
text("p4dash", width/2, height/2 - 100);
|
||||
// go to game
|
||||
fill(70, 130, 169);
|
||||
if (drawRectWithMouseColission(width/2, height/2, 300, 100)) {
|
||||
if (mousePressed) {
|
||||
ismenu = false;
|
||||
isgame = true;
|
||||
}
|
||||
}
|
||||
fill(0);
|
||||
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) {
|
||||
ismenu = false;
|
||||
iseditor = true;
|
||||
}
|
||||
}
|
||||
fill(0);
|
||||
textSize(40);
|
||||
text("Editor", width/2, height/2+200);
|
||||
fill(145, 200, 228);
|
||||
// exit game
|
||||
if (drawRectWithMouseColission(50, 100, 80, 40)) {
|
||||
if (mousePressed) {
|
||||
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() {
|
||||
fill(145, 200, 228);
|
||||
if (drawRectWithMouseColission(50, 50, 80, 40)) {
|
||||
if (mousePressed) {
|
||||
ismenu = true;
|
||||
iseditor = false;
|
||||
isgame = false;
|
||||
moveTilesBack(tilespeed);
|
||||
savetofile("save");
|
||||
screenx = 0;
|
||||
}
|
||||
}
|
||||
fill(0);
|
||||
textSize(40);
|
||||
textAlign(CENTER);
|
||||
text("Exit", 50, 50+10);
|
||||
}
|
||||
|
||||
// Map Editor Mode
|
||||
void mapEditor() {
|
||||
background(255);
|
||||
baseRect();
|
||||
generate_editor_tiles();
|
||||
// generate_tiles();
|
||||
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) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// 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() {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
182
game/map.pde
Normal file
182
game/map.pde
Normal file
@@ -0,0 +1,182 @@
|
||||
// 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;
|
||||
|
||||
// level generation for playable
|
||||
void generate_tiles() {
|
||||
stroke(0);
|
||||
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]);
|
||||
} 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() {
|
||||
for (int i = 0; i < 100; i++ ) {
|
||||
// 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 (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;
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void baseRect() {
|
||||
line(0, 0.850*height, width, 0.850*height);
|
||||
fill(255);
|
||||
}
|
||||
|
||||
// Draws all the Background elements like sea and Beach
|
||||
void drawBackground() {
|
||||
color sky = color(94, 218, 252);
|
||||
color sand = color(235, 218, 174);
|
||||
color darksand = color(232, 177, 120);
|
||||
color darkersand = color(166, 110, 51);
|
||||
color sea = color(51, 169, 255);
|
||||
color seaend = color(146, 254, 255);
|
||||
color sun = color(247, 178, 2);
|
||||
|
||||
// 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();
|
||||
}
|
||||
// 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);
|
||||
//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);
|
||||
}
|
||||
|
||||
// No Clouds yet
|
||||
void drawCloud() {
|
||||
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
|
||||
JSONArray json;
|
||||
|
||||
// This saves the Current save to file
|
||||
int savetofile(String filename) {
|
||||
json = new JSONArray();
|
||||
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
|
||||
JSONArray mapsave = new JSONArray();
|
||||
mapsave.setInt(0, level[i][0]);
|
||||
mapsave.setInt(1, level[i][1]);
|
||||
mapsave.setInt(2, level[i][2]);
|
||||
mapsave.setInt(3, level[i][3]);
|
||||
mapsave.setInt(4, level[i][4]);
|
||||
|
||||
json.setJSONArray(i, mapsave);
|
||||
}
|
||||
saveJSONArray(json,"./saves/" + filename + ".json");
|
||||
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) {
|
||||
if (!checkSaveFile("./saves/save.json")) {
|
||||
JSONArray values = loadJSONArray(jsonfile);
|
||||
// println(values.size());
|
||||
|
||||
int[][] arrayfromjson = new int[values.size()][values.size()];
|
||||
|
||||
for (int i = 0; i < values.size(); i++) {
|
||||
|
||||
JSONArray jsontoarray = values.getJSONArray(i);
|
||||
|
||||
int x = jsontoarray.getInt(0);
|
||||
int y = jsontoarray.getInt(1);
|
||||
int rectwidth = jsontoarray.getInt(2);
|
||||
int rectheight = jsontoarray.getInt(3);
|
||||
int isspike = jsontoarray.getInt(4);
|
||||
|
||||
arrayfromjson[i][0] = x;
|
||||
arrayfromjson[i][1] = y;
|
||||
arrayfromjson[i][2] = rectwidth;
|
||||
arrayfromjson[i][3] = rectheight;
|
||||
arrayfromjson[i][4] = isspike;
|
||||
}
|
||||
return arrayfromjson;
|
||||
} else {
|
||||
int[][] arrayfromjson = new int[100][5];
|
||||
return arrayfromjson;
|
||||
}
|
||||
}
|
||||
702
game/saves/save.json
Normal file
702
game/saves/save.json
Normal file
@@ -0,0 +1,702 @@
|
||||
[
|
||||
[
|
||||
-28,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-28,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
649,
|
||||
677,
|
||||
50,
|
||||
50,
|
||||
1
|
||||
],
|
||||
[
|
||||
-28,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-28,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
580,
|
||||
391,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
265,
|
||||
310,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
543,
|
||||
479,
|
||||
50,
|
||||
50,
|
||||
1
|
||||
],
|
||||
[
|
||||
278,
|
||||
402,
|
||||
50,
|
||||
50,
|
||||
1
|
||||
],
|
||||
[
|
||||
1394,
|
||||
429,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
1469,
|
||||
574,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
1742,
|
||||
644,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
1597,
|
||||
453,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
1622,
|
||||
652,
|
||||
100,
|
||||
50,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
-109,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
]
|
||||
BIN
game/sounds/fail.mp3
Normal file
BIN
game/sounds/fail.mp3
Normal file
Binary file not shown.
BIN
game/sounds/jump.mp3
Normal file
BIN
game/sounds/jump.mp3
Normal file
Binary file not shown.
BIN
game/sounds/maintheme.mp3
Normal file
BIN
game/sounds/maintheme.mp3
Normal file
Binary file not shown.
26
game/unused.pde
Normal file
26
game/unused.pde
Normal file
@@ -0,0 +1,26 @@
|
||||
void rectWithText(float rectX, float rectY, float rectWidth, float rectHeight, String rectText, float ts) {
|
||||
// rect
|
||||
rectMode(CENTER);
|
||||
rect(rectX, rectY, rectWidth, rectHeight);
|
||||
|
||||
// text
|
||||
textSize(ts);
|
||||
textAlign(CENTER,CENTER);
|
||||
fill(0);
|
||||
text(rectText, rectX, rectY);
|
||||
|
||||
// stop painting
|
||||
noFill();
|
||||
|
||||
}
|
||||
|
||||
void menu() {
|
||||
rectWithText(width/2, height/2, 100, 50, "test", 40);
|
||||
}
|
||||
|
||||
|
||||
// This is basically the Level file:
|
||||
// It consists out of an array, that spawns tiles
|
||||
// It is also checked in collisionTest()
|
||||
int[] tiles_x = { 300, 50, 600, 50};
|
||||
int[] tiles_y = { 500, 50, 600, 200 };
|
||||
18
map/map.json
Normal file
18
map/map.json
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
[
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
417,
|
||||
414
|
||||
],
|
||||
[
|
||||
602,
|
||||
165
|
||||
],
|
||||
[
|
||||
308,
|
||||
296
|
||||
]
|
||||
]
|
||||
56
map/map.pde
Normal file
56
map/map.pde
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
// void setup() {
|
||||
// size(800,800);
|
||||
// json = loadJSONArray("map.json");
|
||||
|
||||
// JSONObject values = json.getJSONObject(1);
|
||||
|
||||
// int x = values.getInt("x");
|
||||
// print(x);
|
||||
|
||||
// }
|
||||
|
||||
// void draw() {
|
||||
// background(255);
|
||||
// generate_tiles();
|
||||
// }
|
||||
|
||||
void generate_tiles() {
|
||||
for (int i = 0; i < level.length; i++ ) {
|
||||
rect(level[i][0]-screenx, level[i][1], level[i][2], level[i][3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int[][] level = new int[100][4];
|
||||
JSONArray json;
|
||||
|
||||
int savetofile(String filename) {
|
||||
json = new JSONArray();
|
||||
|
||||
for (int i = 0; i < level.length; i++) {
|
||||
|
||||
JSONArray mapsave = new JSONArray();
|
||||
mapsave.setInt(0, level[i][0]);
|
||||
mapsave.setInt(1, level[i][1]);
|
||||
mapsave.setInt(2, level[i][2]);
|
||||
mapsave.setInt(3, level[i][3]);
|
||||
|
||||
json.setJSONArray(i, mapsave);
|
||||
}
|
||||
saveJSONArray(json, filename + ".json");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int screenx = 0;
|
||||
602
map/save.json
Normal file
602
map/save.json
Normal file
@@ -0,0 +1,602 @@
|
||||
[
|
||||
[
|
||||
132,
|
||||
131,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
307,
|
||||
381,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
582,
|
||||
155,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
568,
|
||||
582,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
120,
|
||||
440,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
624,
|
||||
283,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
517,
|
||||
562,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
1174,
|
||||
145,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
1126,
|
||||
492,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
858,
|
||||
596,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
963,
|
||||
201,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
1342,
|
||||
589,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
1622,
|
||||
495,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
1687,
|
||||
130,
|
||||
50,
|
||||
50
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
]
|
||||
185
program.pde
185
program.pde
@@ -1,185 +0,0 @@
|
||||
//TODO
|
||||
//- Start Screen
|
||||
//- Level Editor (click with mouse spawns or deletes tiles)
|
||||
// - Hotkey to slide the window right and left
|
||||
|
||||
// jumping related
|
||||
float speed = 20;
|
||||
float gravitation = 9.81;
|
||||
float jumpheight;
|
||||
float jumpcooldown = 12;
|
||||
|
||||
// for moving x-axis (mostly depracted)
|
||||
// But dont delete yet!!
|
||||
PVector movement = new PVector(0,0);
|
||||
PVector direction = new PVector(0,0);
|
||||
PVector pos = new PVector(220, 50);
|
||||
int playerRadius = 25;
|
||||
|
||||
float actualPos;
|
||||
|
||||
|
||||
void setup() {
|
||||
size(800,800);
|
||||
frameRate(60);
|
||||
smooth(4);
|
||||
|
||||
}
|
||||
|
||||
void draw() {
|
||||
|
||||
// rectMode(CENTER);
|
||||
// rect(50, 50, 100, 50);
|
||||
// textAlign(CENTER);
|
||||
// fill(0);
|
||||
// text("test", 50, 50);
|
||||
// noFill();
|
||||
|
||||
|
||||
menu();
|
||||
// play();
|
||||
helper();
|
||||
}
|
||||
|
||||
boolean ismenu;
|
||||
void menu() {
|
||||
rectWithText(width/2, height/2, 100, 50, "test", 40);
|
||||
}
|
||||
|
||||
|
||||
void rectWithText(float rectX, float rectY, float rectWidth, float rectHeight, String rectText, float ts) {
|
||||
// rect
|
||||
rectMode(CENTER);
|
||||
rect(rectX, rectY, rectWidth, rectHeight);
|
||||
|
||||
// text
|
||||
textSize(ts);
|
||||
textAlign(CENTER,CENTER);
|
||||
fill(0);
|
||||
text(rectText, rectX, rectY);
|
||||
|
||||
// stop painting
|
||||
noFill();
|
||||
|
||||
}
|
||||
|
||||
void mouseClicked() {
|
||||
}
|
||||
|
||||
// The actual game
|
||||
void play() {
|
||||
// calculate actual position on ground
|
||||
actualPos = height - pos.y;
|
||||
|
||||
background(255);
|
||||
|
||||
// player
|
||||
rectMode(CENTER);
|
||||
rect(pos.x, pos.y, playerRadius, playerRadius);
|
||||
|
||||
baseline();
|
||||
collisionTest();
|
||||
cooldown();
|
||||
jumpToJumpheight();
|
||||
|
||||
generate_tiles();
|
||||
|
||||
helper();
|
||||
}
|
||||
|
||||
// This is basically the Level file:
|
||||
// It consists out of an array, that spawns tiles
|
||||
// It is also checked in collisionTest()
|
||||
int[] tiles_x = { 300, 50, 600 };
|
||||
int[] tiles_y = { 500, 50, 600 };
|
||||
|
||||
void generate_tiles() {
|
||||
for (int i = 0; i < tiles_x.length; i++ ) {
|
||||
rect(tiles_x[i], tiles_y[i], 50, 50);
|
||||
}
|
||||
}
|
||||
// TODO Collision erweitern wie in https://happycoding.io/tutorials/processing/collision-detection
|
||||
void collisionTest() {
|
||||
// Collision with baseline
|
||||
if ( pos.y > baseline_y - playerRadius ) {
|
||||
pos.set(pos.x, baseline_y - playerRadius);
|
||||
}
|
||||
// Collision with all the tiles top site
|
||||
for (int i = 0; i < tiles_x.length; i++) {
|
||||
if ((pos.x > tiles_x[i]-25 && pos.x < tiles_x[i]+25) && pos.y < tiles_y[i] - playerRadius) {
|
||||
pos.set(pos.x, tiles_y[i] - playerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int baseline_y = 700;
|
||||
void baseline() {
|
||||
line(0, baseline_y, width, baseline_y);
|
||||
}
|
||||
|
||||
|
||||
// ##### Movement related
|
||||
//
|
||||
// all there is to jumping
|
||||
void jumpToJumpheight() {
|
||||
// control gravitation
|
||||
pos.set(pos.x, pos.y + gravitation);
|
||||
// turn gravity of if we are jumping
|
||||
if (actualPos < jumpheight) {
|
||||
gravitation = 0;
|
||||
} else {
|
||||
gravitation = 9.81;
|
||||
}
|
||||
|
||||
if (actualPos < jumpheight) {
|
||||
pos.y = pos.y - speed;
|
||||
jumpcooldown = 40;
|
||||
} else {
|
||||
jumpheight = 0;
|
||||
}
|
||||
}
|
||||
// count down jumping cooldown
|
||||
void cooldown() {
|
||||
if (jumpcooldown > 0) {
|
||||
jumpcooldown = jumpcooldown-1;
|
||||
}
|
||||
}
|
||||
// actions for moving
|
||||
void keyPressed() {
|
||||
if (key == CODED)
|
||||
{
|
||||
if (keyCode == LEFT)
|
||||
{
|
||||
direction.x = -1;
|
||||
pos.x = pos.x + direction.x * speed;
|
||||
}
|
||||
else if (keyCode == RIGHT)
|
||||
{
|
||||
//if (directionX<0) {
|
||||
direction.x = +1;
|
||||
pos.x = pos.x + direction.x * speed;
|
||||
//}
|
||||
}
|
||||
if (keyCode == UP && jumpcooldown == 0)
|
||||
{
|
||||
//if (directionY<0) {
|
||||
jumpheight += 400;
|
||||
//}
|
||||
}
|
||||
// else if (keyCode == DOWN)
|
||||
// {
|
||||
// //if (directionY<0) {
|
||||
// direction.y = +1;
|
||||
// pos.y = pos.y + direction.y * speed;
|
||||
// //}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
// Neat helper function, that gives us coordinates of point while clicking
|
||||
void helper() {
|
||||
if (mousePressed == true){
|
||||
println(mouseX, mouseY);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user