Skip to content

dannz510/Tank_Game_V1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tank Game

A simple retro-style 2D tank game built using the Enchant.js library, featuring keyboard and touch controls. Navigate your tank, attack enemies, and clear the map!

🎮 How to Play

Keyboard Controls:

  • ↑ (Up Arrow): Move Tank Up
  • ↓ (Down Arrow): Move Tank Down
  • ← (Left Arrow): Move Tank Left
  • → (Right Arrow): Move Tank Right
  • Spacebar: Attack / Shoot

Touch Controls (for mobile devices):

  • A virtual D-pad will appear on the bottom-left for tank movement (Up, Down, Left, Right).
  • A "Attack" button will appear on the bottom-right to fire.
  • Note: If keyboard controls become unresponsive, click on the game area to re-focus.

✨ Features

  • Classic 2D tank gameplay.
  • Dynamic map scrolling centered on the player.
  • Enemy tanks with basic AI that attack periodically.
  • Collision detection for player and bullets with map obstacles and enemies.
  • Game Over and Winner screens.
  • Sound effects for cannon fire and explosions.
  • Responsive layout that centers the game on the screen.
  • Support for both keyboard and touch inputs.

🚀 Setup & Installation

This is a web-based game, so no complex installation is required.

  1. Clone the repository:

    git clone [https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git](https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git)
    cd YOUR_REPOSITORY_NAME

    (Replace YOUR_USERNAME and YOUR_REPOSITORY_NAME with your actual GitHub details.)

  2. Open index.html: Simply open the index.html file in your web browser. You can do this by double-clicking it or by dragging it into your browser window.

Project Structure:

  • index.html: The main HTML file that sets up the game canvas and loads scripts.
  • style.css: Contains CSS rules for centering the game and styling the info text.
  • script.js: The core JavaScript game logic, including tank movement, enemy AI, bullet mechanics, and UI controls.
  • External Enchant.js Libraries and Assets: The game relies on the Enchant.js library and its plugins, as well as game assets (images, audio) hosted externally. These are linked directly in index.html:
    • https://hankuro.sakura.ne.jp/build/enchant.js (Enchant.js Core)
    • https://hankuro.sakura.ne.jp/build/plugins/ui.enchant.js (Enchant.js UI plugin for virtual controls)
    • https://hankuro.sakura.ne.jp/build/plugins/mixing.enchant.js (Enchant.js Mixing plugin)
    • Various image and audio files from hankuro.sakura.ne.jp.

🛠️ Technologies Used

  • HTML5
  • CSS3
  • JavaScript
  • Enchant.js: A simple JavaScript game engine.
  • Enchant.js UI Plugin: For on-screen touch controls.
  • Enchant.js Mixing Plugin: (Though its specific use isn't immediately obvious from the provided script.js snippet, it's included per the index.html).

🖼️ Screenshots

(It's highly recommended to add screenshots of your game here!) Example: Gameplay Screenshot 1 Player tank navigating the map.

Gameplay Screenshot 2 Mobile view with virtual controls.

🙏 Credits / Assets

This game utilizes assets from hankuro.sakura.ne.jp. Specific asset URLs are included within the script.js and index.html files.

📄 License

This project is open-source. You might want to add a license file (e.g., MIT, Apache 2.0) to your repository.