From bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57 Mon Sep 17 00:00:00 2001 From: mark Date: Sun, 14 Apr 2002 17:08:03 +0000 Subject: Import of kbill --- (limited to 'noncore/games/kbill/Horde.cc') diff --git a/noncore/games/kbill/Horde.cc b/noncore/games/kbill/Horde.cc new file mode 100644 index 0000000..d908037 --- a/dev/null +++ b/noncore/games/kbill/Horde.cc @@ -0,0 +1,64 @@ +#include "objects.h" + +void Horde::setup() { + for (int i=0; i < MAX_BILLS; i++) + list[i].state = list[i].OFF; + off_screen = on (game.level); + on_screen = 0; +} + +/* Launches Bills whenever called */ +void Horde::launch(int max){ + int i, n; + if (!max || !off_screen) return; + n=game.RAND(1, game.MIN(max, off_screen)); + for (i=0; n; n--) { + for (i++; i < MAX_BILLS; i++) + if (list[i].state == list[i].OFF) break; + if (i == MAX_BILLS) return; + list[i++].enter(); + } +} + +int Horde::on (unsigned int lev) { + return game.MIN(8+3*lev, MAX_BILLS); +} + +int Horde::max_at_once (unsigned int lev) { + return game.MIN(2+lev/4, 12); +} + +int Horde::between (unsigned int lev) { + return game.MAX(14-lev/3, 10); +} + +void Horde::load_pix () { + int i; + for (i=0; i < WCELS-1; i++) { + lcels[i].load("billL", i); + rcels[i].load("billR", i); + } + lcels[WCELS-1] = lcels[1]; + rcels[WCELS-1] = rcels[1]; + + for (i=0; i < DCELS; i++) + dcels[i].load("billD", i); + width=dcels[0].width; + height=dcels[0].height; + + for (i=0; i < ACELS; i++) + acels[i].load("billA", i); +} + +void Horde::update() { + int i; + if (!(game.iteration % between(game.level))) + launch(max_at_once(game.level)); + for (i=0; i < MAX_BILLS; i++) list[i].update(); +} + +void Horde::draw() { + int i; + for (i=0; i < MAX_BILLS; i++) list[i].draw(); +} + -- cgit v0.9.0.2