Skip to content

Instantly share code, notes, and snippets.

@umkl
Created September 30, 2022 06:45
Show Gist options
  • Save umkl/95f20d97d4ae3d79c55a703825d434d4 to your computer and use it in GitHub Desktop.
Save umkl/95f20d97d4ae3d79c55a703825d434d4 to your computer and use it in GitHub Desktop.
const player = "p";
const wall = "w";
const enemy = "e";
const obstacle = "o";
setLegend(
[ player, bitmap`
....288888......
...222888888....
...222880808....
...228888888....
....28888888....
....2.888888....
.......8888.....
........8.......
........8.......
........8.......
.......888......
........8.......
.......888......
.......8.8......
................
................` ],
[ enemy, bitmap`
................
................
.........CCC....
.......CCCCC....
......CCCCC.....
.....888888.....
.....808808.....
.....888888.....
.......88.......
...4444444444...
...4444444444...
...44.4444.44...
...88.4444.88...
...88.4444.88...
......4444......
................`],
[ obstacle, bitmap`
................
......CCCC......
......C88C......
......C88C......
......C55C......
.....CC55CC.....
....55555555....
....55555555....
....55555555....
....55555555....
....85555558....
.....555555.....
.....555555.....
......8..8......
......0..0......
................`],
);
const level = map`
.......
.......
.......
.......`
setMap(level)
addSprite(1,1, player)
addSprite(2,2, obstacle)
addSprite(2,3, enemy)
setSolids([player, obstacle, enemy])
onInput("w", () => {
moveForward();
makeLoop();
})
onInput("s", () => {
getFirst(player).y += 1
})
onInput("a", () => {
getFirst(player).x -= 1
})
onInput("d", () => {
getFirst(player).x += 1
})
function moveForward(){
console.log("hes")
getFirst(player).y -= 1
}
function makeLoop(){
//setInterval(moveForward, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment