diff --git a/assets/Sprite-0002.ase b/assets/Sprite-0002.ase new file mode 100644 index 0000000..3123978 Binary files /dev/null and b/assets/Sprite-0002.ase differ diff --git a/assets/Sprite-robi.png b/assets/Sprite-robi.png new file mode 100644 index 0000000..c6474f1 Binary files /dev/null and b/assets/Sprite-robi.png differ diff --git a/assets/Sprite-robiwithbob.png b/assets/Sprite-robiwithbob.png new file mode 100644 index 0000000..85f49c2 Binary files /dev/null and b/assets/Sprite-robiwithbob.png differ diff --git a/collect.pde b/collect.pde index ae619a0..a4b373b 100644 --- a/collect.pde +++ b/collect.pde @@ -19,10 +19,6 @@ class Saw extends Collectable { void drawSaw() { if (!is_attached) { - // stroke(0); - // fill(210, 210, 0); - // rect(pos.x, pos.y, cwidth, cheight); - // fill(0); image(saw_sprite, pos.x, pos.y); } } @@ -36,10 +32,6 @@ class Bob extends Collectable { void drawBob() { if (!is_attached) { - // stroke(0); - // fill(255, 209, 152); - // rect(pos.x, pos.y, cwidth, cheight); - // fill(0); image(bob_sprite, pos.x, pos.y); } } diff --git a/files.pde b/files.pde index f817f73..d395bbf 100644 --- a/files.pde +++ b/files.pde @@ -1,6 +1,3 @@ -// DONE File loading and Saving -// TODO Math for best_game_time - class Files { boolean checkSaveFile(String filepath) { @@ -8,13 +5,17 @@ class Files { } void loadJson(String jsonfile) { - if (!checkSaveFile(jsonfile)) { + // if (!checkSaveFile(jsonfile)) { + try { JSONArray values = loadJSONArray(jsonfile); stats_menu.best_game_time = values.getInt(0); stats_menu.trees_sawed = values.getInt(1); stats_menu.game_time = values.getInt(2); + println("Savefile found"); + } catch (Exception e) { + println("Savefile not found"); } } diff --git a/kek2.pde b/kek2.pde index 63a2225..21386ad 100644 --- a/kek2.pde +++ b/kek2.pde @@ -1,9 +1,3 @@ -// DONE Level mit 2 Bereichen. Erster Bereich Straße und Kettensäge und End/Startpunkt. Zweiter Bereich Wald und Bob - -// DONE Statistikseite: Spielzeit, Bäume gefällt, Zeit gestoppt -// TODO Wir brauchen Geräusche -// DONE Robi muss noch beschleunigen können - float checkDistance(Log log, Ship ship) { float testX = ship.pos.x; float testY = ship.pos.y; @@ -27,7 +21,7 @@ float checkDistance(Log log, Ship ship) { // Main Game entry void play() { - background(50); + background(75, 105, 47); text(playtime.second(), 20, 20); @@ -79,9 +73,11 @@ Bob bob; // stopwatch StopWatchTimer playtime = new StopWatchTimer(); +Files savefile = new Files(); PImage player_sprite; +PImage player_sprite_bob; PImage saw_sprite; PImage bob_sprite; @@ -96,9 +92,12 @@ void setup() { saw_zero = new Saw(-width+100, 100, 20, 50); bob = new Bob(500, 400, 20, 40); - player_sprite = loadImage("./assets/Sprite-0001.png"); + player_sprite = loadImage("./assets/Sprite-robi.png"); + player_sprite_bob = loadImage("./assets/Sprite-robiwithbob.png"); saw_sprite = loadImage("./assets/Sprite-saege.png"); bob_sprite = loadImage("./assets/Sprite-bob.png"); + + savefile.loadJson("./saves/save.json"); } void draw() { @@ -146,6 +145,11 @@ void draw() { stats_menu.draw(); } else if (isend) { // end screen code + + + // save + if(playtime.second() < stats_menu.best_game_time) stats_menu.best_game_time = playtime.second(); + savefile.savetofile("save"); } else if (ispause) { main_menu.drawMenu(); diff --git a/keys.pde b/keys.pde index dafce93..5f666bc 100644 --- a/keys.pde +++ b/keys.pde @@ -11,7 +11,6 @@ void keyPressed() { ROTATER = true; } } else if (key == 's') { // SAW - // BUG sometimes a log gets stuck in sawed = false state if (ship_zero.hasSaw) { Log target_log = logs[ship_zero.nextLog]; if(checkDistance(target_log, ship_zero) < 40) { diff --git a/logs.pde b/logs.pde index 2908360..1500e23 100644 --- a/logs.pde +++ b/logs.pde @@ -55,31 +55,4 @@ class Log { } - - // void logCollide(Ship ship) { - // if(sawed == false) { - // if(ship.newX+10 > x && ship.newX-10 < x + logwidth && ship.newY+10 > y && ship.newY-10 < y + logheight) { - // ship.colliding = true; - // } - // } - // } - - // void draw() { - // drawLog(4); - // logCollide(ship_zero); - // } - } - -// class Tree extends Log { -// Tree (float x, float y, float logw, float logh, boolean hasC) { -// super(x, y, logw, logh, hasC); -// } -// void draw() { -// color treecolor = color(133, 79, 51); - -// // rectMode(CENTER); -// drawLog(1); - -// } -// } diff --git a/menu.pde b/menu.pde index ae44f14..339789d 100644 --- a/menu.pde +++ b/menu.pde @@ -25,6 +25,9 @@ class MainMenu extends Menus { ispause = false; isgame = true; } + fill(0); + textAlign(CENTER, CENTER); + textSize(32); text("Play", x, y); } @@ -34,6 +37,9 @@ class MainMenu extends Menus { ismenu = false; isstats = true; } + fill(0); + textAlign(CENTER, CENTER); + textSize(32); text("Stats", x, y); } @@ -42,6 +48,10 @@ class MainMenu extends Menus { // color maincolor = color(100, 100, 100); playButton(300, 300, 150, 50); statsButton(300, 400, 150, 50); + + textSize(100); + textAlign(CENTER, CENTER); + text("Save Bob", 300, 200); } void draw() { @@ -62,6 +72,8 @@ class Stats extends Menus { isstats = false; } fill(0); + textSize(32); + textAlign(CENTER, CENTER); text("Main Menu", 300, 300); } @@ -69,13 +81,14 @@ class Stats extends Menus { background(50); menuButton(); + textAlign(LEFT); textSize(24); - text("Best Game Time", 50, 50); - text(best_game_time, 200, 50); - text("Trees Sawed: " , 50, 70); - text(trees_sawed, 200, 70); - text("Insgesamt Spielzeit", 50, 90); - text(game_time, 200, 90); + text("Best Game Time", 100, 50); + text(best_game_time, 500, 50); + text("Trees Sawed: " , 100, 70); + text(trees_sawed, 500, 70); + text("Insgesamt Spielzeit", 100, 90); + text(game_time, 500, 90); } } diff --git a/readme.org b/readme.org new file mode 100644 index 0000000..31116db --- /dev/null +++ b/readme.org @@ -0,0 +1,17 @@ +** Ingame +*** DONE Level mit 2 Bereichen. Erster Bereich Straße und Kettensäge und End/Startpunkt. Zweiter Bereich Wald und Bob +*** DONE Robi muss noch beschleunigen können +*** TODO Wir brauchen Geräusche +*** DONE setze bob auf den Robi +*** TODO Richtige Texte am Anfang zum erklären +*** TODO Abprallen nicht machen, wenn newx nicht erreicht sein kann, sondern wenn Robi tatsächlich die Wand berührt +*** TODO Roboter muss abprallen, kaputt gehen +*** BUG sometimes a log gets stuck in sawed = false state +** Menu +*** DONE Statistikseite: Spielzeit, Bäume gefällt, Zeit gestoppt +*** DONE Richtige Texte im Menu +*** DONE File loading and saving +Wird noch nicht benutzt +*** DONE nochmal die statistikseite überarbeiten +**** DONE Math for best_game_time +**** TODO Why doesnt bestgametime work diff --git a/saves/save.json b/saves/save.json new file mode 100644 index 0000000..97f2c01 --- /dev/null +++ b/saves/save.json @@ -0,0 +1,5 @@ +[ + 0, + 13, + 205455 +] \ No newline at end of file diff --git a/ship.pde b/ship.pde index a0997f9..e54de47 100644 --- a/ship.pde +++ b/ship.pde @@ -1,6 +1,3 @@ -// Roboter muss abprallen, kaputt gehen -// TODO Abprallen nicht machen, wenn newx nicht erreicht sein kann, sondern wenn Robi tatsächlich die Wand berührt - class Ship { // Movement PVector pos = new PVector(-width/2, height/2); // position @@ -157,7 +154,11 @@ class Ship { // line(-10, 10, 0, -10); // triangle(- 5, - 5, - 5, 5, 10, 0); imageMode(CENTER); - image(player_sprite, 0, 0); + if(bob.is_attached) { + image(player_sprite_bob, 0, 0); + } else { + image(player_sprite, 0, 0); + } if(hasSaw) { image(saw_sprite, 20, 0); }