added Kollisionserkennung

This commit is contained in:
christoph.deest
2023-10-09 05:50:30 +00:00
parent c2e18f797a
commit 4f3a52a88e
15 changed files with 558 additions and 0 deletions

View File

@@ -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);
}
}
}