Skip to content

Sina-Ghiasi/threejs-catapult-game

Repository files navigation

ThreeJS Catapult Game 🎮

GitHub Stars GitHub Issues GitHub License GitHub Repo Size GitHub code size in bytes GitHub Last Commit Build Status Vite

A thrilling 3D catapult game built with Three.js and Vite. Choose your level, charge up your catapult's power, and launch projectiles to defeat enemies across challenging stages! 🚀

Table of Contents

🌟 Features

  • 🎮 Level Selection: Choose from 4 unique levels (1 to 4) before starting a new game, each with increasing difficulty.
  • 🎯 Power-Based Gameplay: Hold a button or key to charge the catapult’s power and release to fire.
  • 🖼️ 3D Graphics: Smooth and immersive visuals powered by Three.js.
  • Physics-Based Mechanics: Realistic projectile motion with Cannon.js.
  • 🏆 Stage Progression: Defeat all enemies in a level to complete it and replay or choose another level.
  • 🖱️ Simple Controls: Use mouse or keyboard to select levels, charge, and fire.
  • 🚀 Fast Development: Built with Vite for a modern, blazing-fast dev experience.
  • 📱 Responsive Design: Playable on desktop and mobile devices.
  • 🌍 Open Source: Fork, modify, and contribute!

🛠️ Tech Stack

  • Three.js: JavaScript 3D library for rendering.
  • Cannon.js: Physics engine for realistic projectile motion.
  • Vite: Next-generation frontend tooling for fast builds and development.
  • HTML5/CSS3: Game interface and styling.
  • JavaScript: Core game logic and interactivity.

🚀 Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • A modern web browser (Chrome, Firefox, Edge, etc.)

Installation

  1. Clone the repository:
    git clone https://github.com/Sina-Ghiasi/threejs-catapult-game.git
  2. Navigate to the project directory:
    cd threejs-catapult-game
  3. Install dependencies:
    npm install
  4. Start the development server:
    npm run dev
  5. Open your browser and visit http://localhost:5173 (or the port shown in the terminal) to play.

Build for Production

To create a production-ready build:

npm run build

The output will be in the dist folder. Serve it with any static file server.

🎮 How to Play

  1. Select Level: Choose a level (1 to 4) from the main menu before starting a new game. Higher levels increase difficulty.
  2. Charge Power: Hold the mouse button or a designated key (e.g., spacebar) to increase the catapult’s firing power.
  3. Fire: Release the button/key to launch the projectile at a fixed angle.
  4. Defeat Enemies: Hit all enemies in the selected level to win and return to the level selection menu.
  5. Replay or Switch Levels: After completing a level, choose to replay or select a different level.

📸 Screenshots

Main Menu Gameplay
Main Menu Gameplay

🤝 Contributing

Contributions are welcome! 🙌 Follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/awesome-feature).
  3. Make your changes and commit (git commit -m 'Add awesome feature').
  4. Push to the branch (git push origin feature/awesome-feature).
  5. Open a Pull Request.

📜 License

This project is licensed under the MIT License. See the LICENSE file for details. The MIT License applies retroactively to all code and commits in this repository, including past contributions, unless explicitly stated otherwise.

🌐 Live Demo

Play the game now at https://sina-ghiasi.github.io/threejs-catapult-game/

About

A physics-based catapult game powered by Three.js and Cannon-es. Experience realistic physics and fun gameplay—play it online now!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published