Skip to content

Commit

Permalink
control with arrow on fengari
Browse files Browse the repository at this point in the history
  • Loading branch information
jardimdanificado committed May 3, 2024
1 parent c0948ca commit 746af75
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
26 changes: 21 additions & 5 deletions entrypoint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ for x = 0, #currentRoom.map-1 do
end

window.brout.player = window:Object()
window.brout.player.x = br.player.position["local"].x
window.brout.player.y = br.player.position["local"].y
window.brout.player.position = window:Object()

function window._redraw()
window.brout.player.position["local"] = window:Object()
window.brout.player.position["local"].x = br.player.position["local"].x -1
window.brout.player.position["local"].y = br.player.position["local"].y -1

window.brout.player.position["global"] = window:Object()
window.brout.player.position["global"].x = br.player.position["global"].x -1
window.brout.player.position["global"].y = br.player.position["global"].y -1

function br.redraw()
window.brout = window:Object();
window.brout.room = window:Array()

Expand All @@ -38,6 +45,15 @@ function window._redraw()
end

window.brout.player = window:Object()
window.brout.player.x = br.player.position["local"].x
window.brout.player.y = br.player.position["local"].y
window.brout.player.position = window:Object()

window.brout.player.position["local"] = window:Object()
window.brout.player.position["local"].x = br.player.position["local"].x -1
window.brout.player.position["local"].y = br.player.position["local"].y -1

window.brout.player.position["global"] = window:Object()
window.brout.player.position["global"].x = br.player.position["global"].x -1
window.brout.player.position["global"].y = br.player.position["global"].y -1

window:resizeCanvas((11 * #currentRoom.map) + 2, (11 * #currentRoom.map[1]) + 2)
end
24 changes: 23 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@
//brutopolis code
fengari.load(await fetch("entrypoint.lua").then(response => response.text()))()

keyPressed = function()
{
if (key === 'd')
{
fengari.load("br.d()")()
}
else if (key === 'a')
{
fengari.load("br.a()")()
}
else if (key === 'w')
{
fengari.load("br.w()")()
}
else if (key === 's')
{
fengari.load("br.s()")()
}
// Uncomment to prevent any default behavior.
// return false;
}

draw = function()
{
background(220)
Expand All @@ -48,7 +70,7 @@
}
}
}
image(imgs.human, brout.player.x * 11, brout.player.y * 11, 12, 12)
image(imgs.human, brout.player.position.local.x * 11, brout.player.position.local.y * 11, 12, 12)
}
}
main()
Expand Down

0 comments on commit 746af75

Please sign in to comment.