eb8115aa7e
Replaced the global 'onStep' with 'onFrame', otherwise it works the same.
36 lines
717 B
Plaintext
36 lines
717 B
Plaintext
|
|
var counter = 0;
|
|
var randi: Int = 69420;
|
|
fn rand() {
|
|
return randi = randi * 1664525 + 1013904223; //can be negative
|
|
}
|
|
|
|
fn wander(actor: Opaque) {
|
|
actor.setX(actor.x + rand() % 5);
|
|
actor.setY(actor.y + rand() % 5);
|
|
|
|
counter++;
|
|
}
|
|
|
|
//when the game is ready, load the "zombie" sprite
|
|
fn onReady() {
|
|
loadSprite("zombie", "assets/parvati.png", 32, 32);
|
|
|
|
//spawn some "zombies" looking for brains
|
|
spawnActorAt("zombie", wander, 250, 250);
|
|
spawnActorAt("zombie", wander, 250, 500);
|
|
spawnActorAt("zombie", wander, 500, 250);
|
|
spawnActorAt("zombie", wander, 500, 500);
|
|
}
|
|
|
|
fn onFrame() {
|
|
//debug
|
|
print counter;
|
|
}
|
|
|
|
//example API for the game
|
|
initScreen(1280, 720, "Oh no, Zombies!");
|
|
initLoop(onReady, null, null);
|
|
|
|
|