| 1 | |
| 2 | /** |
| 3 | * |
| 4 | * @file jj1levelframe.cpp |
| 5 | * |
| 6 | * Part of the OpenJazz project |
| 7 | * |
| 8 | * @par History: |
| 9 | * - 23rd August 2005: Created level.c |
| 10 | * - 3rd February 2009: Renamed level.c to level.cpp |
| 11 | * - 19th July 2009: Created levelframe.cpp from parts of level.cpp |
| 12 | * - 30th March 2010: Created baselevel.cpp from parts of level.cpp and |
| 13 | * levelframe.cpp |
| 14 | * - 29th June 2010: Created jj2levelframe.cpp from parts of levelframe.cpp |
| 15 | * - 1st August 2012: Renamed levelframe.cpp to jj1levelframe.cpp |
| 16 | * |
| 17 | * @par Licence: |
| 18 | * Copyright (c) 2005-2013 AJ Thomson |
| 19 | * |
| 20 | * OpenJazz is distributed under the terms of |
| 21 | * the GNU General Public License, version 2.0 |
| 22 | * |
| 23 | * @par Description: |
| 24 | * Provides the once-per-frame functions for levels. |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #include "jj1bullet.h"cxx . . $ `<file>/src/jj1/level/jj1bullet.h`/ |
| 30 | #include "event/jj1event.h"cxx . . $ `<file>/src/jj1/level/event/jj1event.h`/ |
| 31 | #include "event/jj1guardians.h"cxx . . $ `<file>/src/jj1/level/event/jj1guardians.h`/ |
| 32 | #include "jj1level.h"cxx . . $ `<file>/src/jj1/level/jj1level.h`/ |
| 33 | #include "jj1levelplayer.h"cxx . . $ `<file>/src/jj1/level/jj1levelplayer.h`/ |
| 34 | |
| 35 | #include "game/game.h"cxx . . $ `<file>/src/game/game.h`/ |
| 36 | #include "game/gamemode.h"cxx . . $ `<file>/src/game/gamemode.h`/ |
| 37 | #include "io/controls.h"cxx . . $ `<file>/src/io/controls.h`/ |
| 38 | #include "io/gfx/font.h"cxx . . $ `<file>/src/io/gfx/font.h`/ |
| 39 | #include "io/gfx/video.h"cxx . . $ `<file>/src/io/gfx/video.h`/ |
| 40 | #include "util.h"cxx . . $ `<file>/src/util.h`/ |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * Level iteration. |
| 45 | * |
| 46 | * @return Error code |
| 47 | */ |
| 48 | int JJ1Levelcxx . . $ JJ1Level#::stepcxx . . $ JJ1Level#step(b126dc7c1de90089). () { |
| 49 | |
| 50 | JJ1Eventcxx . . $ JJ1Event# *event; |
| 51 | int viewH = canvasHcxx . . $ canvasH.; |
| 52 | int x, y; |
| 53 | |
| 54 | if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::Classiccxx . . $ hudType#Classic.) { |
| 55 | // Can we see below the panel? |
| 56 | if (canvasWcxx . . $ canvasW. > SWcxx . . $ `src/io/gfx/video.h:38:9`!) viewH = canvasHcxx . . $ canvasH.; |
| 57 | else viewH = canvasHcxx . . $ canvasH. - 33; |
| 58 | } else if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::FPScxx . . $ hudType#FPS.) { |
| 59 | // Leave space for panel in view height |
| 60 | viewH = canvasHcxx . . $ canvasH. - 33; |
| 61 | } |
| 62 | |
| 63 | // Search for active events |
| 64 | for (y = FTOTcxx . . $ `src/level/level.h:37:9`!(viewY) - 5; y < ITOTcxx . . $ `src/level/level.h:39:9`!(FTOIcxx . . $ `src/types.h:52:9`!(viewY) + viewH) + 5; y++) { |
| 65 | |
| 66 | for (x = FTOTcxx . . $ `src/level/level.h:37:9`!(viewX) - 5; x < ITOTcxx . . $ `src/level/level.h:39:9`!(FTOIcxx . . $ `src/types.h:52:9`!(viewX) + canvasW) + 5; x++) { |
| 67 | |
| 68 | if ((x >= 0) && (y >= 0) && (x < LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!) && (y < LHcxx . . $ `src/jj1/level/jj1level.h:44:9`!) && |
| 69 | gridcxx . . $ JJ1Level#grid.[y][x].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. && (gridcxx . . $ JJ1Level#grid.[y][x].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. < 121) && |
| 70 | (+cxx . . $ operator+(19ccb40277a922df).eventSetcxx . . $ JJ1Level#eventSet.[gridcxx . . $ JJ1Level#grid.[y][x].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].difficultycxx . . $ $anonymous_type_e8f9ae77bbb68925_1#difficulty. <= +cxx . . $ operator+(19ccb40277a922df).getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).())) { |
| 71 | |
| 72 | event = eventscxx . . $ JJ1Level#events.; |
| 73 | |
| 74 | while (event) { |
| 75 | |
| 76 | // If the event has been found, stop searching |
| 77 | if (event->isFromcxx . . $ JJ1Event#isFrom(4ed805b44025c28a).(x, y)) break; |
| 78 | |
| 79 | event = event->getNextcxx . . $ JJ1Event#getNext(31caec775bb17100).(); |
| 80 | |
| 81 | } |
| 82 | |
| 83 | // If the event wasn't found, create it |
| 84 | if (!event) { |
| 85 | |
| 86 | switch (getEventcxx . . $ JJ1Level#getEvent(4d9fc4215ff36191).(x, y)->movementcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#movement.) { |
| 87 | |
| 88 | case 28: |
| 89 | |
| 90 | eventscxx . . $ JJ1Level#events. = new JJ1Bridgecxx . . $ JJ1Bridge#(x, y); |
| 91 | |
| 92 | break; |
| 93 | |
| 94 | case 41: |
| 95 | |
| 96 | eventscxx . . $ JJ1Level#events. = new MedGuardiancxx . . $ MedGuardian#(x, y); |
| 97 | |
| 98 | break; |
| 99 | |
| 100 | case 60: |
| 101 | |
| 102 | eventscxx . . $ JJ1Level#events. = new DeckGuardiancxx . . $ DeckGuardian#(x, y); |
| 103 | |
| 104 | break; |
| 105 | |
| 106 | default: |
| 107 | |
| 108 | eventscxx . . $ JJ1Level#events. = new JJ1StandardEventcxx . . $ JJ1StandardEvent#(eventSetcxx . . $ JJ1Level#eventSet. + gridcxx . . $ JJ1Level#grid.[y][x].eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event., x, y, TTOFcxx . . $ `src/level/level.h:38:9`!(x), TTOFcxx . . $ `src/level/level.h:38:9`!(y + 1)); |
| 109 | |
| 110 | break; |
| 111 | |
| 112 | } |
| 113 | |
| 114 | } |
| 115 | |
| 116 | } |
| 117 | |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | |
| 122 | |
| 123 | // Process bullets |
| 124 | if (bulletscxx . . $ JJ1Level#bullets.) bulletscxx . . $ JJ1Level#bullets. = bulletscxx . . $ JJ1Level#bullets.->stepcxx . . $ JJ1Bullet#step(c90693087d4d5c05).(tickscxx . . $ Level#ticks.); |
| 125 | |
| 126 | // Determine the players' trajectories |
| 127 | for (x = 0; x < nPlayerscxx . . $ nPlayers.; x++) playerscxx . . $ players.[x].getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->controlcxx . . $ JJ1LevelPlayer#control(cb2f890c2fdad230).(tickscxx . . $ Level#ticks.); |
| 128 | |
| 129 | // Process active events |
| 130 | if (eventscxx . . $ JJ1Level#events.) eventscxx . . $ JJ1Level#events. = eventscxx . . $ JJ1Level#events.->stepcxx . . $ JJ1Event#step(96f3a021ae50222d).(tickscxx . . $ Level#ticks.); |
| 131 | |
| 132 | // Apply as much of those trajectories as possible, without going into the |
| 133 | // scenery |
| 134 | for (x = 0; x < nPlayerscxx . . $ nPlayers.; x++) playerscxx . . $ players.[x].getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->movecxx . . $ JJ1LevelPlayer#move(cb2f890c2fdad230).(tickscxx . . $ Level#ticks.); |
| 135 | |
| 136 | |
| 137 | // Check if time has run out |
| 138 | if (tickscxx . . $ Level#ticks. > endTimecxx . . $ Level#endTime.) { |
| 139 | |
| 140 | if (multiplayercxx . . $ Level#multiplayer.) { |
| 141 | |
| 142 | gamecxx . . $ Level#game.->getModecxx . . $ Game#getMode(b2ac8a9286443acb).()->outOfTimecxx . . $ GameMode#outOfTime(49f6e7a06ebc5aa8).(); |
| 143 | |
| 144 | } else { |
| 145 | |
| 146 | if ((getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).() == difficultyTypecxx . . $ difficultyType#::Hardcxx . . $ difficultyType#Hard. || |
| 147 | getDifficultycxx . . $ JJ1Level#getDifficulty(601dbc13202031c0).() == difficultyTypecxx . . $ difficultyType#::Turbocxx . . $ difficultyType#Turbo.) |
| 148 | && (stagecxx . . $ Level#stage. == LS_NORMALcxx . . $ LS_NORMAL.)) |
| 149 | localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->killcxx . . $ JJ1LevelPlayer#kill(43305d5aaa6271c0).(nullptr, endTimecxx . . $ Level#endTime.); |
| 150 | |
| 151 | } |
| 152 | |
| 153 | } |
| 154 | |
| 155 | |
| 156 | // Handle change in ammo selection |
| 157 | |
| 158 | x = localPlayercxx . . $ localPlayer.->getAmmoTypecxx . . $ Player#getAmmoType(b126dc7c1de90089).() + 1; |
| 159 | |
| 160 | if (x != ammoTypecxx . . $ JJ1Level#ammoType.) { |
| 161 | |
| 162 | // Change the ammo type display on the panel |
| 163 | ammoTypecxx . . $ JJ1Level#ammoType. = x; |
| 164 | ammoOffsetcxx . . $ JJ1Level#ammoOffset. = ITOFcxx . . $ `src/types.h:53:9`!(26); |
| 165 | |
| 166 | } |
| 167 | |
| 168 | if (ammoOffsetcxx . . $ JJ1Level#ammoOffset. > 0) { |
| 169 | |
| 170 | // Descending |
| 171 | ammoOffsetcxx . . $ JJ1Level#ammoOffset. -= F1cxx . . $ `src/types.h:31:9`!; |
| 172 | |
| 173 | // Avoid an offset of 0, which prevents changes |
| 174 | if (ammoOffsetcxx . . $ JJ1Level#ammoOffset. == 0) ammoOffsetcxx . . $ JJ1Level#ammoOffset. = -1; |
| 175 | |
| 176 | } |
| 177 | |
| 178 | |
| 179 | // Handle change in water level |
| 180 | if (waterLevelcxx . . $ JJ1Level#waterLevel. < waterLevelTargetcxx . . $ JJ1Level#waterLevelTarget.) waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. += 3200; |
| 181 | else waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. -= 3200; |
| 182 | if (waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. > 80000) waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. = 80000; |
| 183 | if (waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. < -80000) waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. = -80000; |
| 184 | |
| 185 | waterLevelcxx . . $ JJ1Level#waterLevel. += waterLevelSpeedcxx . . $ JJ1Level#waterLevelSpeed. >> 6; |
| 186 | |
| 187 | |
| 188 | // Handle player reactions |
| 189 | for (x = 0; x < nPlayerscxx . . $ nPlayers.; x++) { |
| 190 | |
| 191 | if (playerscxx . . $ players.[x].getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->reactedcxx . . $ JJ1LevelPlayer#reacted(c1136c0fafdb757a).(tickscxx . . $ Level#ticks.) == PR_KILLEDcxx . . $ PR_KILLED.) { |
| 192 | |
| 193 | playerscxx . . $ players.[x].clearAmmocxx . . $ Player#clearAmmo(49f6e7a06ebc5aa8).(); |
| 194 | |
| 195 | if (!multiplayercxx . . $ Level#multiplayer.) return LOSTcxx . . $ `src/level/level.h:47:9`!; |
| 196 | |
| 197 | gamecxx . . $ Level#game.->resetPlayercxx . . $ Game#resetPlayer(34e2c302b1f0e5dd).(playerscxx . . $ players. + x); |
| 198 | |
| 199 | } |
| 200 | |
| 201 | } |
| 202 | |
| 203 | |
| 204 | return E_NONEcxx . . $ `src/OpenJazz.h:69:9`!; |
| 205 | |
| 206 | } |
| 207 | |
| 208 | |
| 209 | |
| 210 | /** |
| 211 | * Draw the level. |
| 212 | */ |
| 213 | void JJ1Levelcxx . . $ JJ1Level#::drawcxx . . $ JJ1Level#draw(49f6e7a06ebc5aa8). () { |
| 214 | |
| 215 | GridElementcxx . . $ GridElement# *ge; |
| 216 | SDL_Rect src, dst; |
| 217 | int viewH = canvasHcxx . . $ canvasH.; |
| 218 | int vX, vY; |
| 219 | int x, y; |
| 220 | unsigned int change; |
| 221 | |
| 222 | |
| 223 | // Calculate change since last step |
| 224 | change = getTimeChangecxx . . $ Level#getTimeChange(b126dc7c1de90089).(); |
| 225 | |
| 226 | |
| 227 | // Calculate viewport |
| 228 | if (gamecxx . . $ Level#game. && (stagecxx . . $ Level#stage. == LS_ENDcxx . . $ LS_END.)) gamecxx . . $ Level#game.->viewcxx . . $ Game#view(d4f767463ce0a6b3).(pausedcxx . . $ Level#paused.? 0: ((tickscxx . . $ Level#ticks. - prevTickscxx . . $ Level#prevTicks.) * 160)); |
| 229 | else localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->viewcxx . . $ JJ1LevelPlayer#view(8c880916ccadf15d).(tickscxx . . $ Level#ticks., pausedcxx . . $ Level#paused.? 0: (tickscxx . . $ Level#ticks. - prevTickscxx . . $ Level#prevTicks.), change); |
| 230 | |
| 231 | if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::Classiccxx . . $ hudType#Classic.) { |
| 232 | // Can we see below the panel? |
| 233 | if (canvasWcxx . . $ canvasW. > SWcxx . . $ `src/io/gfx/video.h:38:9`!) viewH = canvasHcxx . . $ canvasH.; |
| 234 | else viewH = canvasHcxx . . $ canvasH. - 33; |
| 235 | } else if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::FPScxx . . $ hudType#FPS.) { |
| 236 | // Leave space for panel in view height |
| 237 | viewH = canvasHcxx . . $ canvasH. - 33; |
| 238 | } |
| 239 | |
| 240 | // Ensure the new viewport is within the level |
| 241 | if (FTOIcxx . . $ `src/types.h:52:9`!(viewX) + canvasWcxx . . $ canvasW. >= TTOIcxx . . $ `src/level/level.h:40:9`!(LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!)) viewXcxx . . $ viewX. = ITOFcxx . . $ `src/types.h:53:9`!(TTOIcxx . . $ `src/level/level.h:40:9`!(LWcxx . . $ `src/jj1/level/jj1level.h:43:9`!) - canvasW); |
| 242 | if (viewXcxx . . $ viewX. < 0) viewXcxx . . $ viewX. = 0; |
| 243 | if (FTOIcxx . . $ `src/types.h:52:9`!(viewY) + viewH >= TTOIcxx . . $ `src/level/level.h:40:9`!(LHcxx . . $ `src/jj1/level/jj1level.h:44:9`!)) viewYcxx . . $ viewY. = ITOFcxx . . $ `src/types.h:53:9`!(TTOIcxx . . $ `src/level/level.h:40:9`!(LHcxx . . $ `src/jj1/level/jj1level.h:44:9`!) - viewH); |
| 244 | if (viewYcxx . . $ viewY. < 0) viewYcxx . . $ viewY. = 0; |
| 245 | |
| 246 | // Use the viewport |
| 247 | dst.x = 0; |
| 248 | dst.y = 0; |
| 249 | vX = FTOIcxx . . $ `src/types.h:52:9`!(viewX); |
| 250 | vY = FTOIcxx . . $ `src/types.h:52:9`!(viewY); |
| 251 | dst.w = canvasWcxx . . $ canvasW.; |
| 252 | dst.h = viewH; |
| 253 | videocxx . . $ video..setClipRectcxx . . $ Video#setClipRect(382a02f39687f508).(canvascxx . . $ canvas., &dst); |
| 254 | |
| 255 | |
| 256 | // Set tile drawing dimensions |
| 257 | src.w = TTOIcxx . . $ `src/level/level.h:40:9`!(1); |
| 258 | src.h = TTOIcxx . . $ `src/level/level.h:40:9`!(1); |
| 259 | src.x = 0; |
| 260 | |
| 261 | |
| 262 | // If there is a sky, draw it |
| 263 | if (skycxx . . $ JJ1Level#sky.) { |
| 264 | |
| 265 | // Background scale |
| 266 | int bgScale; |
| 267 | if (canvasWcxx . . $ canvasW. > SWcxx . . $ `src/io/gfx/video.h:38:9`!) bgScale = ((canvasHcxx . . $ canvasH. - 1) / 100) + 1; |
| 268 | else bgScale = ((canvasHcxx . . $ canvasH. - 34) / 100) + 1; |
| 269 | |
| 270 | for (y = 0; y < viewH; y += bgScale) |
| 271 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, y, canvasWcxx . . $ canvasW., bgScale, 156 + (y / bgScale)); |
| 272 | |
| 273 | |
| 274 | // Show sun / moon / etc. |
| 275 | if (skyOrbcxx . . $ JJ1Level#skyOrb.) { |
| 276 | |
| 277 | dst.x = ((canvasWcxx . . $ canvasW. * 4) / 5) - (vX & 3); |
| 278 | dst.y = ((canvasHcxx . . $ canvasH. - 33) * 3) / 25; |
| 279 | src.y = TTOIcxx . . $ `src/level/level.h:40:9`!(skyOrb + (vX & 3)); |
| 280 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(tileSetcxx . . $ JJ1Level#tileSet., &src, canvascxx . . $ canvas., &dst); |
| 281 | |
| 282 | } |
| 283 | |
| 284 | } else { |
| 285 | |
| 286 | // If there is no sky, draw a blank background |
| 287 | // This is only very occasionally actually visible |
| 288 | videocxx . . $ video..clearScreencxx . . $ Video#clearScreen(d4f767463ce0a6b3).(127); |
| 289 | |
| 290 | } |
| 291 | |
| 292 | |
| 293 | |
| 294 | // Show background tiles |
| 295 | |
| 296 | for (y = 0; y <= ITOTcxx . . $ `src/level/level.h:39:9`!(viewH - 1) + 1; y++) { |
| 297 | |
| 298 | for (x = 0; x <= ITOTcxx . . $ `src/level/level.h:39:9`!(canvasW - 1) + 1; x++) { |
| 299 | |
| 300 | if ((x + ITOTcxx . . $ `src/level/level.h:39:9`!(vX) >= 256) || (y + ITOTcxx . . $ `src/level/level.h:39:9`!(vY) >= 64)) { |
| 301 | |
| 302 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(TTOIcxx . . $ `src/level/level.h:40:9`!(x) - (vX & 31), TTOIcxx . . $ `src/level/level.h:40:9`!(y) - (vY & 31), 32, 32, LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!); |
| 303 | |
| 304 | continue; |
| 305 | |
| 306 | } |
| 307 | |
| 308 | // Get the grid element from the given coordinates |
| 309 | ge = gridcxx . . $ JJ1Level#grid.[y + ITOTcxx . . $ `src/level/level.h:39:9`!(vY)] + x + ITOTcxx . . $ `src/level/level.h:39:9`!(vX); |
| 310 | |
| 311 | // If this tile uses a black background, draw it |
| 312 | if (ge->bgcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#bg.) |
| 313 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(TTOIcxx . . $ `src/level/level.h:40:9`!(x) - (vX & 31), TTOIcxx . . $ `src/level/level.h:40:9`!(y) - (vY & 31), 32, 32, LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!); |
| 314 | |
| 315 | |
| 316 | // If this is not a foreground tile, draw it |
| 317 | if ((ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. != 124) && |
| 318 | (ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. != 125) && |
| 319 | (eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].movementcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#movement. != 37) && |
| 320 | (eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].movementcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#movement. != 38)) { |
| 321 | |
| 322 | dst.x = TTOIcxx . . $ `src/level/level.h:40:9`!(x) - (vX & 31); |
| 323 | dst.y = TTOIcxx . . $ `src/level/level.h:40:9`!(y) - (vY & 31); |
| 324 | src.y = TTOIcxx . . $ `src/level/level.h:40:9`!(ge->tile); |
| 325 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(tileSetcxx . . $ JJ1Level#tileSet., &src, canvascxx . . $ canvas., &dst); |
| 326 | |
| 327 | } |
| 328 | |
| 329 | } |
| 330 | |
| 331 | } |
| 332 | |
| 333 | |
| 334 | // Show active events |
| 335 | if (eventscxx . . $ JJ1Level#events.) eventscxx . . $ JJ1Level#events.->drawcxx . . $ JJ1Event#draw(3d89109e85ced1be).(tickscxx . . $ Level#ticks., change); |
| 336 | |
| 337 | |
| 338 | // Show the players |
| 339 | for (x = 0; x < nPlayerscxx . . $ nPlayers.; x++) playerscxx . . $ players.[x].getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->drawcxx . . $ JJ1LevelPlayer#draw(3d89109e85ced1be).(tickscxx . . $ Level#ticks., change); |
| 340 | |
| 341 | |
| 342 | // Show bullets |
| 343 | if (bulletscxx . . $ JJ1Level#bullets.) bulletscxx . . $ JJ1Level#bullets.->drawcxx . . $ JJ1Bullet#draw(d4f767463ce0a6b3).(change); |
| 344 | |
| 345 | |
| 346 | |
| 347 | // Show foreground tiles |
| 348 | |
| 349 | for (y = 0; y <= ITOTcxx . . $ `src/level/level.h:39:9`!(viewH - 1) + 1; y++) { |
| 350 | |
| 351 | for (x = 0; x <= ITOTcxx . . $ `src/level/level.h:39:9`!(canvasW - 1) + 1; x++) { |
| 352 | |
| 353 | if ((x + ITOTcxx . . $ `src/level/level.h:39:9`!(vX) >= 256) || (y + ITOTcxx . . $ `src/level/level.h:39:9`!(vY) >= 64)) continue; |
| 354 | |
| 355 | // Get the grid element from the given coordinates |
| 356 | ge = gridcxx . . $ JJ1Level#grid.[y + ITOTcxx . . $ `src/level/level.h:39:9`!(vY)] + x + ITOTcxx . . $ `src/level/level.h:39:9`!(vX); |
| 357 | |
| 358 | // If this is an "animated" foreground tile, draw it |
| 359 | if (ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. == 123) { |
| 360 | |
| 361 | dst.x = TTOIcxx . . $ `src/level/level.h:40:9`!(x) - (vX & 31); |
| 362 | dst.y = TTOIcxx . . $ `src/level/level.h:40:9`!(y) - (vY & 31); |
| 363 | if (tickscxx . . $ Level#ticks. & 64) src.y = TTOIcxx . . $ `src/level/level.h:40:9`!(eventSet[ge->event].multiB); |
| 364 | else src.y = TTOIcxx . . $ `src/level/level.h:40:9`!(eventSet[ge->event].multiA); |
| 365 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(tileSetcxx . . $ JJ1Level#tileSet., &src, canvascxx . . $ canvas., &dst); |
| 366 | |
| 367 | //video.drawRect(dst.x, dst.y, TTOI(1), TTOI(1), 44, false); |
| 368 | } |
| 369 | |
| 370 | // If this is a foreground tile, draw it |
| 371 | if ((ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. == 124) || |
| 372 | (ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event. == 125) || |
| 373 | (eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].movementcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#movement. == 37) || |
| 374 | (eventSetcxx . . $ JJ1Level#eventSet.[ge->eventcxx . . $ $anonymous_type_e8f9ae77bbb68925_0#event.].movementcxx . . $ $anonymous_type_e8f9ae77bbb68925_1#movement. == 38)) { |
| 375 | |
| 376 | dst.x = TTOIcxx . . $ `src/level/level.h:40:9`!(x) - (vX & 31); |
| 377 | dst.y = TTOIcxx . . $ `src/level/level.h:40:9`!(y) - (vY & 31); |
| 378 | src.y = TTOIcxx . . $ `src/level/level.h:40:9`!(ge->tile); |
| 379 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(tileSetcxx . . $ JJ1Level#tileSet., &src, canvascxx . . $ canvas., &dst); |
| 380 | |
| 381 | //video.drawRect(dst.x, dst.y, TTOI(1), TTOI(1), 33, false); |
| 382 | } |
| 383 | |
| 384 | } |
| 385 | |
| 386 | } |
| 387 | |
| 388 | // FIXME: Temporary lines showing the water level |
| 389 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, FTOIcxx . . $ `src/types.h:52:9`!(waterLevel - viewY), canvasWcxx . . $ canvasW., 2, 24); |
| 390 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, FTOIcxx . . $ `src/types.h:52:9`!(waterLevel - viewY) + 3, canvasWcxx . . $ canvasW., 1, 24); |
| 391 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, FTOIcxx . . $ `src/types.h:52:9`!(waterLevel - viewY) + 6, canvasWcxx . . $ canvasW., 1, 24); |
| 392 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, FTOIcxx . . $ `src/types.h:52:9`!(waterLevel - viewY) + 10, canvasWcxx . . $ canvasW., 1, 24); |
| 393 | |
| 394 | // Show active guardian's energy bar |
| 395 | if (eventscxx . . $ JJ1Level#events.) eventscxx . . $ JJ1Level#events.->drawEnergycxx . . $ JJ1Event#drawEnergy(cb2f890c2fdad230).(tickscxx . . $ Level#ticks.); |
| 396 | |
| 397 | |
| 398 | // If this is a competitive game, draw the score |
| 399 | if (multiplayercxx . . $ Level#multiplayer.) gamecxx . . $ Level#game.->getModecxx . . $ Game#getMode(b2ac8a9286443acb).()->drawScorecxx . . $ GameMode#drawScore(ae6dc2419597cce5).(fontcxx . . $ JJ1Level#font.); |
| 400 | |
| 401 | |
| 402 | // Show panel |
| 403 | |
| 404 | int offsetX = 0; |
| 405 | bool isWide = (canvasWcxx . . $ canvasW. != SWcxx . . $ `src/io/gfx/video.h:38:9`!); |
| 406 | |
| 407 | if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::FPScxx . . $ hudType#FPS. && isWide) { |
| 408 | // center panel |
| 409 | offsetX = (canvasWcxx . . $ canvasW. >> 1) - (SWcxx . . $ `src/io/gfx/video.h:38:9`! >> 1); |
| 410 | } |
| 411 | |
| 412 | videocxx . . $ video..setClipRectcxx . . $ Video#setClipRect(382a02f39687f508).(canvascxx . . $ canvas., nullptr); |
| 413 | |
| 414 | if (ammoOffsetcxx . . $ JJ1Level#ammoOffset. != 0) { |
| 415 | |
| 416 | if (ammoOffsetcxx . . $ JJ1Level#ammoOffset. < 0) { |
| 417 | |
| 418 | // Finished descending |
| 419 | ammoOffsetcxx . . $ JJ1Level#ammoOffset. = 0; |
| 420 | |
| 421 | } |
| 422 | |
| 423 | src.x = 0; |
| 424 | src.y = FTOIcxx . . $ `src/types.h:52:9`!(ammoOffset); |
| 425 | src.w = 64; |
| 426 | src.h = 26 - src.y; |
| 427 | dst.x = 248; |
| 428 | dst.y = 3; |
| 429 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(panelAmmocxx . . $ JJ1Level#panelAmmo.[ammoTypecxx . . $ JJ1Level#ammoType.], &src, panelcxx . . $ JJ1Level#panel., &dst); |
| 430 | |
| 431 | } |
| 432 | |
| 433 | // always classic HUD if there is not enough space |
| 434 | if(setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::Classiccxx . . $ hudType#Classic. || |
| 435 | (setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::FPScxx . . $ hudType#FPS. && !isWide)) { |
| 436 | |
| 437 | dst.x = 0; |
| 438 | dst.y = canvasHcxx . . $ canvasH. - 33; |
| 439 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(panelcxx . . $ JJ1Level#panel., nullptr, canvascxx . . $ canvas., &dst); |
| 440 | |
| 441 | // Fill the one missing pixel row at the bottom black |
| 442 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, canvasHcxx . . $ canvasH. - 1, SWcxx . . $ `src/io/gfx/video.h:38:9`!, 1, LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!); |
| 443 | } else if (setupcxx . . $ setup..hudStylecxx . . $ Setup#hudStyle. == hudTypecxx . . $ hudType#::FPScxx . . $ hudType#FPS.) { |
| 444 | // quake-style HUD |
| 445 | |
| 446 | dst.y = canvasHcxx . . $ canvasH. - 33; |
| 447 | |
| 448 | for (x = 0; x <= ITOTcxx . . $ `src/level/level.h:39:9`!(offsetX); x++) { |
| 449 | // draw left border |
| 450 | dst.x = TTOIcxx . . $ `src/level/level.h:40:9`!(x); |
| 451 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(panelBGcxx . . $ JJ1Level#panelBG.[0], nullptr, canvascxx . . $ canvas., &dst); |
| 452 | |
| 453 | // draw right border |
| 454 | dst.x = canvasWcxx . . $ canvasW. - TTOIcxx . . $ `src/level/level.h:40:9`!(x + 1); |
| 455 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(panelBGcxx . . $ JJ1Level#panelBG.[1], nullptr, canvascxx . . $ canvas., &dst); |
| 456 | } |
| 457 | |
| 458 | // cut the panel borders and re-center |
| 459 | src.x = 1; // left: 1 white pixel |
| 460 | src.y = 0; |
| 461 | src.w = SWcxx . . $ `src/io/gfx/video.h:38:9`! - 8; // right: 3 black pixels + 5 pixels around screws |
| 462 | src.h = TTOIcxx . . $ `src/level/level.h:40:9`!(1); |
| 463 | dst.x = offsetX + 5; |
| 464 | SDL_BlitSurfacecxx . . $ `<external>/18043084669712134795/SDL_surface.h:873:9`!(panelcxx . . $ JJ1Level#panel., &src, canvascxx . . $ canvas., &dst); |
| 465 | |
| 466 | // Fill the one missing pixel row at the bottom black |
| 467 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(0, canvasHcxx . . $ canvasH. - 1, canvasWcxx . . $ canvasW., 1, LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!); |
| 468 | |
| 469 | offsetX += 4; // move everything inside right |
| 470 | } |
| 471 | |
| 472 | |
| 473 | // Show panel data |
| 474 | |
| 475 | // Show score |
| 476 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(localPlayercxx . . $ localPlayer.->getScorecxx . . $ Player#getScore(b126dc7c1de90089).(), offsetX + 84, canvasHcxx . . $ canvasH. - 27); |
| 477 | |
| 478 | // Show time remaining |
| 479 | if (endTimecxx . . $ Level#endTime. > tickscxx . . $ Level#ticks.) x = endTimecxx . . $ Level#endTime. - tickscxx . . $ Level#ticks.; |
| 480 | else x = 0; |
| 481 | y = x / (60 * 1000); |
| 482 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(y, offsetX + 116, canvasHcxx . . $ canvasH. - 27); |
| 483 | x -= (y * 60 * 1000); |
| 484 | y = x / 1000; |
| 485 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(y, offsetX + 136, canvasHcxx . . $ canvasH. - 27); |
| 486 | x -= (y * 1000); |
| 487 | y = x / 100; |
| 488 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(y, offsetX + 148, canvasHcxx . . $ canvasH. - 27); |
| 489 | |
| 490 | // Show lives |
| 491 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(localPlayercxx . . $ localPlayer.->getLivescxx . . $ Player#getLives(b126dc7c1de90089).(), offsetX + 124, canvasHcxx . . $ canvasH. - 13); |
| 492 | |
| 493 | // Show planet number |
| 494 | |
| 495 | if (worldNumcxx . . $ JJ1Level#worldNum. <= 41) // Main game levels |
| 496 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).((worldNumcxx . . $ JJ1Level#worldNum. % 3) + 1, offsetX + 184, canvasHcxx . . $ canvasH. - 13); |
| 497 | else if ((worldNumcxx . . $ JJ1Level#worldNum. >= 50) && (worldNumcxx . . $ JJ1Level#worldNum. <= 52)) // Christmas levels |
| 498 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(worldNumcxx . . $ JJ1Level#worldNum. - 49, offsetX + 184, canvasHcxx . . $ canvasH. - 13); |
| 499 | else panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(worldNumcxx . . $ JJ1Level#worldNum., offsetX + 184, canvasHcxx . . $ canvasH. - 13); |
| 500 | |
| 501 | // Show level number |
| 502 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(levelNumcxx . . $ JJ1Level#levelNum. + 1, offsetX + 196, canvasHcxx . . $ canvasH. - 13); |
| 503 | |
| 504 | // Show ammo |
| 505 | if (localPlayercxx . . $ localPlayer.->getAmmoTypecxx . . $ Player#getAmmoType(b126dc7c1de90089).() == -1) { |
| 506 | |
| 507 | // Draw "infinity" symbol |
| 508 | panelSmallFontcxx . . $ panelSmallFont.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).(":", offsetX + 225, canvasHcxx . . $ canvasH. - 13); |
| 509 | panelSmallFontcxx . . $ panelSmallFont.->showStringcxx . . $ Font#showString(7e50a619d5a117f1).(";", offsetX + 233, canvasHcxx . . $ canvasH. - 13); |
| 510 | |
| 511 | } else { |
| 512 | |
| 513 | x = localPlayercxx . . $ localPlayer.->getAmmocxx . . $ Player#getAmmo(b126dc7c1de90089).(); |
| 514 | |
| 515 | // Trailing 0s |
| 516 | if (x < 100) { |
| 517 | |
| 518 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(0, offsetX + 229, canvasHcxx . . $ canvasH. - 13); |
| 519 | if (x < 10) panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(0, offsetX + 237, canvasHcxx . . $ canvasH. - 13); |
| 520 | |
| 521 | } |
| 522 | |
| 523 | panelSmallFontcxx . . $ panelSmallFont.->showNumbercxx . . $ Font#showNumber(b1146eedae1e1d0b).(x > 999? 999: x, offsetX + 245, canvasHcxx . . $ canvasH. - 13); |
| 524 | |
| 525 | } |
| 526 | |
| 527 | |
| 528 | // Draw the health bar |
| 529 | |
| 530 | dst.x = 20; |
| 531 | x = localPlayercxx . . $ localPlayer.->getJJ1LevelPlayercxx . . $ Player#getJJ1LevelPlayer(cf23ec4c0d6db922).()->getEnergycxx . . $ JJ1LevelPlayer#getEnergy(b126dc7c1de90089).(); |
| 532 | y = (tickscxx . . $ Level#ticks. - prevTickscxx . . $ Level#prevTicks.) * 40; |
| 533 | |
| 534 | if (FTOIcxx . . $ `src/types.h:52:9`!(energyBar) < x) { |
| 535 | // increase |
| 536 | |
| 537 | if (ITOFcxx . . $ `src/types.h:53:9`!(x) - energyBarcxx . . $ JJ1Level#energyBar. < y) energyBarcxx . . $ JJ1Level#energyBar. = ITOFcxx . . $ `src/types.h:53:9`!(x); |
| 538 | else energyBarcxx . . $ JJ1Level#energyBar. += y; |
| 539 | |
| 540 | } else if (FTOIcxx . . $ `src/types.h:52:9`!(energyBar) > x) { |
| 541 | // decrease |
| 542 | |
| 543 | if (energyBarcxx . . $ JJ1Level#energyBar. - ITOFcxx . . $ `src/types.h:53:9`!(x) < y) energyBarcxx . . $ JJ1Level#energyBar. = ITOFcxx . . $ `src/types.h:53:9`!(x); |
| 544 | else energyBarcxx . . $ JJ1Level#energyBar. -= y; |
| 545 | |
| 546 | } |
| 547 | |
| 548 | if (energyBarcxx . . $ JJ1Level#energyBar. > F1cxx . . $ `src/types.h:31:9`!) { |
| 549 | |
| 550 | dst.w = FTOIcxx . . $ `src/types.h:52:9`!(energyBar) - 1; |
| 551 | |
| 552 | // Choose energy bar colour |
| 553 | int color; |
| 554 | if (x <= 20) color = 32 + (((tickscxx . . $ Level#ticks. / 75) * 4) & 15); // flash |
| 555 | else if (x > 51) color = 24; // blue only before first hit |
| 556 | else if (x > 38) color = 17; // green |
| 557 | else if (x > 25) color = 80; // pink |
| 558 | else if (x > 20) color = 32; // orange is only seen in easy |
| 559 | |
| 560 | // Draw energy bar |
| 561 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(offsetX + dst.x, canvasHcxx . . $ canvasH. - 13, dst.w, 7, color); |
| 562 | |
| 563 | dst.x += dst.w; |
| 564 | dst.w = 64 - dst.w; |
| 565 | |
| 566 | } else dst.w = 64; |
| 567 | |
| 568 | |
| 569 | // Fill in remaining energy bar space with black |
| 570 | videocxx . . $ video..drawRectcxx . . $ Video#drawRect(a4376a5627a47301).(offsetX + dst.x, canvasHcxx . . $ canvasH. - 13, dst.w, 7, LEVEL_BLACKcxx . . $ `src/jj1/level/jj1level.h:137:9`!); |
| 571 | } |