Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Horde.cc

Go to the documentation of this file.
00001 #include "objects.h"
00002 
00003 void Horde::setup() {
00004         for (int i=0; i < MAX_BILLS; i++)
00005                 list[i].state = list[i].OFF;
00006         off_screen = on (game.level);
00007         on_screen = 0;
00008 }
00009 
00010 /*  Launches Bills whenever called  */
00011 void Horde::launch(int max){
00012         int i, n;
00013         if (!max || !off_screen) return;
00014         n=game.RAND(1, game.MIN(max, off_screen));
00015         for (i=0; n; n--) {
00016                 for (i++; i < MAX_BILLS; i++)
00017                         if (list[i].state == list[i].OFF) break;
00018                 if (i == MAX_BILLS) return;
00019                 list[i++].enter();
00020         }
00021 }
00022 
00023 int Horde::on (unsigned int lev) {
00024         return game.MIN(8+3*lev, MAX_BILLS);
00025 }
00026 
00027 int Horde::max_at_once (unsigned int lev) {
00028         return game.MIN(2+lev/4, 12);
00029 }
00030 
00031 int Horde::between (unsigned int lev) {
00032         return game.MAX(14-lev/3, 10);
00033 }
00034 
00035 void Horde::load_pix () {
00036         int i;
00037         for (i=0; i < WCELS-1; i++) {
00038                 lcels[i].load("billL", i);
00039                 rcels[i].load("billR", i);
00040         }
00041         lcels[WCELS-1] = lcels[1]; 
00042         rcels[WCELS-1] = rcels[1]; 
00043 
00044         for (i=0; i < DCELS; i++) 
00045                 dcels[i].load("billD", i);
00046         width=dcels[0].width;
00047         height=dcels[0].height;
00048 
00049         for (i=0; i < ACELS; i++)
00050                 acels[i].load("billA", i);
00051 }
00052 
00053 void Horde::update() {
00054         int i;
00055         if (!(game.iteration % between(game.level)))
00056                 launch(max_at_once(game.level));
00057         for (i=0; i < MAX_BILLS; i++) list[i].update();
00058 }
00059 
00060 void Horde::draw() {
00061         int i;
00062         for (i=0; i < MAX_BILLS; i++) list[i].draw();
00063 }
00064 

Generated on Sat Nov 5 16:17:19 2005 for OPIE by  doxygen 1.4.2