UK Bebras


OUCC Tutorials: blockly movie [1 of 4]

Tutorials index

Blockly Movie Tasks

The movie tasks build on the picture tasks. If you have not already looked at the Blockly Picture Tasks tutorial please do so before continuing with this one.

The picture module provides blocks for creating shapes and lines. The movie module adds to this some sprite blocks and a time block:

time block This block returns the frame integer from 0 to 100.

The key to understanding these tasks is to realise that the code you write is executed 101 times in a movie time loop to create the animation. (This means that in some instances your code might not complete in each frame which can produce some weird results!)

The process of drawing each movie frame is like this:
1. Remove old objects (shapes and lines).
2. Execute the code blocks in the workspace
3. Draw the objects onto the canvas.

The main blocks:
time block returns the frame integer from 0 to 100.

This can be used in place of any of the numerical parameters in the Add shape block:
Try running the code in the workspace below. Then try replacing each of the numbers, one at a time, with the time block and re-running the code each time to see what happens.
red square movie

Interesting huh? Now have a look at the examples below to explore, in a little more detail, how this module works.

Next >>

Example 1 - Using an if else clause
Example 2 - Using just an if clause
Example 3 - Why you should avoid loops in this module

Tutorials index