-rw-r--r-- | noncore/games/kbill/Game.cc | 14 |
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 | |||
@@ -49,39 +49,39 @@ void Game::quit() { | |||
49 | 49 | ||
50 | exit(0); | 50 | exit(0); |
51 | } | 51 | } |
52 | 52 | ||
53 | void Game::update_info() { | 53 | void Game::update_info() { |
54 | static char str[80]; | 54 | static char str[80]; |
55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", | 55 | sprintf (str, "Bill:%d/%d System:%d/%d/%d Level:%d Score:%d", |
56 | bill.on_screen, bill.off_screen, net.base, net.off, | 56 | bill.on_screen, bill.off_screen, net.base, net.off, |
57 | net.win, level, score); | 57 | net.win, level, score); |
58 | ui.draw_str(str, 5, scrheight-5); | 58 | ui.draw_str(str, 5, scrheight-5); |
59 | efficiency += ((100*net.base-10*net.win)/net.units); | 59 | efficiency += ((100*net.base-10*net.win)/net.units); |
60 | } | 60 | } |
61 | 61 | ||
62 | void Game::update_score (int action) { | 62 | void Game::update_score (int action) { |
63 | switch (action){ | 63 | switch (action){ |
64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; | 64 | case ENDLEVEL: score+=(level*efficiency/iteration); break; |
65 | default: score+=(action*action*BILLPOINTS); | 65 | default: score+=(action*action*BILLPOINTS); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | 68 | ||
69 | void Game::warp_to_level (unsigned int lev) { | 69 | void Game::warp_to_level (unsigned int lev) { |
70 | if (state==PLAYING) { | 70 | if (state==PLAYING) { |
71 | if (lev <= level) return; | 71 | if (lev <= level) return; |
72 | setup_level(lev); | 72 | setup_level(lev); |
73 | } | 73 | } |
74 | else { | 74 | else { |
75 | if (lev<=0) return; | 75 | if (lev <=0) return; |
76 | start(lev); | 76 | start(lev); |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | void Game::button_press(int x, int y) { | 80 | void Game::button_press(int x, int y) { |
81 | int i, counter=0, flag=0; | 81 | int i, counter=0, flag=0; |
82 | if (state != PLAYING) return; | 82 | if (state != PLAYING) return; |
83 | ui.set_cursor(DOWNC); | 83 | ui.set_cursor(DOWNC); |
84 | if (bucket.clicked(x, y)) { | 84 | if (bucket.clicked(x, y)) { |
85 | ui.set_cursor(BUCKETC); | 85 | ui.set_cursor(BUCKETC); |
86 | grabbed = BUCKET; | 86 | grabbed = BUCKET; |
87 | } | 87 | } |
@@ -90,25 +90,25 @@ void Game::button_press(int x, int y) { | |||
90 | || bill.list[i].state == bill.list[i].DYING) | 90 | || bill.list[i].state == bill.list[i].DYING) |
91 | continue; | 91 | continue; |
92 | if (bill.list[i].state == bill.list[i].STRAY && | 92 | if (bill.list[i].state == bill.list[i].STRAY && |
93 | bill.list[i].clickedstray(x, y)) | 93 | bill.list[i].clickedstray(x, y)) |
94 | { | 94 | { |
95 | ui.set_cursor (bill.list[i].cargo); | 95 | ui.set_cursor (bill.list[i].cargo); |
96 | grabbed = i; | 96 | grabbed = i; |
97 | flag = 1; | 97 | flag = 1; |
98 | } | 98 | } |
99 | else if (bill.list[i].state != bill.list[i].STRAY && | 99 | else if (bill.list[i].state != bill.list[i].STRAY && |
100 | bill.list[i].clicked(x, y)) | 100 | bill.list[i].clicked(x, y)) |
101 | { | 101 | { |
102 | if (bill.list[i].state == bill.list[i].AT) | 102 | if (bill.list[i].state == bill.list[i].AT) |
103 | net.computers[bill.list[i].target_c].busy=0; | 103 | net.computers[bill.list[i].target_c].busy=0; |
104 | bill.list[i].index = -1; | 104 | bill.list[i].index = -1; |
105 | bill.list[i].cels = bill.dcels; | 105 | bill.list[i].cels = bill.dcels; |
106 | bill.list[i].x_offset = -2; | 106 | bill.list[i].x_offset = -2; |
107 | bill.list[i].y_offset = -15; | 107 | bill.list[i].y_offset = -15; |
108 | bill.list[i].state = bill.list[i].DYING; | 108 | bill.list[i].state = bill.list[i].DYING; |
109 | counter++; | 109 | counter++; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | if (counter) update_score(counter); | 112 | if (counter) update_score(counter); |
113 | } | 113 | } |
114 | 114 | ||
@@ -122,44 +122,44 @@ void Game::button_release(int x, int y) { | |||
122 | for (i=0; i<net.ncables; i++) | 122 | for (i=0; i<net.ncables; i++) |
123 | if (net.cables[i].onspark(x, y)) { | 123 | if (net.cables[i].onspark(x, y)) { |
124 | net.cables[i].active=0; | 124 | net.cables[i].active=0; |
125 | net.cables[i].delay = spark.delay(level); | 125 | net.cables[i].delay = spark.delay(level); |
126 | } | 126 | } |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | for (i=0; i<net.units; i++) | 129 | for (i=0; i<net.units; i++) |
130 | if (net.computers[i].oncomputer(x, y) | 130 | if (net.computers[i].oncomputer(x, y) |
131 | && | 131 | && |
132 | net.computers[i].compatible (bill.list[grabbed].cargo) | 132 | net.computers[i].compatible (bill.list[grabbed].cargo) |
133 | && | 133 | && |
134 | (net.computers[i].os == OS.WINGDOWS || | 134 | (net.computers[i].os == OS.WINGDOWS || |
135 | net.computers[i].os == OS.OFF)) | 135 | net.computers[i].os == OS.OFF)) |
136 | { | 136 | { |
137 | net.base++; | 137 | net.base++; |
138 | if (net.computers[i].os == OS.WINGDOWS) | 138 | if (net.computers[i].os == OS.WINGDOWS) |
139 | net.win--; | 139 | net.win--; |
140 | else | 140 | else |
141 | net.off--; | 141 | net.off--; |
142 | net.computers[i].os = bill.list[grabbed].cargo; | 142 | net.computers[i].os = bill.list[grabbed].cargo; |
143 | bill.list[grabbed].state = bill.list[grabbed].OFF; | 143 | bill.list[grabbed].state = bill.list[grabbed].OFF; |
144 | grabbed = EMPTY; | 144 | grabbed = EMPTY; |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | grabbed = EMPTY; | 147 | grabbed = EMPTY; |
148 | } | 148 | } |
149 | 149 | ||
150 | void Game::update() { | 150 | void Game::update() { |
151 | switch (state) { | 151 | switch (state) { |
152 | case PLAYING: | 152 | case PLAYING: |
153 | ui.clear(); | 153 | ui.clear(); |
154 | bucket.draw(); | 154 | bucket.draw(); |
155 | net.update(); | 155 | net.update(); |
156 | net.draw(); | 156 | net.draw(); |
157 | bill.update(); | 157 | bill.update(); |
158 | bill.draw(); | 158 | bill.draw(); |
159 | update_info(); | 159 | update_info(); |
160 | if (!(bill.on_screen+bill.off_screen)) { | 160 | if (!(bill.on_screen+bill.off_screen)) { |
161 | update_score(ENDLEVEL); | 161 | update_score(ENDLEVEL); |
162 | state = BETWEEN; | 162 | state = BETWEEN; |
163 | } | 163 | } |
164 | if ((net.base+net.off)<=1) state = END; | 164 | if ((net.base+net.off)<=1) state = END; |
165 | break; | 165 | break; |