XST framework cool movement effect.

Xst is a simple framework developed by me and is kind of a bunch of objects and functions to simulate a basic language.
This is an example of a cool movement with circles.

winScreen(640, 480, false);
setFps(20);
setBackColor(COLOR.WHITE);

//var declaration
var DPI = PI * 2;
var PHIDELTA = DPI / 15;
var PHISTEP  = DPI / 50;

var current_phi = 0;
var radius = 20;
var small_radius = 3;
var distance = 23;
var w = getScreenWidth();
var h = getScreenHeight();

function main() {
    var x, xBall, yBall, phi, phiIndex;
    current_phi += PHISTEP;
    clear();
    for(x=0; x< w+radius; x+=distance) {
        for(y=0; y < h+radius; y+=distance) {
            circle(x, y, radius, COLOR.BLACK);
            phiIndex = (x + y) % (2 * w) / radius;
            phi = phiIndex * PHIDELTA + current_phi;
            xBall = cos(phi) * radius + x;
            yBall = sin(phi) * radius + y;
            fillCircle(xBall, yBall, small_radius, COLOR.BLACK);
        }
    }
} 

See it in action Here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s