view examples/01-bouncing/client.js @ 116:d7025649d85c

Server: add database account Implement accounts using a abstract factory mechanism, the database object creates abstract account which are implemented differently depending on the backend. See: - test_database, - test_account - broken_account Refs #687, #682
author David Demelier <markand@malikania.fr>
date Mon, 11 Sep 2017 13:18:43 +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();
}