A lightweight 2D browser game built using Kontra.js and HTML5 Canvas.
The player moves inside the canvas using arrow keys.
A target appears at random positions, and whenever the player reaches the target, it relocates to a new random position.
- JavaScript (ES Modules)
- Kontra.js
- HTML5 Canvas
- npm + Vite (dev server)
- Arrow Left โ Move left
- Arrow Right โ Move right
- Arrow Up โ Move up
- Arrow Down โ Move down
- Player movement with boundary constraints
- Target spawns at random positions inside the canvas
- Target relocates when the player overlaps with it
- Simple collision detection (AABB)
git clone https://github.com/satyansh2004/collect-black-ball-game.gitnpm install kontranpm run devOpen the local server URL shown in the terminal.
This project is a practice exercise to understand:
- Game loops
- Sprite-based movement
- Collision detection
- Basic game mechanics using Kontra.js
Play here - https://boxmoves.netlify.app/