Technical mumbo jumbo incoming
So for my level
Super Monster Truck Mayhem - Score/Time Attack I put together a monster truck with built in scoring and a HUD to tell the driver when they will score points for wheelies, big airs and flips. It actually took quite a bit of time to get working and I am fairly happy with how it turned out. This is probably the 10th iteration of this vehicle.
Note: above pictures have and old non working flip detector.
Features
-Left analog stick allows rotation of vehicle while moving on the ground or in the air. Helps for getting over ramps and doing wheelies.
-
Quadrature encoder based flip detection. I replicated a quadrature encoder
http://en.wikipedia.org/wiki/Rotary_encoder in game. The advantage of a quadrature encoder is its accurate detection of rotation in either direction. When a person begins a jump it knows relatively what position it was in at this time. My quadrature encoder only has 4 sensors(90 degrees of view each, think a pie cut into 4 slices) but it can and probably will be expanded to have more accurate measurements.
1|2
- -
3|4
The one issue is the mechanism takes up five layers. This is due to needing to have four tag sensors in the exact location. Since they cannot be overlayed I needed to have them all on different layers. The 5th layer contains a tag attached to a board bolted to the other layers. The board is attached to a gyroscope so it always points up. When the vehicle rotates, the tag is always in the view of one of the four tag sensors. Each sensor has a specific bit pattern 01 11 10 00 . I then used a simple algorithm that can easily determine which direction the object had rotated
http://www.didel.com/mot/RomEnco.pdf ( sommers algorithm). This algorithm needs knowledge of the previous bit pattern so I implemented data storage in the form of D type flip flops (
http://en.wikipedia.org/wiki/Flip-flop_(electronics) )A full 360 degree rotation involves 4 rotations of 90 degrees.
-
Wheelie detection is implemented using impact sensors on the wheels and body. When the back wheel is the only item touching the ground a counter starts. When the counter reaches a given time 100 points is given to the driver of the vehicle for each second afterwards. The counter only resets when the body or the front wheel touches. Meaning if you are going over bumps and your back wheel comes off the ground you can still get bonus points if you land on your back wheel and keep driving
-Big air detection is implemented and detects when no part of the truck is on the ground
-
Tag based score limiter. My level uses time gates however there is no way to prevent points from accruing when the time runs out. This would leave the person able to continue storing and abusing the points from wheelies, jumps and flips. To prevent this all scoring is based on both a timer and a tag. Each truck detects a tag that signifies it should start scoring and tag that signifies if it should stop scoring. Also there is a timer that ticks down at the same rate as the gated race.
-
HUD Floating in the bed of the truck are counter signifying to the driver if they have wheelied or been in the air enough to gain bonus points.
Current bugs
----------------
One thing i need help on is having a usable suspension that can also support the stress that occurs from flipping in the air. When you rotate quickly in the air the heavy wheels pull on the suspension forcing the springs and pistons out of alignment. They will return but if you do too many flips at once. the vehicle will break.