A classic browser-based Battleship game, meticulously crafted with Vanilla JavaScript for The Odin Project.
This project is a browser-based implementation of the classic board game Battleship. Developed as part of The Odin Project’s JavaScript course, it showcases fundamental web development concepts including modular JavaScript, DOM manipulation, and interactive game logic. Players can engage in a strategic naval battle against an AI opponent directly in their web browser.
- Classic Gameplay: Enjoy the timeless strategy of Battleship directly in your browser.
- Intelligent AI Opponent: Challenge yourself against a computer player with logical attack patterns.
- Interactive Game Boards: Visually place your ships and launch attacks on a responsive grid.
- Clear Visual Feedback: Instantly see hits, misses, and sunken ships with distinct visual cues.
- Dynamic Game Flow: Start a new game at any time with randomly generated ship placements for both players.
- Responsive Design: Play seamlessly across various devices and screen sizes.
- Modular Codebase: Well-structured and maintainable JavaScript, promoting scalability and understanding.
- Robust Testing: Comprehensive unit and integration tests ensure game logic and functionality are sound.
- 🎯 Computer AI: add more logical attack pattern on hunt mode
- 🎯 Upgrade UX: fix some minors issues on positioning ships and allow ships re positioning
- 🎯 VS Mode: add 2 players mode with privacy switch
Frontend:
Build Tools:
Before you begin, ensure you have the following installed:
- Node.js:
^14.x.xor higher (includes npm)
-
Clone the repository
git clone https://github.com/Franchuphone/battleship.git cd weather-app -
Install dependencies
npm install
-
Start development server
npm run dev
-
Open your browser Visit
http://localhost:8080(or the port indicated in your console)
battleship/
├── src/ # All source code for the game logic and UI
│ ├── css/ # All style sheets
│ ├── fonts/ # Fonts folder
│ ├── html/ # Html templates
│ ├── img/ # Images folder
│ ├── js/ # Game logic and ui manipulations
│ ├── index.js # Entry point of the application
│ └── template.hmlt # Main html file
├── dist/ # Output directory for production builds
├── babel.config.js # Babel configuration for JavaScript transpilation
├── eslint.config.mjs # ESLint configuration for code quality
├── package.json # Project metadata and dependencies
├── package-lock.json # Exact dependency versions
├── webpack.common.js # Common Webpack settings
├── webpack.dev.js # Webpack configuration for development mode
├── webpack.prod.js # Webpack configuration for production build
└── README.md # This file
This project uses ESLint for code linting and Prettier for code formatting.
eslint.config.mjs: Configures ESLint rules and plugins.prettier: Configured indirectly viaeslint-config-prettierto avoid conflicts.
Webpack is used to bundle the application.
webpack.common.js: Contains shared Webpack configurations for both development and production.webpack.dev.js: Extendswebpack.common.jswith development-specific settings (e.g.,webpack-dev-server).webpack.prod.js: Extendswebpack.common.jswith production-specific optimizations.babel.config.js: Configures Babel to transpile modern JavaScript features for wider browser compatibility.
To create a minified and optimized production build of the application:
npm run buildThis command will compile all assets and output them into the dist/ directory, ready for deployment.
The dist/ directory contains all the static files required to run the application. You can deploy these files to any static hosting service, such as:
- GitHub Pages: Push the
distfolder content to agh-pagesbranch. - Vercel/Netlify: These services can automatically detect the build process and deploy the
distfolder. - Any Web Server: Simply copy the contents of the
distfolder to your web server's public directory.
We welcome contributions to the Weather App! If you're interested in improving the project, please consider:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes following a clear commit message convention.
- Push your branch and open a pull request.
The development setup is straightforward, as outlined in the Quick Start section. Ensure you have Node.js and npm installed, and then follow the installation steps.
No particular license, just keep in mind to respect the work of others and just point to this repository for credentials.
- The Odin Project: For providing an excellent curriculum and guiding this project's development.
- date-fns: For providing a comprehensive and easy-to-use library for date manipulation.
- Webpack: For the powerful and flexible module bundler.
- Babel: For enabling the use of modern JavaScript features.
- 🐛 Issues: GitHub Issues
- 👤 Author: Franchuphone
- 📧 Contact: LinkedIn
⭐ Star this repo if you find it helpful!
Made with ❤️ by Franchuphone