From c215b3c24717623367b017fa59a9adc539733624 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:39:12 +0530 Subject: [PATCH 1/4] Create index.html --- Hoplite/index.html | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Hoplite/index.html diff --git a/Hoplite/index.html b/Hoplite/index.html new file mode 100644 index 00000000..b0dadd51 --- /dev/null +++ b/Hoplite/index.html @@ -0,0 +1,16 @@ + + + + + + Hoplite Game + + + +
+

Hoplite Game

+
+
+ + + From 4cde179b15ba5eee89f1041d2cae3c530011cc00 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:39:41 +0530 Subject: [PATCH 2/4] Create styles.css --- Hoplite/styles.css | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Hoplite/styles.css diff --git a/Hoplite/styles.css b/Hoplite/styles.css new file mode 100644 index 00000000..912834aa --- /dev/null +++ b/Hoplite/styles.css @@ -0,0 +1,43 @@ +body { + font-family: Arial, sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #f5f5f5; + margin: 0; +} + +.container { + text-align: center; + background-color: #fff; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); +} + +#gameBoard { + display: grid; + grid-template-columns: repeat(5, 50px); + gap: 5px; + margin: 20px 0; +} + +.cell { + width: 50px; + height: 50px; + background-color: #ddd; + display: flex; + justify-content: center; + align-items: center; + border: 1px solid #ccc; + cursor: pointer; +} + +.cell.hero { + background-color: #ffa; +} + +.cell.enemy { + background-color: #f88; +} From fd88930f1b31fd07e1a90088e33874245c4a147f Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:40:00 +0530 Subject: [PATCH 3/4] Create script.js --- Hoplite/script.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Hoplite/script.js diff --git a/Hoplite/script.js b/Hoplite/script.js new file mode 100644 index 00000000..1c289935 --- /dev/null +++ b/Hoplite/script.js @@ -0,0 +1,61 @@ +document.addEventListener('DOMContentLoaded', () => { + const gameBoard = document.getElementById('gameBoard'); + const boardSize = 5; + const heroPosition = { x: 2, y: 2 }; + const enemies = [{ x: 1, y: 1 }, { x: 3, y: 3 }]; + + function createBoard() { + for (let y = 0; y < boardSize; y++) { + for (let x = 0; x < boardSize; x++) { + const cell = document.createElement('div'); + cell.classList.add('cell'); + cell.dataset.x = x; + cell.dataset.y = y; + gameBoard.appendChild(cell); + } + } + renderBoard(); + } + + function renderBoard() { + document.querySelectorAll('.cell').forEach(cell => { + cell.classList.remove('hero', 'enemy'); + }); + + const heroCell = document.querySelector(`.cell[data-x='${heroPosition.x}'][data-y='${heroPosition.y}']`); + heroCell.classList.add('hero'); + + enemies.forEach(enemy => { + const enemyCell = document.querySelector(`.cell[data-x='${enemy.x}'][data-y='${enemy.y}']`); + enemyCell.classList.add('enemy'); + }); + } + + function moveHero(x, y) { + if (x >= 0 && x < boardSize && y >= 0 && y < boardSize) { + heroPosition.x = x; + heroPosition.y = y; + renderBoard(); + } + } + + document.addEventListener('keydown', (event) => { + const { x, y } = heroPosition; + switch (event.key) { + case 'ArrowUp': + moveHero(x, y - 1); + break; + case 'ArrowDown': + moveHero(x, y + 1); + break; + case 'ArrowLeft': + moveHero(x - 1, y); + break; + case 'ArrowRight': + moveHero(x + 1, y); + break; + } + }); + + createBoard(); +}); From 2368d8fe365e5e2e9b00b23f5657cf9b502b91b0 Mon Sep 17 00:00:00 2001 From: Aditi Bansal <142652964+Aditi22Bansal@users.noreply.github.com> Date: Fri, 5 Jul 2024 15:40:25 +0530 Subject: [PATCH 4/4] Create manifest.json --- Hoplite/manifest.json | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Hoplite/manifest.json diff --git a/Hoplite/manifest.json b/Hoplite/manifest.json new file mode 100644 index 00000000..2357f631 --- /dev/null +++ b/Hoplite/manifest.json @@ -0,0 +1,27 @@ +{ + "name": "Hoplite Game", + "short_name": "Hoplite", + "description": "A simple web-based strategy game inspired by Hoplite.", + "version": "1.0.0", + "manifest_version": 2, + "start_url": "index.html", + "display": "standalone", + "background_color": "#f5f5f5", + "theme_color": "#ffffff", + "orientation": "portrait", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "permissions": [ + "storage" + ] +}