From 497de0702809a5d235f2c2513a2bce375803d71f Mon Sep 17 00:00:00 2001 From: Maximilian Ruhm Date: Tue, 12 Dec 2023 15:22:24 +0100 Subject: [PATCH] abprallen --- #simulation.pde# | 100 ++++++++++++++++++++++++++++++++++++ .kek2.pde.~undo-tree~ | 10 ++++ .logs.pde.~undo-tree~ | 15 ++++++ .ship.pde.~undo-tree~ | 11 ++++ .simulation.pde.~undo-tree~ | 8 +++ kek2.pde | 9 +++- logs.pde | 14 +++++ ship.pde | 15 ++++-- 8 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 #simulation.pde# create mode 100644 .kek2.pde.~undo-tree~ create mode 100644 .logs.pde.~undo-tree~ create mode 100644 .ship.pde.~undo-tree~ create mode 100644 .simulation.pde.~undo-tree~ diff --git a/#simulation.pde# b/#simulation.pde# new file mode 100644 index 0000000..c9bb2a2 --- /dev/null +++ b/#simulation.pde# @@ -0,0 +1,100 @@ +boolean ismenu = true; +boolean isgame = false; +PVector pos = new PVector(220, 50); + +void setup() { + size(800,800); +} + +// https://forum.processing.org/two/discussion/19925/rotating-an-object-and-making-it-move-with-a-variable.html +void draw() { + // debug(); + + if (ismenu) { + mainMenu(); + } else if (isgame) { + play(); + } +} + +int rotation; +void play() { + background(255); + + rotate(radians(rotation)); + translate(pos.x, pos.y); + rect(0, 0, 20, 20); +} + +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; + } + } + 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); +} + +// 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; + } +} + +void keyPressed() { + if (ismenu) { + } else if (isgame) { + if (key == CODED) { + if (keyCode == UP) { + pos.x = pos.x + 1; + } else if (keyCode == DOWN) { + pos.x = pos.x - 1; + } else if (keyCode == LEFT) { + rotation = rotation +1; + } else if (keyCode == RIGHT) { + rotation = rotation -1; + } + } + } +} + diff --git a/.kek2.pde.~undo-tree~ b/.kek2.pde.~undo-tree~ new file mode 100644 index 0000000..a8cb795 --- /dev/null +++ b/.kek2.pde.~undo-tree~ @@ -0,0 +1,10 @@ +(undo-tree-save-format-version . 1) +"f7678610572151071a75b80e34c3a939accf7c9b" +[nil nil nil nil (25974 54439 79887 0) 0 nil] +([nil nil ((#(" + +" 0 2 (fontified t)) . 1) (undo-tree-id0 . -1) (undo-tree-id1 . -1) (undo-tree-id2 . -1) (undo-tree-id3 . -1) (undo-tree-id4 . -1) (undo-tree-id5 . -1) (undo-tree-id6 . -2) 2 (t 25974 54118 112253 507000)) nil (25974 54439 79883 0) 0 nil]) +([nil nil ((1471 . 1474) (1469 . 1469) (1469 . 1471) (1463 . 1469) (1461 . 1463) (1460 . 1460) (1460 . 1461) (1459 . 1460) (1458 . 1459) (1456 . 1457) (1455 . 1456) (#("." 0 1 (face font-lock-string-face fontified t)) . -1455) (undo-tree-id7 . -1) (undo-tree-id8 . -1) (undo-tree-id9 . -1) (undo-tree-id10 . -1) (undo-tree-id11 . -1) (undo-tree-id12 . -1) (undo-tree-id13 . -1) (#(" " 0 1 (face font-lock-string-face fontified t)) . -1456) (undo-tree-id14 . -1) (undo-tree-id15 . -1) (undo-tree-id16 . -1) (undo-tree-id17 . -1) (undo-tree-id18 . -1) 1457 (1454 . 1457) (1453 . 1455) (#("\"" 0 1 (fontified nil)) . -1453) (undo-tree-id19 . -1) (undo-tree-id20 . -1) (1452 . 1454) (1451 . 1452) (1448 . 1451) (1447 . 1447) (1447 . 1448) (#("N" 0 1 (fontified t)) . -1447) (undo-tree-id21 . -1) (undo-tree-id22 . -1) (#("e" 0 1 (fontified t)) . -1448) (undo-tree-id23 . -1) (undo-tree-id24 . -1) 1449 (1448 . 1449) (1446 . 1446) (1446 . 1448) (1440 . 1446) (1439 . 1440) (1438 . 1439) (1437 . 1437) (1437 . 1438) (1436 . 1438) (#("(" 0 1 (face font-lock-keyword-face fontified nil)) . -1436) (1436 . 1437) (1430 . 1436) (1429 . 1429) (1429 . 1430) (#("o" 0 1 (fontified t)) . -1429) (undo-tree-id25 . -1) (undo-tree-id26 . -1) 1430 (1429 . 1429) (1429 . 1430) (1427 . 1429) (#(" " 0 2 (fontified nil)) . 1426) (undo-tree-id27 . -2) (1428 . 1429) (1425 . 1428) (t 25974 54439 84243 136000) 1379) nil (25974 55177 491605 0) 0 nil]) +([nil nil ((1475 . 1476) (t 25974 55177 494845 710000)) nil (25974 55179 791073 0) 0 nil]) +([nil current ((apply -3 1427 1480 undo--wrap-and-run-primitive-undo 1427 1480 ((1429 . 1432) 1443))) nil (25974 55193 449487 0) 0 nil]) +nil diff --git a/.logs.pde.~undo-tree~ b/.logs.pde.~undo-tree~ new file mode 100644 index 0000000..dd0a393 --- /dev/null +++ b/.logs.pde.~undo-tree~ @@ -0,0 +1,15 @@ +(undo-tree-save-format-version . 1) +"aafce57dc9d3ed6c354179a6ca1caa678609b93f" +[nil nil nil nil (25974 55370 872343 0) 0 nil] +([nil nil ((#("logwidth/2, y+5, 170*0.3, 160*0.3); + } + } + + void logCollide() " 0 13 (fontified t) 13 14 (prettify-symbols-end 918 prettify-symbols-start 917 composition (0 1 [32 65 57709]) fontified t) 14 20 (fontified t) 20 21 (prettify-symbols-end 925 prettify-symbols-start 924 composition (1 1 [32 65 57711]) fontified t) 21 29 (fontified t) 29 30 (prettify-symbols-end 934 prettify-symbols-start 933 composition (1 1 [32 65 57711]) fontified t) 30 42 (fontified t) 42 45 (fontified t) 45 46 (fontified t) 46 47 (fontified t) 47 49 (fontified t) 49 50 (face font-lock-type-face fontified t) 50 51 (face font-lock-type-face fontified t) 51 52 (face font-lock-type-face fontified t) 52 53 (face font-lock-type-face c-type c-decl-id-start fontified t) 53 54 (fontified t) 54 55 (face font-lock-function-name-face fontified t) 55 56 (face font-lock-function-name-face fontified t) 56 57 (face font-lock-function-name-face fontified t) 57 58 (face font-lock-function-name-face fontified t) 58 59 (face font-lock-function-name-face fontified t) 59 60 (face font-lock-function-name-face fontified t) 60 61 (face font-lock-function-name-face fontified t) 61 62 (face font-lock-function-name-face fontified t) 62 63 (face font-lock-function-name-face fontified t) 63 64 (face font-lock-function-name-face fontified t) 64 65 (fontified t) 65 66 (fontified t) 66 67 (fontified t)) . -904) (undo-tree-id10 . -44) (undo-tree-id11 . -61) (undo-tree-id12 . -67) 971 (970 . 971) (968 . 970) (#("(" 0 1 (face font-lock-variable-name-face fontified nil)) . -968) (968 . 969) (#(" " 0 1 (fontified t)) . -968) (undo-tree-id13 . -1) 969 (965 . 969) (#("o" 0 1 (face font-lock-variable-name-face fontified t)) . -965) (undo-tree-id14 . -1) 966 (965 . 966) (#("ide() " 0 1 (face font-lock-function-name-face fontified t) 1 2 (face font-lock-function-name-face fontified t) 2 3 (face font-lock-function-name-face fontified t) 3 4 (fontified t) 4 5 (fontified t) 5 6 (fontified t)) . -965) (undo-tree-id15 . -4) (undo-tree-id16 . -6) 971 (970 . 971) (#(";" 0 1 (fontified t)) . -970) (undo-tree-id17 . -1) (#(" +" 0 1 (fontified t)) . -971) (undo-tree-id18 . -1) (#(" " 0 1 (fontified t)) . -972) (undo-tree-id19 . -1) (#(" " 0 1 (fontified t)) . -973) (undo-tree-id20 . -1) 974 (971 . 974) (970 . 971) (#("L" 0 1 (face font-lock-type-face fontified t)) . -969) (undo-tree-id21 . -1) (undo-tree-id22 . -1) (#("o" 0 1 (face font-lock-type-face fontified t)) . -970) (undo-tree-id23 . -1) (undo-tree-id24 . -1) (#("g" 0 1 (face font-lock-type-face fontified t)) . -971) (undo-tree-id25 . -1) (undo-tree-id26 . -1) 972 (970 . 972) (969 . 969) (969 . 970) (968 . 970) (#("(" 0 1 (face font-lock-variable-name-face fontified nil)) . -968) (968 . 969) (959 . 968) (954 . 954) (954 . 959) (953 . 953) (953 . 954) (951 . 953) (#(" " 0 2 (fontified nil)) . 950) (undo-tree-id27 . -2) (952 . 953) (949 . 952) (t 25974 54118 112720 118000) 948) nil (25974 55370 872341 0) 0 nil]) +([nil nil ((#(" + " 0 1 (fontified nil) 1 3 (fontified nil)) . 949) (undo-tree-id1 . -3) (#(" +" 0 1 (fontified nil)) . 952) (undo-tree-id2 . -1) (950 . 952) (#(" " 0 2 (fontified nil)) . 951) (undo-tree-id3 . -2) (#("v" 0 1 (face font-lock-type-face fontified nil)) . 953) (undo-tree-id4 . -1) (#("oid l" 0 1 (face font-lock-type-face fontified nil) 1 2 (face font-lock-type-face fontified nil) 2 3 (face font-lock-type-face fontified nil) 3 4 (fontified nil) 4 5 (face font-lock-function-name-face fontified nil)) . 954) (undo-tree-id5 . -5) (#("ogCollide" 0 1 (face font-lock-function-name-face fontified nil) 1 2 (face font-lock-function-name-face fontified nil) 2 3 (face font-lock-function-name-face fontified nil) 3 4 (face font-lock-function-name-face fontified nil) 4 5 (face font-lock-function-name-face fontified nil) 5 6 (face font-lock-function-name-face fontified nil) 6 7 (face font-lock-function-name-face fontified nil) 7 8 (face font-lock-function-name-face fontified nil) 8 9 (face font-lock-function-name-face fontified nil)) . 959) (undo-tree-id6 . -9) (#("(" 0 1 (face font-lock-variable-name-face fontified nil)) . 968) (968 . 969) (#("()" 0 1 (fontified nil) 1 2 (fontified nil)) . 968) (undo-tree-id7 . -1) (#("L" 0 1 (face font-lock-type-face fontified nil)) . 969) (undo-tree-id8 . -1) (#("og" 0 1 (face font-lock-type-face fontified nil) 1 2 (face font-lock-type-face fontified nil)) . 970) (undo-tree-id9 . -2) (969 . 972) (#(";" 0 1 (fontified nil)) . 970) (#(" + " 0 1 (fontified nil) 1 2 (fontified nil) 2 3 (fontified nil)) . 971) (970 . 974) (#(" " 0 1 (fontified nil)) . 970) (965 . 971) (#("o" 0 1 (face font-lock-variable-name-face fontified nil)) . 965) (965 . 966) (#("ide " 0 1 (face font-lock-function-name-face fontified nil) 1 2 (face font-lock-function-name-face fontified nil) 2 3 (face font-lock-function-name-face fontified nil) 3 4 (fontified nil)) . 965) (968 . 969) (#("(" 0 1 (face font-lock-variable-name-face fontified nil)) . 968) (968 . 969) (#("()" 0 1 (fontified nil) 1 2 (fontified nil)) . 968) (#(" " 0 1 (fontified nil)) . 970) (904 . 971)) nil (25974 55370 872332 0) 0 nil]) +([nil current ((970 . 971) (968 . 970) (#("(" 0 1 (face font-lock-variable-name-face fontified nil)) . -968) (968 . 969) (959 . 968) (954 . 954) (954 . 959) (953 . 953) (953 . 954) (951 . 953) (#(" " 0 2 (fontified nil)) . 950) (undo-tree-id0 . -2) (952 . 953) (949 . 952) (t 25974 54118 112720 118000) 948) nil (25974 55370 872323 0) 0 nil]) +nil diff --git a/.ship.pde.~undo-tree~ b/.ship.pde.~undo-tree~ new file mode 100644 index 0000000..3beec3c --- /dev/null +++ b/.ship.pde.~undo-tree~ @@ -0,0 +1,11 @@ +(undo-tree-save-format-version . 1) +"5a0971ca47ac30921e9b713a56e832b4cdda3829" +[nil nil nil nil (25974 55084 608787 0) 0 nil] +([nil nil ((#(" +" 0 1 (fontified t)) . -254) (undo-tree-id0 . -1) (undo-tree-id1 . -1) (undo-tree-id2 . -1) (undo-tree-id3 . -1) (undo-tree-id4 . -1) (undo-tree-id5 . -1) (#(" +" 0 1 (fontified t)) . -255) (undo-tree-id6 . -1) (undo-tree-id7 . -1) (undo-tree-id8 . -1) (undo-tree-id9 . -1) (undo-tree-id10 . -1) (#(" " 0 1 (fontified t)) . -256) (undo-tree-id11 . -1) (undo-tree-id12 . -1) (undo-tree-id13 . -1) (#(" " 0 1 (fontified t)) . -257) (undo-tree-id14 . -1) (undo-tree-id15 . -1) 258 (256 . 258) (#(" " 0 2 (fontified nil)) . 255) (undo-tree-id16 . -2) (257 . 258) (254 . 257) (t 25974 54118 112987 610000) 251) nil (25974 55084 608783 0) 0 nil]) +([nil nil ((apply 3 484 507 undo--wrap-and-run-primitive-undo 484 507 ((#("// " 0 1 (face font-lock-comment-delimiter-face fontified t c-is-sws t c-in-sws t) 1 3 (face font-lock-comment-delimiter-face fontified t c-in-sws t)) . -488) 507))) nil (25974 55118 133801 0) 0 nil]) +([nil nil ((484 . 485)) nil (25974 55118 133801 0) 0 nil]) +([nil nil ((511 . 514) (509 . 509) (509 . 511) (508 . 509) (506 . 507) (505 . 506) (504 . 505) (503 . 505) (#("\"" 0 1 (fontified nil)) . -503) (503 . 504) (#("\"" 0 1 (face font-lock-string-face fontified nil)) . -503) (undo-tree-id17 . -1) (#("\"" 0 1 (face font-lock-string-face fontified t)) . 504) (503 . 505) (#("\"" 0 1 (fontified nil)) . -503) (502 . 504) (501 . 502) (499 . 501) (498 . 498) (498 . 499) (497 . 497) (497 . 498) (#("colliding" 0 9 (fontified t)) . 497) (undo-tree-id18 . -8) (undo-tree-id19 . -8) (undo-tree-id20 . -1) (undo-tree-id21 . -1) (undo-tree-id22 . -1) (undo-tree-id23 . -1) (undo-tree-id24 . -9) (undo-tree-id25 . -9) 498) nil (25974 55118 133798 0) 0 nil]) +([nil current ((apply -3 485 520 undo--wrap-and-run-primitive-undo 485 520 ((489 . 492) 497))) nil (25974 55141 588556 0) 0 nil]) +nil diff --git a/.simulation.pde.~undo-tree~ b/.simulation.pde.~undo-tree~ new file mode 100644 index 0000000..1100b3f --- /dev/null +++ b/.simulation.pde.~undo-tree~ @@ -0,0 +1,8 @@ +(undo-tree-save-format-version . 1) +"6ba7b52093be99eddee500fa2cd073dfd0644cc9" +[nil nil nil nil (25965 46461 784103 0) 0 nil] +([nil nil ((122 . 123) (120 . 122) (#("#" 0 1 (fontified t)) . -120) (undo-tree-id0 . -1) 121 (120 . 121) (t 25939 34023 800616 55000)) nil (25965 46461 784100 0) 0 nil]) +([nil nil ((83 . 84) (t 25965 46461 786953 630000) 48) nil (25974 17116 102820 0) 0 nil]) +([nil current ((#(" +" 0 1 (fontified t)) . 84) (undo-tree-id0 . 1)) nil (25974 17116 102818 0) 0 nil]) +nil diff --git a/kek2.pde b/kek2.pde index ffab7e7..8133bfd 100644 --- a/kek2.pde +++ b/kek2.pde @@ -1,4 +1,8 @@ +// Level mit 2 Bereichen. Erster Bereich Straße und Kettensäge und End/Startpunkt. Zweiter Bereich Wald und Bob +// Statistikseite: Spielzeit, Bäume gefällt, Zeit gestoppt +// Wir brauchen Geräusche +// Roboter muss abprallen, kaputt gehen float checkDistance(Log log, Ship ship) { float testX = ship.x; @@ -29,7 +33,7 @@ Saw saw_zero; Bob bob; Log[] logs = {new Log(100, 200, 100, 100, false), new Log(500, 200, 200, 100, false), new Log(400, 400, 20, 100, true) }; - +//Log log_zero = new Log(100,200,100,100,false); void setup() { size(600, 600); ship_zero = new Ship(); @@ -63,4 +67,7 @@ void draw() { logs[ship_zero.nextLog].strokecolor = color(255, 0, 0); + // println(ship_zero.newX, " : ", ship_zero.newY); + + println("x: ", ship_zero.x, " : ", ship_zero.newX); } diff --git a/logs.pde b/logs.pde index 75dd75e..d216d2d 100644 --- a/logs.pde +++ b/logs.pde @@ -12,6 +12,7 @@ class Log { logwidth = logw; logheight = logh; is_tree = ist; + //draw(); } void drawLog(int logtext) { @@ -39,6 +40,19 @@ 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 { diff --git a/ship.pde b/ship.pde index 6c7a466..5d07a27 100644 --- a/ship.pde +++ b/ship.pde @@ -5,7 +5,7 @@ class Ship { boolean colliding2 = false; boolean hasSaw = false; float rotationSpeed = 4; // The speed of rotation - float movementSpeed = 4; // The speed of movement + float movementSpeed = 2; // The speed of movement int nextLog; Ship() { @@ -22,7 +22,8 @@ class Ship { sawIndicator(); simulate(); render(); - // println(colliding); + + // println(newX, " : ", newY); ship_zero.colliding2 = false; } @@ -74,6 +75,11 @@ class Ship { if(colliding == false && colliding2 == false) { x = newX; y = newY; + } else { + float richtungX = x-newX; + float richtungY = y-newY; + x = (10*richtungX) + x; + y = (10*richtungY) + y; } } else if (SOUTH) { newX = x - cos(radians(a)) * movementSpeed; @@ -83,7 +89,10 @@ class Ship { if(colliding == false && colliding2 == false) { x = newX; y = newY; - } + } //else { + // x = newX - x; + // y = newY - y; + //} } }