Added start screen with countdown and advancing level.

This commit is contained in:
2020-12-27 14:36:07 +01:00
parent 411720765d
commit b63e24cc56
4 changed files with 110 additions and 7 deletions

View File

@@ -3,7 +3,8 @@
<Level :level="level" />
<Timer />
<Buffer />
<Matrix />
<Matrix v-on:won="level++" v-on:lost="lost = true" />
<Start :level="level" v-on:start="nextLevel" />
</main>
</template>
@@ -13,6 +14,7 @@
import Timer from "./components/Timer.vue";
import Buffer from "./components/Buffer.vue";
import Matrix from "./components/Matrix.vue";
import Start from "./components/Start.vue";
import { Game } from "./game/Game";
export default defineComponent({
@@ -20,7 +22,8 @@
Level,
Timer,
Buffer,
Matrix
Matrix,
Start
},
setup() {
const game = ref(new Game({
@@ -36,10 +39,28 @@
timeoutMilliseconds: 60_000,
}));
provide("game", game);
const level = ref(1);
const level = ref(0);
const lost = ref(false);
function nextLevel() {
game.value = new Game({
matrix: [
"AA", "BB", "CC",
"DD", "AA", "BB",
"CC", "DD", "DD",
],
sequences: [
["DD", "CC", "AA"],
],
maxBufferLength: 3,
timeoutMilliseconds: 60_000,
});
}
return {
level
level,
lost,
nextLevel
}
}
});