summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/Horde.cc
authormark <mark>2002-04-14 17:08:03 (UTC)
committer mark <mark>2002-04-14 17:08:03 (UTC)
commitbfeb067c8acfb5f1797fdc886ac71ca1b10ccf57 (patch) (side-by-side diff)
treead77e90c90f4bfb598bbe93aa4b3e14b689c96f4 /noncore/games/kbill/Horde.cc
parenta0fe593db4e700989cc19e28b67a58f87823afeb (diff)
downloadopie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.zip
opie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.tar.gz
opie-bfeb067c8acfb5f1797fdc886ac71ca1b10ccf57.tar.bz2
Import of kbill
Diffstat (limited to 'noncore/games/kbill/Horde.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/Horde.cc64
1 files changed, 64 insertions, 0 deletions
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();
+}
+