[DEPRECATED]
As part of the lecture, we developed a small JApplet game. I decided to create an avoider.
Rules:
- don’t toch the wall
- don’t touch the red circles
- circles will bounce off the walls and each other
- circles will grow over time
- catch the green circle to reduce the size of the circles and gain 3 seconds of shield power
- the shield will protect you from all threats
- you have 3 seconds of shield power for an easy start
» Open the game in a new window
I also wrote my own “collision detection” for the game, as there is no intersect method for ovals:
let’s call our circles a and b:
If sqrt((bx-ax)²+(by-ay)²) < (a.radius + b.radius), then a and b are colliding.
The collision is only 1D, without friction etc., so I just swap the velocity-vectors of the circles.