Skip to content

Commit

Permalink
Merge branch 'main' into task/xsebek/time-vs-clock
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Sep 15, 2024
2 parents bc06667 + c37334f commit e050cf8
Show file tree
Hide file tree
Showing 6 changed files with 44,134 additions and 17 deletions.
14 changes: 8 additions & 6 deletions data/scenarios/Testing/562-lodestone.sw
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ def ifC = \p.\t.\e.
if b t e
end;

def until = \p.\t.
ifC p t {until p t}
def waitFor = \e.\t.
watch down;
wait 100;
ifC (ishere e) t {waitFor e t}
end;

def repeat = \c.
Expand All @@ -29,18 +31,18 @@ end;

// get one lodestone
build {log "Hey!"; turn north; m2; l <- grab; turn back; m2; place l};
until (ishere "lodestone") {grab};
waitFor "lodestone" {grab};

// get two bit (0)
build {
log "Hi!";
repeat (
log "I am going for a bit";
turn east; m2; x <- until (ishere "bit (0)") {harvest}; turn back; m2; place x;
turn east; m2; x <- waitFor "bit (0)" {harvest}; turn back; m2; place x;
log "I brought a bit";
)};
until (ishere "bit (0)") {grab};
until (ishere "bit (0)") {grab};
waitFor "bit (0)" {grab};
waitFor "bit (0)" {grab};

make "bit (1)";
make "drill bit"
2 changes: 2 additions & 0 deletions data/scenarios/Testing/562-lodestone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ robots:
- workbench
- 3D printer
- branch predictor
- rolex
inventory:
- [10, drill]
- [10, lambda]
Expand All @@ -37,6 +38,7 @@ robots:
- [10, strange loop]
- [10, branch predictor]
- [10, toolkit]
- [10, rolex]
- [0, drill bit]
- [0, bit (0)]
- [0, bit (1)]
Expand Down
8 changes: 4 additions & 4 deletions web/play.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<html>
<head>
<title>Web frontend</title>
<script src="https://pixijs.download/release/pixi.js"></script>
<script src="script/pixi.js"></script>

<script src="script/display.js"></script>
<script src="script/fetch.js"></script>

<script>
<script type="module">

function startLoop() {
async function startLoop() {
const button = document.getElementById('restart-button');
button.style.display = 'none';

let displayWidth = 600;
let displayHeight = 300;
let out = setupGraphics(button, displayWidth, displayHeight);
let out = await setupGraphics(button, displayWidth, displayHeight);
let appView = out[0];
let graphics = out[1];
doFetch(button, appView, graphics, displayWidth, displayHeight);
Expand Down
9 changes: 5 additions & 4 deletions web/script/display.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
function setupGraphics(button, displayWidth, displayHeight) {
async function setupGraphics(button, displayWidth, displayHeight) {

const app = new PIXI.Application();
// Create the application helper and add its render target to the page
let app = new PIXI.Application({
await app.init({
width: displayWidth,
height: displayHeight,
backgroundColor: 0xFFFFFF
});

document.body.insertBefore(app.view, button);
document.body.insertBefore(app.canvas, button);

const graphics = new PIXI.Graphics();
app.stage.addChild(graphics);
return [app.view, graphics];
return [app.canvas, graphics];
}
5 changes: 2 additions & 3 deletions web/script/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ function drawGraphics(graphics, colorMap, grid) {
let colorIdx = row[colIdx];
let color = colorMap[colorIdx];

graphics.beginFill(color);
let xPos = colIdx * cellSize;
let yPos = rowIdx * cellSize;
graphics.drawRect(xPos, yPos, xPos + cellSize, yPos + cellSize);
graphics.endFill();
graphics.rect(xPos, yPos, xPos + cellSize, yPos + cellSize);
graphics.fill(color);
}
}
}
Expand Down
Loading

0 comments on commit e050cf8

Please sign in to comment.