Skip to content
Snippets Groups Projects
Commit d13cd80d authored by Andrew Brown's avatar Andrew Brown
Browse files

First Commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #417 failed
Showing
with 115 additions and 0 deletions
"use strict";
var battleship = /** @class */ (function () {
function battleship(w, h) {
if (w === void 0) { w = 10; }
if (h === void 0) { h = 10; }
this.w = w;
this.h = h;
this.board = this.emptyBoard();
}
battleship.prototype.emptyBoard = function () {
var arr = [];
for (var i = 0; i < this.h * this.w; i++) {
arr.push(0);
}
return arr;
};
battleship.prototype.boardIndex = function (x, y) {
return y * this.w + x;
};
battleship.prototype.x = function (index) {
return index % this.w;
};
battleship.prototype.y = function (index) {
return Math.floor(index / this.w);
};
battleship.prototype.toggleCell = function (x, y) {
var b = this.boardIndex(x, y);
//this.board[b] = !this.board[b]
};
battleship.prototype.isAlive = function (x, y) {
var b = this.boardIndex(x, y);
return (x >= 0) && (y >= 0) && (x < this.w) && (y < this.h)
&& this.board[b] == 1;
};
return battleship;
}());
This diff is collapsed.
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css"
integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B" crossorigin="anonymous">
<title>COSC360 A2</title>
</head>
<body>
<div class="container">
<h1>Assignment 2</h1>
<p>
This is a simple Battleship game.
</p>
<div class="attack" id="attack">
</div>
<div class="buttons" id="but">
<button type="button" class="shipButton" id='destroyer'>Destoyer</button>
<button type="button" class="shipButton" id='rotate'>Rotate</button><br>
<button type="button" class="shipButton" id='cruiser'>Cruiser</button>
<button type="button" class="shipButton" id='delete'>Delete</button><br>
<button type="button" class="shipButton" id='submarine'>Submarine</button>
<button type="button" class="shipButton" id='begin'>Begin</button><br>
<button type="button" class="shipButton" id='battleship'>Battleship</button><br>
<button type="button" class="shipButton" id='carrier'>Carrier</button><br><br>
</div>
<div class="defend" id="defend">
</div>
</div>
<script src="https://d3js.org/d3.v5.min.js"></script>
<script src="./node_modules/react/umd/react.development.js"></script>
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="dist/bundle.js"></script>
<link rel="stylesheet" href="style.css" />
</body>
</html>
../acorn/bin/acorn
\ No newline at end of file
../atob/bin/atob.js
\ No newline at end of file
../babylon/bin/babylon.js
\ No newline at end of file
../browserslist/cli.js
\ No newline at end of file
../cssesc/bin/cssesc
\ No newline at end of file
../csso/bin/csso
\ No newline at end of file
../d3-dsv/bin/dsv2json
\ No newline at end of file
../d3-dsv/bin/dsv2dsv
\ No newline at end of file
../d3-dsv/bin/dsv2dsv
\ No newline at end of file
../d3-dsv/bin/dsv2json
\ No newline at end of file
../errno/cli.js
\ No newline at end of file
../esprima/bin/esparse.js
\ No newline at end of file
../esprima/bin/esvalidate.js
\ No newline at end of file
../he/bin/he
\ No newline at end of file
../import-local/fixtures/cli.js
\ No newline at end of file
../js-yaml/bin/js-yaml.js
\ No newline at end of file
../jsesc/bin/jsesc
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment