Loop Function - Reapism/Skork GitHub Wiki

What is a loop?

The loop function is one of many functions built into the Skork library.

The loop can be used to iterate code statement(s) n times. (where n represents an integer of any valid value.)

**Note: ** The squiggly brackets { } are required even if you're only using one code statement in the body.


Example:

Loop function that's primitive, just loops from inclusive x to y exclusive. (10 times in this example.)

This does not include a loop control variable.

int x = 0;

int y = 10;

sprite s;

// animation for s loop(x->y) {

s.left();

s.right(2);

s.up(2);

s.down();

}


Example:

Loop function using a loop control variable created dynamically.

int x = 0;

int y = 10;

sprite s;

// animation for s

loop(int i = 0; i->y; i+=1) {

s.left(i);

s.right(i + 2);

s.up(i + 5);

s.down(i);

}