A little traffic simulation, made as a study about the basics of OOP.
There are three important rules:
- brake if there is a slow car ahead,
- wait at the crossing, if there is a car coming from the right side.
- don´t turn left, if there is a car on the opposite lane.
Thanks to the friendly people in the forum, who helped me with the ArrayList stuff.
17.1.: update with with an improved display-method.
This is about building an alarm system with mirrors and a laser.
The sketch will explain.
I didn´t calculate the reflection angels and the length of the beams.
I made an array which stores the different directions according to the position of the mirrors and the incoming beams.
I didn´t draw the beams as "line", but made them point by point, checking if a mirror is reached.
If you know some math, you will remember Monsieur Fourier (looking at the x or y-values as
Fourier series from 0 to anzahl), otherwise just enjoy the movements.
On start the sketch chooses one of eight possible movements.
Little blue particles move around. If they get near, they connect building "molecules". I was inspired by some nice sketches like ID268 or ID 2600 to learn something about interacting
In the code you can disable the limitation of only binding two particles. Nice too!
"A"-key enlarges the strength of the attractive force, "a" makes it smaller. "R" enlarges the range of the forces, "r" reduces it. "N" gives a higher number of particles, "n" a smaller number.
Do you know Gerhard Richters famous windows in Cologne Cathedral? Do it on your own :-)
Use your mouse and the r,g,b,i,m,a,k and s-keys!(red,green,blue, invert,mixing with neighbours,k=contrast,"Ausgleich"=leveling to grey and supermixer.