v0.58
litecanvas » Devlog
From the beginning I had decided that in litecanvas there would be no functions to detect keyboard inputs (I would need a plugin/extension). But I decided to change my mind and now we have a function called iskeydown(key: string): boolean
.
// basic usage
iskeydown('a') // check if the A key is pressed
iskeydown('arrowup') // check if the ARROW UP is pressed
iskeydown(' ') // check if SPACE is pressed
// also, you can check if "any" key is pressed
iskeydown('any')
// real world example
litecanvas()
function init() {
posx = 0
}
function update (dt) {
const speed = 200
// move to right pressing ARROW RIGHT
if (iskeydown('arrowright')) {
posx += speed * dt
}
// move to right pressing ARROW LEFT
if (iskeydown('arrowleft')) {
posx -= speed * dt
}
}
function draw() {
cls(0)
circfill(posx, CENTERY, 50, 4)
}
litecanvas
HTML5 engine with browser-based playground
Status | In development |
Category | Tool |
Author | Luiz Bills |
Tags | Game engine, html5, javascript, lightweight, minigames, Mouse only, PICO-8, TIC-80 |
Languages | English |
Accessibility | One button |
More posts
- v0.5456 days ago
- How to use litecanvas in LOWREZJAMAug 07, 2024
- v0.42Aug 05, 2024
- v0.41Jul 31, 2024
Leave a comment
Log in with itch.io to leave a comment.