/* 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); } } }