Skip to content

Commit

Permalink
added game over screen
Browse files Browse the repository at this point in the history
  • Loading branch information
waveoffire committed Apr 26, 2022
1 parent bd0e42a commit 780809b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<script lang="ts">
import Vue from "vue";
import Canvas from "./components/canvas.vue";
export default Vue.extend({
components: {
CanvasApp: Canvas,
Expand Down
7 changes: 6 additions & 1 deletion src/components/canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
<div>
<canvas id="mainCanv" width="500" height="500"></canvas>
<div>Wynik: {{ snakeWidth - 1 }}</div>
<div v-if="gameover">Game over</div>

<game-over-app :gameover="gameover" :score="snakeWidth - 1" />
</div>
</template>

<script lang="ts">
import GameOver from "./gameover.vue";
import Vue from "vue";
export default Vue.extend({
name: "CanvasApp",
components: {
GameOverApp: GameOver,
},
data() {
return {
kierunek: 2,
Expand Down
42 changes: 42 additions & 0 deletions src/components/gameover.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div v-if="gameover" id="gameover">
<div>Game Over</div>
<div>Wynik: {{ score }}</div>
<button @click="refresh">Zagraj ponownie</button>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: ["gameover", "score"],
name: "CanvasApp",
methods: {
refresh() {
window.location.reload();
},
},
});
</script>
<style scoped lang="scss">
#gameover {
background: rgba(54, 54, 54, 0.8);
display: block;
width: 20vw;
height: 20vh;
left: 40vw;
top: 30vh;
line-height: 5vh;
font-size: 3vh;
position: absolute;
border-radius: 20px;
color: RED;
button {
height: 8vh;
width: 10vw;
font-size: 3vh;
border-radius: 20px;
background: rgba(42, 197, 28, 0.8);
border: 1px solid black;
}
}
</style>

0 comments on commit 780809b

Please sign in to comment.