~ubuntu-branches/ubuntu/feisty/xbill/feisty

« back to all changes in this revision

Viewing changes to Horde.cc

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Bridgett
  • Date: 2004-09-07 09:52:14 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040907095214-d0m46ojc8f7upuqm
Tags: 2.1-4
maintainer upload of NMU - many thanks Tollef (closes: #268885) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "objects.h"
2
 
 
3
 
void 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  */
11
 
void 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
 
 
23
 
int Horde::on (unsigned int lev) {
24
 
        return game.MIN(8+3*lev, MAX_BILLS);
25
 
}
26
 
 
27
 
int Horde::max_at_once (unsigned int lev) {
28
 
        return game.MIN(2+lev/4, 12);
29
 
}
30
 
 
31
 
int Horde::between (unsigned int lev) {
32
 
        return game.MAX(14-lev/3, 10);
33
 
}
34
 
 
35
 
void 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
 
 
53
 
void 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
 
 
60
 
void Horde::draw() {
61
 
        int i;
62
 
        for (i=0; i < MAX_BILLS; i++) list[i].draw();
63
 
}
64