sprite/main.js
/**
* main.js v0.0.1
* Copyright (c) 2016 kengo92i
*/
handyGraphic.globalize();
window.onload = function () {
var Hg = new Graphic(),
win = Hg.Open(400, 400);
var isFall = true,
ballPainter = {
paint: function (sprite, win) {
Hg.Clear();
Hg.CircleFill(sprite.x, sprite.y, 20);
}
},
ballToFall = {
execute: function (sprite, win, time) {
if (isFall) { sprite.y -= 1; }
if (sprite.y <= 20) {
isFall = false;
}
}
},
ball = new Sprite("ball", ballPainter, [ ballToFall ]);
/*
var ball = new Sprite("ball",
{
paint: function (sprite, win) {
Hg.Clear();
Hg.CircleFill(sprite.x, sprite.y, 50);
}
},
[{
execute: function (sprite, win, fps) {
if (isFall) {
sprite.y -= 1;
}
if (sprite.y <= 0) {
isFall = false;
}
}
}]);
*/
ball.x = 150;
ball.y = 400;
var scene1 = new Scene();
scene1.update = function () {
ball.update(win, 1);
};
scene1.draw = function () {
ball.paint(win);
};
scene1.start();
};