A fun, browser-based 2D game where you navigate a blue square through gaps in moving pillars. Built with vanilla HTML, CSS, and JavaScript.
HTML Floater is a fast-paced obstacle avoidance game inspired by classic arcade games. Control your player and dodge incoming pillars with gaps to survive as long as possible!
- Open
index.htmlin your web browser - Use WASD or Arrow Keys to move:
- W / ↑ - Jump/Move Up
- A / ← - Move Left
- S / ↓ - Move Down
- D / → - Move Right
- Space - Jump with gravity mechanics
- Navigate through the gaps in the pillars without hitting them
- Survive as long as possible!
- Smooth Controls - WASD and arrow key support for flexible gameplay
- Gravity Physics - Realistic falling and jumping mechanics
- Dynamic Obstacles - Randomly generated pillars with variable gaps
- Responsive Canvas - Full-screen game environment
- Collision Detection - Game mechanics ready for hit detection
- HTML5 - Canvas API for rendering
- CSS3 - Styling and layout
- Vanilla JavaScript - Game loop, physics, and input handling
htmlFloater/
├── index.html # Main HTML file with canvas element
├── script.js # Game logic, physics, and controls
├── style.css # Styling for the canvas and page
└── README.md # This file
- Modern web browser (Chrome, Firefox, Safari, Edge)
- Clone or download this repository
- Open
index.htmlin your browser - Start playing!
No build tools or dependencies required—pure vanilla JavaScript!
- Player - Blue square (15x15 pixels) that you control
- Pillars - Black obstacles that spawn from the right and move left
- Gap - 80-pixel opening between top and bottom pillars for safe passage
- Gravity - Player falls unless jumping or moving upward
- Collision - Game ready for collision detection implementation
Want to tweak the game? Edit these values in script.js:
gravity- Adjust falling speedjumpStrength- Control jump heightgapHeight- Adjust difficulty by changing the gap sizespawnTimer- Control how often pillars appear- Colors and sizes in the object properties
Change the canvas background in style.css:
#gameCanvas {
background-color: rgb(145, 11, 1); /* Change this */
}- Collision detection & game over state
- Score/points system
- Sound effects
- Mobile touch controls
- Difficulty levels
Free to use and modify. Have fun!
Feel free to fork, modify, and improve! If you add cool features, share them!