Update flappy-bird example
This commit is contained in:
parent
31f11d2389
commit
60a5c2fdee
|
@ -3,6 +3,7 @@
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=0.67, maximum-scale=0.67, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=0.67, maximum-scale=0.67, user-scalable=no">
|
||||||
<link href="css/style.css" rel="stylesheet" type="text/css">
|
<link href="css/style.css" rel="stylesheet" type="text/css">
|
||||||
|
<script src="node_modules/@preserves/core/dist/preserves.js"></script>
|
||||||
<script src="node_modules/@syndicate-lang/core/dist/syndicate.js"></script>
|
<script src="node_modules/@syndicate-lang/core/dist/syndicate.js"></script>
|
||||||
<script src="node_modules/@syndicate-lang/html/dist/syndicate-html.js"></script>
|
<script src="node_modules/@syndicate-lang/html/dist/syndicate-html.js"></script>
|
||||||
<script src="node_modules/@syndicate-lang/timer/dist/syndicate-timer.js"></script>
|
<script src="node_modules/@syndicate-lang/timer/dist/syndicate-timer.js"></script>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
|
"author": "Tony Garnock-Jones <tonyg@leastfixedpoint.com>",
|
||||||
"license": "GPL-3.0+",
|
"license": "GPL-3.0+",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@preserves/core": "0.995",
|
||||||
"@syndicate-lang/core": "*",
|
"@syndicate-lang/core": "*",
|
||||||
"@syndicate-lang/html": "*",
|
"@syndicate-lang/html": "*",
|
||||||
"@syndicate-lang/timer": "*"
|
"@syndicate-lang/timer": "*"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/// SPDX-License-Identifier: GPL-3.0-or-later
|
/// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
/// SPDX-FileCopyrightText: Copyright © 2016-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
|
|
||||||
import { Record, Dataspace, Double, floatValue, Ref, stringify } from '@syndicate-lang/core';
|
import { Turn, Dataspace, Double, floatValue, Ref, Facet } from '@syndicate-lang/core';
|
||||||
import { boot as bootHtml, WindowEvent, template, Anchor } from '@syndicate-lang/html';
|
import { boot as bootHtml, WindowEvent, template, Anchor } from '@syndicate-lang/html';
|
||||||
import { boot as bootTimer, PeriodicTick } from '@syndicate-lang/timer';
|
import { boot as bootTimer, PeriodicTick } from '@syndicate-lang/timer';
|
||||||
|
|
||||||
|
@ -86,9 +86,7 @@ function spawnGame(mainDs: Ref) {
|
||||||
|
|
||||||
on (ypos.value > BOARD_HEIGHT - FLAPPY_HEIGHT) {
|
on (ypos.value > BOARD_HEIGHT - FLAPPY_HEIGHT) {
|
||||||
ypos.value = BOARD_HEIGHT - FLAPPY_HEIGHT;
|
ypos.value = BOARD_HEIGHT - FLAPPY_HEIGHT;
|
||||||
react {
|
assert GameOver();
|
||||||
assert GameOver();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,14 +139,14 @@ function spawnGame(mainDs: Ref) {
|
||||||
react {
|
react {
|
||||||
const pipeNumber = nextPipe.value++;
|
const pipeNumber = nextPipe.value++;
|
||||||
spawn linked named ['pipe', pipeNumber] {
|
spawn linked named ['pipe', pipeNumber] {
|
||||||
runPipe(pipeNumber);
|
runPipe(pipeNumber, Turn.activeFacet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function runPipe(i: number) {
|
function runPipe(i: number, mainPipeFacet: Facet) {
|
||||||
const xlocation = (i + 1) * 324;
|
const xlocation = (i + 1) * 324;
|
||||||
|
|
||||||
let ui = new Anchor();
|
let ui = new Anchor();
|
||||||
|
@ -159,21 +157,17 @@ function spawnGame(mainDs: Ref) {
|
||||||
+ PILLAR_HEAD_HEIGHT * 3;
|
+ PILLAR_HEAD_HEIGHT * 3;
|
||||||
const lowerHeight = FIELD_HEIGHT - upperHeight - PILLAR_GAP;
|
const lowerHeight = FIELD_HEIGHT - upperHeight - PILLAR_GAP;
|
||||||
|
|
||||||
stop on (xpos.value < -(PILLAR_WIDTH + FLAPPY_XPOS));
|
stop mainPipeFacet on (xpos.value < -(PILLAR_WIDTH + FLAPPY_XPOS));
|
||||||
|
|
||||||
at gameDs {
|
at gameDs {
|
||||||
react {
|
once (xpos.value <= 0) send message IncreaseScore();
|
||||||
stop on (xpos.value <= 0) send message IncreaseScore();
|
|
||||||
}
|
|
||||||
|
|
||||||
on asserted Position($flappyXpos, _) =>
|
on asserted Position($flappyXpos, _) =>
|
||||||
xpos.value = xlocation - floatValue(flappyXpos);
|
xpos.value = xlocation - floatValue(flappyXpos);
|
||||||
|
|
||||||
on asserted Position($xpos, $ypos) => {
|
on asserted Position($xpos, $ypos) => {
|
||||||
if (touchingPillar(floatValue(xpos), floatValue(ypos))) {
|
if (touchingPillar(floatValue(xpos), floatValue(ypos))) {
|
||||||
react {
|
assert GameOver();
|
||||||
assert GameOver();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,11 @@
|
||||||
resolved "https://registry.yarnpkg.com/@preserves/core/-/core-0.990.0.tgz#c57c1c3d5159fc17477a4205d5a94a78fbf5b1aa"
|
resolved "https://registry.yarnpkg.com/@preserves/core/-/core-0.990.0.tgz#c57c1c3d5159fc17477a4205d5a94a78fbf5b1aa"
|
||||||
integrity sha512-Mx013USv9JU1SrtMxaJISETBy2LZ402xH8ZnQI4JzG6W27ZwGV36DQrXAfF0x6cOmZMGKwJNqQrvmFhh7mEn6w==
|
integrity sha512-Mx013USv9JU1SrtMxaJISETBy2LZ402xH8ZnQI4JzG6W27ZwGV36DQrXAfF0x6cOmZMGKwJNqQrvmFhh7mEn6w==
|
||||||
|
|
||||||
|
"@preserves/core@0.995":
|
||||||
|
version "0.995.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@preserves/core/-/core-0.995.0.tgz#d6badccd1fe56e45f23e01b4c8a33f421749e76b"
|
||||||
|
integrity sha512-0ICNcZ7HkBal1OJwoUuc1+KqoTQNJl2kYI3/nMtfrtNMem908unpydLo20k44Fgh/SRJekWaiRYSzKTcOo0+Tg==
|
||||||
|
|
||||||
"@preserves/schema@0.990.1":
|
"@preserves/schema@0.990.1":
|
||||||
version "0.990.1"
|
version "0.990.1"
|
||||||
resolved "https://registry.yarnpkg.com/@preserves/schema/-/schema-0.990.1.tgz#233e25855194ce0f6ffaa9968d59e50b7dc8635a"
|
resolved "https://registry.yarnpkg.com/@preserves/schema/-/schema-0.990.1.tgz#233e25855194ce0f6ffaa9968d59e50b7dc8635a"
|
||||||
|
|
Loading…
Reference in New Issue