summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/Game.cc
Side-by-side diff
Diffstat (limited to 'noncore/games/kbill/Game.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/Game.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/games/kbill/Game.cc b/noncore/games/kbill/Game.cc
index 624b50b..4cd5322 100644
--- a/noncore/games/kbill/Game.cc
+++ b/noncore/games/kbill/Game.cc
@@ -37,141 +37,141 @@ void Game::setup_level (unsigned int lev) {
iteration = efficiency = 0;
}
void Game::start(unsigned int lev) {
state = PLAYING;
score = 0;
ui.restart_timer();
ui.set_pausebutton(true);
setup_level(lev);
}
void Game::quit() {
exit(0);
}
void Game::update_info() {
static char str[80];
sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d",
bill.on_screen, bill.off_screen, net.base, net.off,
net.win, level, score);
ui.draw_str(str, 5, scrheight-5);
efficiency += ((100*net.base-10*net.win)/net.units);
}
-
+
void Game::update_score (int action) {
switch (action){
case ENDLEVEL: score+=(level*efficiency/iteration); break;
default: score+=(action*action*BILLPOINTS);
}
}
void Game::warp_to_level (unsigned int lev) {
if (state==PLAYING) {
if (lev <= level) return;
setup_level(lev);
}
else {
- if (lev<=0) return;
+ if (lev <=0) return;
start(lev);
}
}
void Game::button_press(int x, int y) {
int i, counter=0, flag=0;
if (state != PLAYING) return;
ui.set_cursor(DOWNC);
if (bucket.clicked(x, y)) {
ui.set_cursor(BUCKETC);
grabbed = BUCKET;
}
for (i=0; i < bill.MAX_BILLS && !flag; i++) {
if (bill.list[i].state == bill.list[i].OFF
|| bill.list[i].state == bill.list[i].DYING)
continue;
if (bill.list[i].state == bill.list[i].STRAY &&
bill.list[i].clickedstray(x, y))
{
ui.set_cursor (bill.list[i].cargo);
grabbed = i;
flag = 1;
}
else if (bill.list[i].state != bill.list[i].STRAY &&
bill.list[i].clicked(x, y))
{
- if (bill.list[i].state == bill.list[i].AT)
+ if (bill.list[i].state == bill.list[i].AT)
net.computers[bill.list[i].target_c].busy=0;
bill.list[i].index = -1;
bill.list[i].cels = bill.dcels;
bill.list[i].x_offset = -2;
bill.list[i].y_offset = -15;
bill.list[i].state = bill.list[i].DYING;
counter++;
}
}
if (counter) update_score(counter);
}
void Game::button_release(int x, int y) {
int i;
ui.set_cursor (DEFAULTC);
if (state != PLAYING || grabbed == EMPTY)
return;
if (grabbed == BUCKET) {
grabbed = EMPTY;
for (i=0; i<net.ncables; i++)
if (net.cables[i].onspark(x, y)) {
net.cables[i].active=0;
net.cables[i].delay = spark.delay(level);
}
return;
}
for (i=0; i<net.units; i++)
if (net.computers[i].oncomputer(x, y)
&&
net.computers[i].compatible (bill.list[grabbed].cargo)
&&
- (net.computers[i].os == OS.WINGDOWS ||
+ (net.computers[i].os == OS.WINGDOWS ||
net.computers[i].os == OS.OFF))
{
- net.base++;
+ net.base++;
if (net.computers[i].os == OS.WINGDOWS)
net.win--;
else
net.off--;
net.computers[i].os = bill.list[grabbed].cargo;
bill.list[grabbed].state = bill.list[grabbed].OFF;
grabbed = EMPTY;
return;
}
grabbed = EMPTY;
-}
+}
void Game::update() {
switch (state) {
case PLAYING:
- ui.clear();
+ ui.clear();
bucket.draw();
net.update();
net.draw();
bill.update();
bill.draw();
update_info();
if (!(bill.on_screen+bill.off_screen)) {
update_score(ENDLEVEL);
state = BETWEEN;
}
if ((net.base+net.off)<=1) state = END;
break;
case END:
ui.clear();
net.toasters();
net.draw();
ui.refresh();
ui.popup_dialog(ENDGAME);
/* if (score > scores.score[9]) ui.popup_dialog(ENTERNAME);
scores.update();*/
ui.popup_dialog(HIGHSCORE);
ui.clear();
ui.draw_centered(logo);
ui.kill_timer();