Skip to content

Battleship game in React typescript & javascript (please switch between branches to see both)

Notifications You must be signed in to change notification settings

orxanaliyev/battleship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

About Game

This game was created as a test project.

When you start the game, you must first set up your initial ships (for now "I shaped" and "dot shaped"). The ships will be placed in the cells where you click, but rotation will be random (for "I shape" is vertical or horizontal). The ships do not overlap, there is at least a single cell between them. The color of the ships is blue (feel free to change colors in Grid.css file (ships - blue, shot cell - grey, sunken ship - red)). The installed ship's button will be disabled after select due the count of this ship.

After setting up all the ships, the Start Attack button will be activated, when you click this button, the program will shoot at random positions (once per position). After shooting the last ship, the program will stop shooting and will be able to tell that "The ships have sunk and the game is over!". The sunken ship will be red, empty shots - grey.

Config object

In the src folder you can find contstans.ts file:

  • greetingWords{} - here you can update the title and description of the game in the header

  • initialShipSetup{} - here you can set ship (count, label, shape, cellSize) and make sure you provide with allShipsCount.

  • finalOuputMessage{} - here you can set message (ex. ships have sunk and game is over.)

About

Battleship game in React typescript & javascript (please switch between branches to see both)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published