Draw a squirrel

This change introduces the Drawable class, which corresponds to a
Scratch sprite or clone. It supports setting its "skin" (corresponding
to a Scratch costume) by md5+extension, but currently only supports
bitmap skins. Drawables can be created, destroyed, and otherwise
manipulated by ID through the renderer.
This commit is contained in:
Christopher Willis-Ford
2016-05-17 13:52:37 -07:00
parent 60931611d4
commit dbe3f1370b
5 changed files with 268 additions and 37 deletions

View File

@@ -11,11 +11,23 @@
<script>
var canvas = document.getElementById('scratch-stage');
var renderer = new RenderWebGL(canvas);
var drawableID = renderer.createDrawable();
function step() {
function drawStep() {
renderer.draw();
requestAnimationFrame(step);
requestAnimationFrame(drawStep);
}
step();
var direction = 90;
var posX = 0;
var posY = 0;
var scale = 100;
function thinkStep() {
direction += 0.1;
renderer.setDrawablePosition(drawableID, posX, posY);
renderer.setDrawableDirection(drawableID, direction);
renderer.setDrawableScale(drawableID, scale);
}
drawStep();
setInterval(thinkStep, 1/60);
</script>
</html>