Implementation Notes
This aquarium simulation demonstrates several JavaScript best practices:
- Object-Oriented Design: Each fish is an instance of the Fish class, encapsulating its own state and behavior.
- Delta Time: Animation uses delta time calculations for frame-rate independent movement.
- Smooth Rotation: Fish rotate smoothly toward target angles using a maximum rotation per frame.
- Boundary Interaction: Fish gradually turn toward the center when approaching edges rather than bouncing.
- Wandering Behavior: Each fish has its own wander timer and strength for organic movement patterns.
- Efficient Rendering: Canvas transforms are used for rotation, and all drawing happens in a single pass.
- Visual Polish: Tail wiggle animation, proper orientation, and subtle background elements enhance the aquarium feel.