Table of Contents
This repository showcases a collection of interactive games developed exclusively with Vanilla JavaScript, HTML5, and CSS3. By focusing on these core web technologies, the project emphasizes a deep understanding of fundamental concepts, efficient performance, and meticulous control over every aspect of the codebase.
Developing games with Vanilla JavaScript and the HTML5 <canvas> element offers several advantages:
-
Deep Understanding of Core Technologies: Building games from scratch without external libraries or frameworks fosters a comprehensive grasp of JavaScript and browser APIs. This foundational knowledge is crucial for any software engineer aiming to excel in web development.
-
Enhanced Performance: By eliminating the overhead associated with external libraries, games can achieve optimized performance, leading to smoother animations and more responsive gameplay.
-
Complete Code Control: Direct manipulation of the codebase allows for tailored solutions and fine-tuned optimizations, ensuring that the game's architecture aligns perfectly with its design requirements.
To explore and run the games in this collection:
-
Clone the Repository:
git clone https://github.com/ibra-kdbra/JS_game_collections.git
-
Navigate to the Project Directory:
cd JS_game_collections -
Serve it locally: the hub uses ES modules, which browsers won't load from
file://. Any static server works:python3 -m http.server 8000
Then open http://localhost:8000.
The hub and the Art Lab page are generated from one registry, assets/js/data.js.
- Add an entry to
games(orexperiments) with itsslug,title,href,blurb,genre,inputsandmobileflag. Setmobile: trueonly after checking the game at phone size with touch. - Add a 16:10 thumbnail as
assets/thumbs/<slug>-480.webpand<slug>-960.webp. - Re-render the pages so the list works without JavaScript:
node tools/render-pages.mjs
node tools/render-pages.mjs --checkexits non-zero if the pages are stale.
See docs/UPGRADE_PLAN.md for the roadmap and CREDITS.md for the original authors and licences of the games, sounds and libraries.
Each game in this collection is developed following a structured approach:
-
Conceptualization and Design: Define the game's mechanics, objectives, and user interactions. Create wireframes or sketches to visualize the game's layout and flow.
-
Setting Up the Development Environment: Structure the project directory, ensuring a clean separation of HTML, CSS, and JavaScript files. Utilize semantic HTML5 elements and organize assets systematically.
-
Implementing the Game Logic: Employ algorithms and data structures to manage game states, handle user inputs, and control game dynamics.
-
Rendering Graphics with HTML5 Canvas, or build with good js logic and css art:
- Drawing Shapes and Images: Use canvas APIs to render game elements.
- Animating Game Objects: Implement game loops and animation frames for smooth motion.
- Collision Detection: Develop algorithms to detect and respond to interactions between game entities.
- Try the best pattern for your game.
For a comprehensive guide on using the canvas element, refer to the MDN Web Docs on Canvas API.
-
Styling with Pure CSS:
- Designing Responsive Layouts: Ensure the game adapts to various screen sizes and orientations.
- Applying Thematic Styles: Use CSS to create immersive themes that align with the game's concept.
- Incorporating Animations and Transitions: Add subtle animations to improve interactivity and feedback.
-
Testing and Optimization: Rigorously test each game to identify and fix bugs. Optimize code and assets to ensure efficient performance across different devices and browsers.(The finishing touches)
-
2048 Clone: A sliding tile puzzle game implementing algorithmic logic with an AI mind playing instead of you.
-
Hangman: Classic word-guessing game demonstrating string manipulation and event handling.
-
Tetris: The timeless block-stacking game showcasing array manipulation and collision detection.
-
PacMan: A rendition of the iconic arcade game, highlighting pathfinding algorithms and sprite animations.
-
Tower Defense: A tower defense game where players control towers to defend against waves of enemies.
