implement restart game

master
Peter Babič 3 years ago
parent 2f33323f54
commit 6c3ff2b904
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 24
      src/App.svelte

@ -3,6 +3,7 @@
</script>
<script>
import { onMount } from "svelte"
const pole = 0
const hole = 1
const pick = 2
@ -13,6 +14,12 @@
let circles = []
let playing = true
let bold = false
const restart = () => {
circles = []
playing = true
bold = false
const numCircles = 15
for (let i = 0; i < numCircles; i++) {
@ -62,6 +69,7 @@
jumps.addEdge(9, 11)
jumps.addEdge(9, 14)
jumps.addEdge(11, 14)
}
const commonBetween = (a, b) =>
adjcs.adjacencyList[a].filter(common =>
@ -120,6 +128,7 @@
if (hints.length == 0) {
playing = false
bold = true
}
return
@ -130,6 +139,8 @@
clearDests()
}
}
onMount(() => restart())
</script>
<style>
@ -212,13 +223,24 @@
background-color: blue;
}
.restart {
cursor: pointer;
}
.playing {
visibility: hidden;
}
.bold {
font-weight: bold;
}
</style>
<main>
<div class:playing>GAME OVER</div>
<div>
<span class="restart" class:bold on:click={restart}>RESTART GAME</span>
<span class:playing> | GAME OVER</span>
</div>
<div class="triangle">
{#each circles as _, i}
<div

Loading…
Cancel
Save