diff options
| author | RogerGabeller-ml <78610776+RogerGabeller-ml@users.noreply.github.com> | 2024-10-27 05:58:46 +0000 |
|---|---|---|
| committer | RogerGabeller-ml <78610776+RogerGabeller-ml@users.noreply.github.com> | 2024-10-27 05:58:46 +0000 |
| commit | 6e45ba9e67f9318d7771badf0ce4e89a8659e45d (patch) | |
| tree | 4d8562728fa8ed8149da927cd2d908484f115bb9 /src/App.vue | |
| parent | 3cd83e084e4ab1fa06f74b83f2a2060e14dd9b10 (diff) | |
Add cool function
Diffstat (limited to 'src/App.vue')
| -rw-r--r-- | src/App.vue | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/App.vue b/src/App.vue index 4dda318..79d4b33 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,7 @@ <!-- eslint-disable @typescript-eslint/no-unused-vars --> <script setup lang="ts"> import { onMounted, onUnmounted, ref, useTemplateRef } from "vue"; +import axios from "axios"; // export type Board = Array<Array<string | number>>; @@ -16,6 +17,11 @@ type Brick = { hit?: boolean; }; +async function fetchSolutions() { + const response = await axios.get("http://localhost:8000/random"); + return response.data; +} + //****** data ****** const bricks: Array<Array<Brick>> = [ @@ -39,7 +45,7 @@ const bricks: Array<Array<Brick>> = [ ], ]; -let currentProblem = ref("(λf. λx. f (f x)) (λy. * y 2) 5"); +let currentProblem = ref(""); let nextStep = 1; let message: string | null = null; @@ -368,7 +374,7 @@ function tick() { drawMessage(); } -function start() { +async function start() { addEventListener("keydown", (event) => { if (event.key === "a") { moveDirection = "left"; @@ -394,6 +400,16 @@ function start() { if (isFiringMode) isFire = true; }); + const solutions = await fetchSolutions(); + + bricks.forEach((row, rowIndex) => { + row.forEach((brick, brickIndex) => { + brick.problem = solutions.steps[rowIndex * 2 + brickIndex]; + }); + }); + + currentProblem.value = bricks[0][0].problem; + gameInterval = setInterval(tick, 16); } |
