Skip to content

Commit 5594b82

Browse files
author
Will Wise
committed
asdads
1 parent d44de2b commit 5594b82

File tree

4 files changed

+119
-22
lines changed

4 files changed

+119
-22
lines changed

src/App.vue

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,48 @@
22
<div id="app">
33
<div class="sports-field">
44
<h1>{{ title }}</h1>
5-
<img
6-
class="soccer-goal"
7-
src="/static/soccer-goal.png"
8-
alt="Soccer goal">
9-
<img
10-
class="soccer-ball"
11-
:class="status"
12-
src="/static/soccer-ball.png"
13-
alt="Soccer ball"
14-
@click="shoot">
5+
<board :score="score" :miss="miss"></board>
6+
<goal></goal>
7+
<ball :image="src" @score="score ++" @miss="miss ++"></ball>
158
</div>
169
</div>
1710
</template>
1811

1912
<script>
13+
import Goal from './components/Goal.vue'
14+
import Ball from './components/Ball.vue'
15+
import Board from './components/Board.vue'
16+
2017
export default {
18+
components: {
19+
Goal,
20+
Ball,
21+
Board
22+
},
23+
2124
data () {
2225
return {
26+
score: 0,
27+
miss: 0,
2328
status: '',
24-
title: "Let's play"
29+
title: "Getting started",
30+
goalClass: "something-great",
31+
src: '/static/soccer-ball.png'
2532
}
2633
},
2734
2835
methods: {
29-
shoot () {
30-
const results = [
31-
'miss',
32-
'score'
33-
]
34-
35-
this.status = results[Math.floor(Math.random() * results.length)]
3636
37-
setTimeout(() => {
38-
this.reset()
39-
}, 800)
40-
},
4137
4238
reset () {
4339
this.status = 'reset'
4440
setTimeout(() => {
4541
this.status = ''
4642
}, 500)
43+
},
44+
45+
imageSrc () {
46+
return '/static/soccer-ball.png'
4747
}
4848
}
4949
}

src/components/Ball.vue

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<img
3+
:class="status"
4+
@click="shoot"
5+
class="soccer-ball"
6+
:src="image"
7+
alt="Soccer ball">
8+
</template>
9+
10+
<script>
11+
export default {
12+
data () {
13+
return {
14+
status: ''
15+
}
16+
},
17+
18+
props: [
19+
'image'
20+
],
21+
22+
watch: {
23+
status () {
24+
if ( this.status == 'score' ) {
25+
this.$emit('score')
26+
} else if ( this.status == 'miss' ) {
27+
this.$emit('miss')
28+
}
29+
}
30+
},
31+
32+
methods: {
33+
shoot () {
34+
const results = [
35+
'miss',
36+
'score'
37+
]
38+
39+
this.status = results[Math.floor(Math.random() * results.length)]
40+
41+
setTimeout(() => {
42+
this.reset()
43+
}, 800)
44+
},
45+
46+
reset () {
47+
this.status = 'reset'
48+
setTimeout(() => {
49+
this.status = ''
50+
}, 500)
51+
},
52+
}
53+
}
54+
</script>
55+
56+
<style>
57+
58+
</style>

src/components/Board.vue

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div class="board">
3+
<div class="board-score">
4+
Score: {{ score }}
5+
</div>
6+
<div class="board-miss">
7+
Miss: {{ miss }}
8+
</div>
9+
</div>
10+
</template>
11+
12+
<script>
13+
export default {
14+
props: [
15+
'score',
16+
'miss'
17+
]
18+
}
19+
</script>
20+
21+
<style>
22+
23+
</style>

src/components/Goal.vue

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<img
3+
class="soccer-goal"
4+
src="/static/soccer-goal.png"
5+
alt="Soccer goal">
6+
</template>
7+
8+
<script>
9+
export default {
10+
11+
}
12+
</script>
13+
14+
<style>
15+
16+
</style>

0 commit comments

Comments
 (0)