summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/Horde.cc
Unidiff
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 @@
1#include "objects.h"
2
3void Horde::setup() {
4 for (int i=0; i < MAX_BILLS; i++)
5 list[i].state = list[i].OFF;
6 off_screen = on (game.level);
7 on_screen = 0;
8}
9
10/* Launches Bills whenever called */
11void Horde::launch(int max){
12 int i, n;
13 if (!max || !off_screen) return;
14 n=game.RAND(1, game.MIN(max, off_screen));
15 for (i=0; n; n--) {
16 for (i++; i < MAX_BILLS; i++)
17 if (list[i].state == list[i].OFF) break;
18 if (i == MAX_BILLS) return;
19 list[i++].enter();
20 }
21}
22
23int Horde::on (unsigned int lev) {
24 return game.MIN(8+3*lev, MAX_BILLS);
25}
26
27int Horde::max_at_once (unsigned int lev) {
28 return game.MIN(2+lev/4, 12);
29}
30
31int Horde::between (unsigned int lev) {
32 return game.MAX(14-lev/3, 10);
33}
34
35void Horde::load_pix () {
36 int i;
37 for (i=0; i < WCELS-1; i++) {
38 lcels[i].load("billL", i);
39 rcels[i].load("billR", i);
40 }
41 lcels[WCELS-1] = lcels[1];
42 rcels[WCELS-1] = rcels[1];
43
44 for (i=0; i < DCELS; i++)
45 dcels[i].load("billD", i);
46 width=dcels[0].width;
47 height=dcels[0].height;
48
49 for (i=0; i < ACELS; i++)
50 acels[i].load("billA", i);
51}
52
53void Horde::update() {
54 int i;
55 if (!(game.iteration % between(game.level)))
56 launch(max_at_once(game.level));
57 for (i=0; i < MAX_BILLS; i++) list[i].update();
58}
59
60void Horde::draw() {
61 int i;
62 for (i=0; i < MAX_BILLS; i++) list[i].draw();
63}
64