From 4f3a52a88e294304a6269f792285ae015d67fe78 Mon Sep 17 00:00:00 2001 From: "christoph.deest" Date: Mon, 9 Oct 2023 05:50:30 +0000 Subject: [PATCH] added Kollisionserkennung --- .../1_FarbButtons/FarbButtons.pde | 64 ++++++++++++ .../1_FarbButtons/out/FarbButtons.class | Bin 0 -> 2033 bytes .../1_FarbButtons/out/source/FarbButtons.java | 93 ++++++++++++++++++ .../2_rectMode/out/rectMode.class | Bin 0 -> 1810 bytes .../2_rectMode/out/source/rectMode.java | 75 ++++++++++++++ .../2_rectMode/rectMode.pde | 46 +++++++++ .../UeberlappendeButtons.pde | 35 +++++++ .../out/UeberlappendeButtons.class | Bin 0 -> 1595 bytes .../out/source/UeberlappendeButtons.java | 65 ++++++++++++ .../KollisionPunktLinie.pde | 28 ++++++ .../out/KollisionPunktLinie.class | Bin 0 -> 1256 bytes .../out/source/KollisionPunktLinie.java | 56 +++++++++++ .../KollisionLinieLinie.pde | 33 +++++++ .../out/KollisionLinieLinie.class | Bin 0 -> 1450 bytes .../out/source/KollisionLinieLinie.java | 63 ++++++++++++ 15 files changed, 558 insertions(+) create mode 100644 Lektion 2/Kollisionserkennung/1_FarbButtons/FarbButtons.pde create mode 100644 Lektion 2/Kollisionserkennung/1_FarbButtons/out/FarbButtons.class create mode 100644 Lektion 2/Kollisionserkennung/1_FarbButtons/out/source/FarbButtons.java create mode 100644 Lektion 2/Kollisionserkennung/2_rectMode/out/rectMode.class create mode 100644 Lektion 2/Kollisionserkennung/2_rectMode/out/source/rectMode.java create mode 100644 Lektion 2/Kollisionserkennung/2_rectMode/rectMode.pde create mode 100644 Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/UeberlappendeButtons.pde create mode 100644 Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/UeberlappendeButtons.class create mode 100644 Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/source/UeberlappendeButtons.java create mode 100644 Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/KollisionPunktLinie.pde create mode 100644 Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/KollisionPunktLinie.class create mode 100644 Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/source/KollisionPunktLinie.java create mode 100644 Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/KollisionLinieLinie.pde create mode 100644 Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/KollisionLinieLinie.class create mode 100644 Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/source/KollisionLinieLinie.java diff --git a/Lektion 2/Kollisionserkennung/1_FarbButtons/FarbButtons.pde b/Lektion 2/Kollisionserkennung/1_FarbButtons/FarbButtons.pde new file mode 100644 index 0000000..7fcd1a3 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/1_FarbButtons/FarbButtons.pde @@ -0,0 +1,64 @@ +int size = 150; + +void setup() { + size(570, 570); + noStroke(); + background(220); +} + +void draw() { + int x1 = width / 2 - size / 2; + int y1 = 105 - size / 2; + int x2 = x1; + int y2 = 285 - size / 2; + int x3 = x1; + int y3 = 475 - size / 2; + + // setze Buttons + drawButton(x1, y1, color(255, 0, 0), "Rot"); + drawButton(x2, y2, color(0, 255, 0), "Grün"); + drawButton(x3, y3, color(0, 0, 255), "Blau"); + + // Klick außerhalb der Elemente + if (!(x1 <= mouseX && + y1 <= mouseY && + mouseX <= x1 + size && + mouseY <= y1 + size) && + !(x2 <= mouseX && + y2 <= mouseY && + mouseX <= x2 + size && + mouseY <= y2 + size) && + !(x3 <= mouseX && + y3 <= mouseY && + mouseX <= x3 + size && + mouseY <= y3 + size)) { + + if (mousePressed) { + background(220); + } + } +} + +void drawButton(int x, int y, color paint, String title) { + // setze Füllfarbe ... + if (x <= mouseX && + y <= mouseY && + mouseX <= x + size && + mouseY <= y + size) { + if (mousePressed) { + background(paint); + } + + fill(200); + } + // setze Rechteck + rect(x, y, size, size); + + // setze Text + fill(0); + textAlign(CENTER); + text(title, x + size / 2, y + size / 2); + + + fill(255); +} \ No newline at end of file diff --git a/Lektion 2/Kollisionserkennung/1_FarbButtons/out/FarbButtons.class b/Lektion 2/Kollisionserkennung/1_FarbButtons/out/FarbButtons.class new file mode 100644 index 0000000000000000000000000000000000000000..e0aa543130b240a1853ce8f6c161e42a78fe68cb GIT binary patch literal 2033 zcmX^0Z`VEs1_pD6RCWd?Mh0%T#G)jp(vp(=ykd3+7Dfi~f};H7)Z*gIymbBK{GwF- z0LOxYoYWFV2A1N?s#Hb>Mo&ftHk-`6%o00B24)S-Fh&Lz=lqmZE(T@>ZXO191`bXJ zMh0FU237_(Mh1SL%)C^;(%hufqL9R-oK!{zA)ox@#GJ6iqD&AUD#%ijky*^h!0UtL z9BW1f*5cHX(gH39Mg|cc22lnMMh1?&{NR$J{OnYapg0eM1cM|a16NXFa&~%Aera9` zBLja=pvcI;nw+1LU&P43rs3)7sp-kV zpv=g?9F$)IQlrYlpvIui$iM|M1`DHQI91NO_ z46N=&hxg=hFlaL}usG!;mVzwTOc@z? zz^Vd@Qj3dIQy3W-qZk>ODhwGJm?}X;g%OAaA}WkQEMrCn-r$nN0&p;b+-=9h zU=IosmbA>A9FTw`4}%kfGa~~_QEGAtBLlmJo12@PW*A7ym50F%q?WTJwW7o^Co??{ zBW7!1OT407eGJ3PuLTN=63Og2c?c5=I8rlFSlF1Y?8{BLhcq zYDr0EUV1UeiXc$p2xeqp)$oMGRc>Nt9wUR8Ml_~fnqlk=;fxFd=w@;-FoBGU;$etp zh+$-4OU}4?_q;C?f+`K_Vy?9E;M685xAJC}w2fN(AQ& zkP>!=1V#p~;QZ2}rDQ#j;~5kg7#Wxu7#J8C7(jW0fq{XIff1Bn7#JBi z85kJs7?{9vJX+fsxU>Wrrfp^5*~q}az{J4Ez`(!<)+@lk!XU)J%^<+Q&%nUI15wW) zz#s@VSBQZF!>nx#!dik1ceXKzp_?Vfz``KTz|A0m)hsEPS&X+C*csRv7#RL(ZDEjR z&C%Mzz{8r8Vk3|VW!XyG2{Ot;Ic6-YU5bH?fq@~6fr}xWfsY}AL5v}i zL6RYgL6#u~Y?BzoG=_MF1O^5ME(Q^XM1}+gMz9As8JPYsNU}2|fn1#oE;~{HrO$L{ literal 0 HcmV?d00001 diff --git a/Lektion 2/Kollisionserkennung/1_FarbButtons/out/source/FarbButtons.java b/Lektion 2/Kollisionserkennung/1_FarbButtons/out/source/FarbButtons.java new file mode 100644 index 0000000..a347c4a --- /dev/null +++ b/Lektion 2/Kollisionserkennung/1_FarbButtons/out/source/FarbButtons.java @@ -0,0 +1,93 @@ +/* autogenerated by Processing revision 1293 on 2023-09-27 */ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class FarbButtons extends PApplet { + +int size = 150; + +public void setup() { + /* size commented out by preprocessor */; + noStroke(); + background(220); +} + +public void draw() { + int x1 = width / 2 - size / 2; + int y1 = 105 - size / 2; + int x2 = x1; + int y2 = 285 - size / 2; + int x3 = x1; + int y3 = 475 - size / 2; + + drawButton(x1, y1, color(255, 0, 0), "Rot"); + drawButton(x2, y2, color(0, 255, 0), "Grün"); + drawButton(x3, y3, color(0, 0, 255), "Blau"); + + // Klick außerhalb der Elemente + if (!(x1 <= mouseX && + y1 <= mouseY && + mouseX <= x1 + size && + mouseY <= y1 + size) && + !(x2 <= mouseX && + y2 <= mouseY && + mouseX <= x2 + size && + mouseY <= y2 + size) && + !(x3 <= mouseX && + y3 <= mouseY && + mouseX <= x3 + size && + mouseY <= y3 + size)) { + + if (mousePressed) { + background(220); + } + } +} + +public void drawButton(int x, int y, int paint, String title) { + // setze Füllfarbe ... + if (x <= mouseX && + y <= mouseY && + mouseX <= x + size && + mouseY <= y + size) { + if (mousePressed) { + background(paint); + } + + fill(200); + } + // setze Rechteck + rect(x, y, size, size); + + // setze Text + fill(0); + textAlign(CENTER); + text(title, x + size / 2, y + size / 2); + + + fill(255); +} + + + public void settings() { size(570, 570); } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "FarbButtons" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} diff --git a/Lektion 2/Kollisionserkennung/2_rectMode/out/rectMode.class b/Lektion 2/Kollisionserkennung/2_rectMode/out/rectMode.class new file mode 100644 index 0000000000000000000000000000000000000000..11211bdaba5ceff452dd32fc73e3992f07d20937 GIT binary patch literal 1810 zcmX^0Z`VEs1_pD640Z-4Mh1?e)Z`N1{FGF71{OvJ@q(iK; zf}GS6Mh2GR%&JsI21ZXt1~!|_yv!0iMh0dL%`ip=7U%qwR4xW)25ue(b_Nbk21W*6 z9tKthHbw@1pUk{eztY^K)S{5Yq?}Yn1|gsPg^__p z!xQYFl%m9PkTYa>7-T`tU@gx~Dain7ljmVjU{GXaU`@`?$uDALVAJsQ^wjj^U{Gdc zU=GSJ0jW{tVNhdGXJp_48RJx1Qj(v?$RGhy=#!OLmZ+bTn3t{}TvC*omu{^Y#=)S; z$iV7eba+o52ZJ^v1B+8mVkyXST^>6%vZf=@xEY5um3@pxX8yG;Et#}x$8EhCCc);cb6r~myr=~D6 zFh(&l@CKJ8CTII57J$POWTHI}g99jdSkf|cazFx3JPb?>k|34~4}&X%8zTb?D6rv{ zg@L3zco;lEx;RTxD@q)5GSl-wqTW0VJ`BE$3@ji~Mh0;W%wTYH1BE+d1tSAvB_jiC zL1JcJ2_pk*NoENo&N0G`k%6N)wWK67FTEIKMJOn}gfTL(YIs6oFgGzXkC8!4BO22# z%`kR`C`JYWbTc^^m_SCw@-W0P#4|FmCFkcQCzdcWSYtB;o4HuTK&d*BhasFHf{}r% zAQ2Sejz#Ikj10n96f-h#C4w^xNC`VbG9v?5aDHh~a;jS;SI`YdLWlGC^9fI zFf%YPFfuTJ@(Ke30~-S)DE}}pGH^05FxW9Lf#rC#wli>P2{KIE%D}Ucfq{XEfscWK zfe)-#fPsZUh=H3yfPtTZfq@62o?5Nxgx0|$m#+Zcqk1R3sZV-Q0(ON@bqL7ah` zK?18;QZTa^`54&2_UzQs+QJ~snj?^@CCKofnRy$7oRHEs1{J8VAfv1nGe`m?u7NCm zTZ>Yi(iRVa;iqI*%b(3qyf9iUK1{1r{g@ z1huv>Sk43oBFy8=;6PLZ2edSUID-s>K7%ZSJA(p427@9)Cxa5hDh3sXjSQ*`I~X*O z0%RvNaBabn#`v3I2LmIhuz-g1GX_=$Rt5%!B!rWs+hp1hu9-H6K@8#=4lUVj3}RY> z3@5fR*lDqCV{p_0DFyi(6c9XZ+Zdd+n4xm+T9Pav*=-D7pupb7UowpOc+cUOc~r5EEv2QEExhAtQevgY#9<6?7*Hefw&Ut83u+V z20w7>1F`%W*cg~Veqab-U<0SJB!)nSAO;o&kf&J~m^47?G#Hj17)%+M!RdipOOVM* zkjZKrLkP%mkYox{%D~_VwiJ>)L5UTVJUKy`3L0#s3@l(P!yw7dkP32j8aO|t0|1q5QcnN? literal 0 HcmV?d00001 diff --git a/Lektion 2/Kollisionserkennung/2_rectMode/out/source/rectMode.java b/Lektion 2/Kollisionserkennung/2_rectMode/out/source/rectMode.java new file mode 100644 index 0000000..45af315 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/2_rectMode/out/source/rectMode.java @@ -0,0 +1,75 @@ +/* autogenerated by Processing revision 1293 on 2023-09-27 */ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class rectMode extends PApplet { + +int size = 150; // Durchmesser + +public void setup() { + /* size commented out by preprocessor */; + noStroke(); + background(220); +} + +public void draw() { + drawButton(width / 2, 105, color(255, 0, 0), "Rot"); + drawButton(width / 2, 285, color(0, 255, 0), "Grün"); + drawButton(width / 2, 475, color(0, 0, 255), "Blau"); + + // Klick außerhalb der Elemente + if (dist(mouseX, mouseY, width / 2, 105) > size / 2 && + dist(mouseX, mouseY, width / 2, 285) > size / 2 && + dist(mouseX, mouseY, width / 2, 475) > size / 2) { + + if (mousePressed) { + background(220); + } + } +} + +public void drawButton(int x, int y, int paint, String title) { + // setze Füllfarbe ... + if (dist(mouseX, mouseY, x, y) < size / 2) { + if (mousePressed) { + background(paint); + } + + fill(200); + } + // setze Rechteck + rectMode(CENTER); + rect(x, y, size, size); + + // setze Text + fill(0); + textAlign(CENTER); + text(title, x, y); + + + fill(255); +} + + + public void settings() { size(570, 570); } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "rectMode" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} diff --git a/Lektion 2/Kollisionserkennung/2_rectMode/rectMode.pde b/Lektion 2/Kollisionserkennung/2_rectMode/rectMode.pde new file mode 100644 index 0000000..76f1875 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/2_rectMode/rectMode.pde @@ -0,0 +1,46 @@ +int size = 150; // Durchmesser + +void setup() { + size(570, 570); + noStroke(); + background(220); +} + +void draw() { + // setze Buttons + drawButton(width / 2, 105, color(255, 0, 0), "Rot"); + drawButton(width / 2, 285, color(0, 255, 0), "Grün"); + drawButton(width / 2, 475, color(0, 0, 255), "Blau"); + + // Klick außerhalb der Elemente + if (dist(mouseX, mouseY, width / 2, 105) > size / 2 && + dist(mouseX, mouseY, width / 2, 285) > size / 2 && + dist(mouseX, mouseY, width / 2, 475) > size / 2) { + + if (mousePressed) { + background(220); + } + } +} + +void drawButton(int x, int y, color paint, String title) { + // setze Füllfarbe ... + if (dist(mouseX, mouseY, x, y) < size / 2) { + if (mousePressed) { + background(paint); + } + + fill(200); + } + // setze Rechteck + rectMode(CENTER); + rect(x, y, size, size); + + // setze Text + fill(0); + textAlign(CENTER); + text(title, x, y); + + + fill(255); +} \ No newline at end of file diff --git a/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/UeberlappendeButtons.pde b/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/UeberlappendeButtons.pde new file mode 100644 index 0000000..a07da3e --- /dev/null +++ b/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/UeberlappendeButtons.pde @@ -0,0 +1,35 @@ +int x1 = 200; +int y1 = 100; +int x2 = 100; +int y2 = 200; +int size = 200; + +void setup() { + size(800, 600); +} + +void draw() { + // setze hintergrund + background(255); + noFill(); + + // setze rechtecke + rect(x1, y1, size, size); + rect(x2, y2, size, size); + + // pruefung ob mauszeiger in rechteck ist + boolean isInRect1 = mouseX >= x1 && mouseY >= y1 && mouseX <= x1 + size && mouseY <= y1 + size; + boolean isInRect2 = mouseX >= x2 && mouseY >= y2 && mouseX <= x2 + size && mouseY <= y2 + size; + + if (isInRect1 && isInRect2) { // mauszeiger in schnittmenge + fill(0, 0, 255); + } else if (isInRect1) { // mauszeiger in rechteck 1 + fill(255, 0, 0); + } else if (isInRect2) { // mauszeiger in rechteck 2 + fill(0, 255, 0); + } else { + noFill(); // mauszeiger außerhalb der rechtecke + } + + ellipse(mouseX, mouseY, 20, 20); +} \ No newline at end of file diff --git a/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/UeberlappendeButtons.class b/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/UeberlappendeButtons.class new file mode 100644 index 0000000000000000000000000000000000000000..799f66282c1c07bda9ed7a0e7eb52351f1b1b876 GIT binary patch literal 1595 zcmX^0Z`VEs1_pD6V0H#3Mh214)TGp+oWz2H)V!2br_z#={Jdgz1{OvJ@q(iK;f}GS6Mh2z|Lq-NhPeul&N<$FO2*fgCWMC=ItV(5MV6(~0%Pg^D zWMJ0N3}a+qan4Uk zVPs&-%XiDn$pHyz@GxjHXfZOd6s0DYFfy=fxVgExX@-G(qQk?W3vw%4ZhmQTY6M6~ zpNGK!Ar#5tT+hG&GR2sO!Gyt-k%1*GGbe|UfemDeW*Cd(0*JH)4}&Gh686-boXmpa zR7M8Q%wo^Hpw#3NP`F1S@r@W6c!Nt4le2vj3!s6(QJh**l9`uY46?}q6o8J546GWS zp5VC1P0Y+=WDwJc_Q^^tOVrOv%uCk~E-A{)OSjexV`p$>WDr1?;9y_^8Rfyl;K|^{ z$iSAIpO>6i!pLBa%@AznVi5x+2Ok~=CkAIm2Cjm{;^Nd4$D;INMh0OliWwQW62U1C zq=cQpkCA~ZIKQ+gIn^x_loTYf#kL;E7YvFFj10^S3=FJb%*Fr$>AVg+UvnWg&x+))odmkj8}!>RM1ytt|`^35yxTVNy^& zJIitg7G@i$DiMTUF@#&AwzC% zFjovBD`W`avco*54RXI;n~<51*)|4qP>?Z$&Y;X-&7j6m&Y;e) znL(3bH-i?#VFqo6Qw%x`ml$*zZZhaGJY>*kc*0=7@PfgZ;TMAmIJgxcK?)7-a)uTL zD+X%@MuyD{9t<`N)(lJxwhRmmA`BeA8A=@(|1elFf=FRTK0am!Mg}`r{rfcOjy z+**Rn3W7`#+ZgOYj)f!`Nc@_EErcWtZm5NvpiBZyj-?DN3``(TvFv4ViDVXX3--}E z#=xhowS&QZ2ZQ%=26pWo4BjA9AweJoPSREkTnyF>d<-@WVhpwnk_>hXvJ4Jjo5Ucd lG59k0F@TC55e9z-KL$pyhd3FS{xC?gGX#KK9SBa@K>+BlCX)aF literal 0 HcmV?d00001 diff --git a/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/source/UeberlappendeButtons.java b/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/source/UeberlappendeButtons.java new file mode 100644 index 0000000..c29ab03 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/3_UeberlappendeButtons/out/source/UeberlappendeButtons.java @@ -0,0 +1,65 @@ +/* autogenerated by Processing revision 1293 on 2023-09-27 */ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class UeberlappendeButtons extends PApplet { + +int x1 = 200; +int y1 = 100; +int x2 = 100; +int y2 = 200; +int size = 200; + +public void setup() { + /* size commented out by preprocessor */; +} + +public void draw() { + // setze hintergrund + background(255); + noFill(); + + // setze rechtecke + rect(x1, y1, size, size); + rect(x2, y2, size, size); + + // pruefung ob mauszeiger in rechteck ist + boolean isInRect1 = mouseX >= x1 && mouseY >= y1 && mouseX <= x1 + size && mouseY <= y1 + size; + boolean isInRect2 = mouseX >= x2 && mouseY >= y2 && mouseX <= x2 + size && mouseY <= y2 + size; + + if (isInRect1 && isInRect2) { // mauszeiger in schnittmenge + fill(0, 0, 255); + } else if (isInRect1) { // mauszeiger in rechteck 1 + fill(255, 0, 0); + } else if (isInRect2) { // mauszeiger in rechteck 2 + fill(0, 255, 0); + } else { + noFill(); // mauszeiger außerhalb der rechtecke + } + + ellipse(mouseX, mouseY, 20, 20); +} + + + public void settings() { size(800, 600); } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "UeberlappendeButtons" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} diff --git a/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/KollisionPunktLinie.pde b/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/KollisionPunktLinie.pde new file mode 100644 index 0000000..8b06ff7 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/KollisionPunktLinie.pde @@ -0,0 +1,28 @@ +float ax = 50; // x-Position von Punkt a + +float bx = 5; // x-Position des Startpunkts der Linie b +float bwidth = 30; // Breite der Linie b + +void draw() { + background(0); + strokeWeight(5); + + stroke(0,255,0); + point(ax, ax); // setze punkt + + if (bx + bwidth >= ax && bx <= ax) { // wenn linie innerhalb x von punkt + stroke(255, 0, 0); // setze farbe auf rot + } else { + stroke(255); // setze farbe auf weiß + } + + line(bx, 60, bx + bwidth, 60); // setze linie + + if (keyPressed) { + if(keyCode == LEFT) { + bx -= 2; + } else if (keyCode == RIGHT) { + bx += 2; + } +} +} \ No newline at end of file diff --git a/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/KollisionPunktLinie.class b/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/KollisionPunktLinie.class new file mode 100644 index 0000000000000000000000000000000000000000..2cf03feb0bf5c26fec54e8497a70587328415047 GIT binary patch literal 1256 zcmX^0Z`VEs1_pBmKXwKtMh0Q;{G6Q3;>`TKfYQ9|5}(Yx%v5#;7Dfi~f};H7)Z*gI zymbBK{GwF-0LOxYoYWFV2ByRcMg~SVMh2#&3PuLDr1H#^k_<)$Hk-`6%o00B24)S- zFh&Lz=lqmZE(T@>ULFQc1}+vS4+aKK21W(}9tKthHWr5k5Uwx}13Lp7i{l3fSB!^& zgMp2af!`-HFV(L!Hz~C!Brz!`m61WnCqFqcCoHij6U2uKvXo?G7Be!4`e5;eH6sH{ zN>O4t7Xu@MEDwVmgFGVxS5jhfc6w2MX=5K#PY#n?Z+>fwdq%Gp~e^ zfmH)0qX*I@&*D@7F~pFE!HB__k%1*AGcT2qfgNOon`Rg&TugZw%oxlW8Mv}jD+7vB zi;GiJ7#SF&KvI@G3|0)*j127Asg+W*#Ghm`1cu zR$^JAeokUux_)p;QD$DcwPqMQg99Uj0J;PR0~5$^&O8h*46cj}Y{~g~$%!S54A$5T z!DcQNF;JYl^Dx*l*fBD26(oW@;#ibk%*Y^&MKL1-S0XrBft0W_crr3@1?QI*C8xS& zf+Af4OT6lVJi(yIz{tSNzyQXq3~US_zz(H3z%(-hBPii9Ffwp6Ffar%FflMPFffQ~ zZD-)o65`v+z^^4FxRpUjOGsoZgXl&E1_mYuaRvqkF$Pu!1_l8J76u^(E(Q?>0R~Y9 zF$Mt!2?hoR9*7YPk_=J|3=E76(%_WA&A`CO!oUiao1(?MjX_3BNN^j2f)=-s3imb! zRV}S84E!LxjX_gu3xkl>76#EI5P#}y1}Ufj|FpRbd|E;(+#n6h8Mw3r8UAl$&;@A~ z64Hk%5=|1)-^O5|wS~cCCWDUF76uCe)ddU!T9I2Agm}}oG6*ea5Ce;h$d}i z5CZv)8SFPZ27U$x1_=gM21y2P25AOi1{nr<1~~>B26+Y-1_cIp21N!x1{H>61~rB( z26cvF1`UQ<22F-e1}%ok47x~RFa;V0HVh0591JYK8Qj?ng%~(Nu?`LJQU(?VCI$uu zIhMT)_L0m&j=?@!#~ApuwRSK#?O#Rn1k&VgP6wP!QjaN%1j~*UJRZLj0_+ba56CcVUT2J@CL=X4>&4)0fsf~#Q*>R literal 0 HcmV?d00001 diff --git a/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/source/KollisionPunktLinie.java b/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/source/KollisionPunktLinie.java new file mode 100644 index 0000000..7bb0b5c --- /dev/null +++ b/Lektion 2/Kollisionserkennung/4_KollisionPunktLinie/out/source/KollisionPunktLinie.java @@ -0,0 +1,56 @@ +/* autogenerated by Processing revision 1293 on 2023-09-27 */ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class KollisionPunktLinie extends PApplet { + +float ax = 50; // x-Position von Punkt a + +float bx = 5; // x-Position des Startpunkts der Linie b +float bwidth = 30; // Breite der Linie b + +public void draw() { + background(0); + strokeWeight(5); + + stroke(0,255,0); + point(ax, ax); + + if (bx + bwidth >= ax && bx <= ax) { + stroke(255, 0, 0); + } else { + stroke(255); + } + + line(bx, 60, bx + bwidth, 60); + + if (keyPressed) { + if(keyCode == LEFT) { + bx -= 2; + } else if (keyCode == RIGHT) { + bx += 2; + } +} +} + + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "KollisionPunktLinie" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +} diff --git a/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/KollisionLinieLinie.pde b/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/KollisionLinieLinie.pde new file mode 100644 index 0000000..d1ee262 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/KollisionLinieLinie.pde @@ -0,0 +1,33 @@ +float ax = 60; // x-Position des Startpunkts der Linie a +float awidth = 30; // Breite der Linie a + +float bx = 5; // x-Position des Startpunkts der Linie b +float bwidth = 40; // Breite der Linie b + +void setup() { + size(150, 100); +} + +void draw() { + background(0); + strokeWeight(4); + + stroke(0,255,0); + line(ax, 50, ax + awidth, 50); // setze linie + + stroke(255); + + if (bx + bwidth >= ax && bx <= ax + awidth) { // wenn line b unter linie a + stroke(255, 0, 0); // setze farbe auf rot + } + + line(bx, 60, bx + bwidth, 60); + + if (keyPressed) { + if(keyCode == LEFT) { + bx -= 2; + } else if (keyCode == RIGHT) { + bx += 2; + } +} +} \ No newline at end of file diff --git a/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/KollisionLinieLinie.class b/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/KollisionLinieLinie.class new file mode 100644 index 0000000000000000000000000000000000000000..f850b8eb1a9627e9d9e64eeec389e8ab02ac4a14 GIT binary patch literal 1450 zcmX^0Z`VEs1_pD6P<93;Mh0Q;{G6Q3;>`R!pUk|>R4~ELz{1ENUQm>uoLXF*nU}7g zoL`ixAK+L}kds=%$iS3X!N|bq#>l{ySe}_ulEKKplvKgUz?KB%vDswiWtP}6GB9gs zhA}d*IOnINaxpM7@bNHkF>tdu6)-SxGB7d-@-VP6u(3FPfN({47}y!uSR58WxZ*qv z91LtMP6`mN6b}O@0~;d)zfWdfs$XetQfg61Vp2{jBZH7nesW??SYlBohz}KHDaptz zW@Hfc!Qwk>Mh4d6)RNKyMh2FYqQr7821W)Y9tLFw6-EZGq{QUx^rHOIyc9+T77b6$ zFcyaf1_qE4bsh!{22Dl=p5l_C{Or{5)XemZ5|AP{%`g_{dWa$&9tK?oJw^sLh$2P? zHVrp7kOC(Uhyp_%1|tSzMh2Fg%)C@a26m9Nn`Riu0#lG)6;Q~S^DtO2STZtjWv5mK z6r~myr=~D6Fh+r-ta%u07;G6C*t1hBLE*~C!05@yz#CkWn4ImKSOE1tM{#ONNoHPp zG00p;9tI}{XGR8=;>@a4Mg~?5Pfu{PnSflTz`Ven?~VPs%S&d*CuEMa7@#%2gMbFqklQidN7gA0QzBLi1K zBFM9jMd`(i48m9xGcs@`f>R+#2|GgoBLi1(erZv1s#_)~El6OAZat7E7!(;88JHOu z7+4q>K&g%a1lSqaKolsQfoV=KpOt|TluQ{I8F&~N7@`@N7#JBC7-Y4!Gw^B&@o!}i z&=L~b${?&IB)XMBOiM^&D}&@l1_lNu25ANc1}U%+0t_q+LJV9C!VCfoq6}gTVhl12 z0t_+?3=BLF!x&^41}iG%~_9D!?={axs8h%)l^T zi+LM^qLz^AHU>2HY8)phAwr|1l!1kTiGhJZ zj%6={TO_lPN3f69F$O+utsM-WI~aVIGq7v#VDJT*3h@{u@+}y+7%Un17_1n?7_1p2 x8EhD28SKC|i9t+b@Mj2M0F?$J41o**42%pQFK{w2{b7(~X9xm0IvAXuLICRZ0oVWl literal 0 HcmV?d00001 diff --git a/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/source/KollisionLinieLinie.java b/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/source/KollisionLinieLinie.java new file mode 100644 index 0000000..f486829 --- /dev/null +++ b/Lektion 2/Kollisionserkennung/5_KollisionLinieLinie/out/source/KollisionLinieLinie.java @@ -0,0 +1,63 @@ +/* autogenerated by Processing revision 1293 on 2023-09-27 */ +import processing.core.*; +import processing.data.*; +import processing.event.*; +import processing.opengl.*; + +import java.util.HashMap; +import java.util.ArrayList; +import java.io.File; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +public class KollisionLinieLinie extends PApplet { + +float ax = 60; // x-Position des Startpunkts der Linie a +float awidth = 30; // Breite der Linie a + +float bx = 5; // x-Position des Startpunkts der Linie b +float bwidth = 40; // Breite der Linie b + +public void setup() { + /* size commented out by preprocessor */; +} + +public void draw() { + background(0); + strokeWeight(4); + + stroke(0,255,0); + line(ax, 50, ax + awidth, 50); + + stroke(255); + + if (bx + bwidth >= ax && bx <= ax + awidth) { + stroke(255, 0, 0); + } + + line(bx, 60, bx + bwidth, 60); + + if (keyPressed) { + if(keyCode == LEFT) { + bx -= 2; + } else if (keyCode == RIGHT) { + bx += 2; + } +} +} + + + public void settings() { size(150, 100); } + + static public void main(String[] passedArgs) { + String[] appletArgs = new String[] { "KollisionLinieLinie" }; + if (passedArgs != null) { + PApplet.main(concat(appletArgs, passedArgs)); + } else { + PApplet.main(appletArgs); + } + } +}