Mercurial > malikania
view examples/01-bouncing/client.js @ 99:0addfab87b17
Common: implement basic tilesets, closes #664
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 18 Aug 2017 18:45:07 +0200 |
parents | a1e80d991968 |
children |
line wrap: on
line source
var x = 0; var y = 0; var dx = 1; var dy = 1; var font; var clip; function start(window) { font = new Malikania.Font("fonts/DejaVuSans.ttf", 10); clip = font.clip("Malikania"); x = (640 / 2) - (clip.width / 2); y = (480 / 2) - (clip.height / 2); } function update() { x += dx; y += dy; if (x >= 640 - clip.width) dx = -1; else if (x <= 0) dx = 1; if (y >= 480 - clip.height) dy = -1; else if (y <= 0) dy = 1; } function draw(window) { window.setDrawingColor('lightskyblue'); window.clear(); window.setDrawingColor('white'); window.drawText('Malikania', font, { x: x, y: y }); window.present(); }