/* Called when window needs to be redrawn */ void redraw(void) { glClear(GL_COLOR_BUFFER_BIT); draw_dither(); glRasterPos2i(0, 0); glPixelZoom(3.f, 3.f); glDrawPixels(image_w, image_h, GL_RGBA, GL_UNSIGNED_BYTE, (GLubyte *)img); glPixelZoom(1.f, 1.f); glAccum(GL_ACCUM, -1.0); glAccum(GL_RETURN, -1.f); glRasterPos2i(0, 0); glDrawBuffer(GL_FRONT); glReadBuffer(GL_FRONT); pixel_map(1); glCopyPixels(0, 0, 3*image_w, 3*image_h, GL_COLOR); pixel_map(0); CHECK_ERROR("redraw"); }
void killtower(gamedata &g, building &b, double xs, double ys, int h, int side){ // Redraw sky and wreckage SDL_Rect rect; rect.x = b.x; rect.y = b.y - b.towersize*16 - 8; rect.w = 16; rect.h = (b.towersize + 1 - h)*16 + 8; SDL_FillRect(g.gamescreen,&rect, 16); g.images[198].blit(g.gamescreen,b.x, b.y - h*16); draw_dither(g.gamescreen, b.x, b.y - b.towersize*16 - 8, 16, (b.towersize + 1 - h)*16 + 8); for (int i=h+1;i<=b.towersize;i++){ falltype fragment; fragment.x = double(b.x); fragment.y = double(b.y) - i*16.0; fragment.xs = xs; fragment.ys = ys; fragment.image = 197; fragment.side = side; fragment.type = 2; g.fall.add(fragment); falltype shrapnel; shrapnel.x = double(b.x) + 6.0; shrapnel.y = double(b.y) - i*16.0; shrapnel.xs = (2.0*drand() - 1.0) * GAME_SPEED; shrapnel.ys = (-1.5*drand() - 1.5) * GAME_SPEED; shrapnel.image = b.shrapnelimage + int(drand()*3); shrapnel.type = 1; g.fall.add(shrapnel); } if ((b.deadimage > 0) && (h<b.towersize)){ falltype roof; roof.x = double(b.x); roof.y = double(b.y) - (b.towersize+1)*16.0; roof.xs = xs; roof.ys = ys; roof.image = b.deadimage; roof.type = 1; g.fall.add(roof); } for (int j=0;j<3;j++){ falltype shrapnel; shrapnel.x = double(b.x) + 6.0; shrapnel.y = double(b.y) - h*16.0; shrapnel.xs = (2.0*drand() - 1.0) * GAME_SPEED; shrapnel.ys = (-1.5*drand() - 1.5) * GAME_SPEED; shrapnel.image = b.shrapnelimage + int(drand()*3); shrapnel.type = 1; g.fall.add(shrapnel); } // Explosion at top firetype boom; boom.x = b.x; boom.y = b.y - h*16; boom.time = 0; boom.type = 0; g.explosion.add(boom); // Fire if tower levelled if (h == 0){ firetype fire; fire.x = b.x; fire.y = b.y; fire.time = 0; g.flame.add(fire); } // Recalculate intelligence map setup_intelligence(g.gamemap); // Reduce height of tower b.towersize = h - 1; // Remove tower if levelled if (h == 0){ b.type = 0; }else{ b.deadimage = 199; } g.sound.play(SOUND_EXPLODE); }
void killbuilding(gamedata &g, building &b){ // Draw dead image //gl_setcontext(&g.gamescreen); g.images[b.deadimage].blit(g.gamescreen,b.x, b.y); draw_dither(g.gamescreen, b.x, b.y, 16, 24); // Subtract points if owned building if (b.side > 0) g.dp.reset(); while (g.dp.next()){ if (b.side == g.dp().side){ g.dp().scoreloss += int(b.points*0.5); }else{ g.dp().buildingwin--; } } if (b.image != 71){ // not a fuel canister if (b.type != 1){ // not a tree firetype boom; boom.x = b.x; boom.y = b.y; boom.time = 0; boom.type = 0; g.explosion.add(boom); firetype fire; fire.x = b.x; fire.y = b.y; fire.time = 0; g.flame.add(fire); } for (int i=0;i<3;i++){ falltype shrapnel; shrapnel.x = double(b.x) + 6.0; shrapnel.y = double(b.y); shrapnel.xs = (2.0*drand() - 1.0) * GAME_SPEED; shrapnel.ys = (-1.5*drand() - 1.5) * GAME_SPEED; switch(i){ case 0: case 1: shrapnel.image = b.shrapnelimage + int(drand()*3); break; case 2: shrapnel.image = b.shrapnelimage2 + int(drand()*3); break; } shrapnel.type = 1; if (b.type == 1) shrapnel.type = 0; g.fall.add(shrapnel); } g.sound.play(SOUND_EXPLODE); }else{ // fuel blows up firetype boom; boom.x = int(b.x-8); boom.y = int(b.y-16); boom.time = 0; boom.type = 1; g.explosion.add(boom); firetype fire; fire.x = b.x; fire.y = b.y; fire.time = 0; g.flame.add(fire); fire.x = b.x - 8; fire.time = int(drand()*10.0*GAME_SPEED); g.flame.add(fire); fire.x = b.x + 8; fire.time = int(drand()*10.0*GAME_SPEED); g.flame.add(fire); int shrapnelbits = 7 + int(drand()*4); for (int i=0;i<shrapnelbits;i++){ falltype shrapnel; shrapnel.x = double(b.x) + 6.0; shrapnel.y = double(b.y); shrapnel.xs = (2.0*drand() - 1.0) * GAME_SPEED; shrapnel.ys = (-2.0*drand() - 4.0) * GAME_SPEED; shrapnel.image = b.shrapnelimage + int(drand()*3); shrapnel.type = 1; g.fall.add(shrapnel); } g.sound.play(SOUND_FUELEXPLODE); } // Check for radar or gun kills switch(b.type){ case 4: // radar g.radar.reset(); while (g.radar.next()){ if (b.id == g.radar().id) g.radar.kill(); } break; case 5: // guns g.gun.reset(); while (g.gun.next()){ if (b.id == g.gun().id) g.gun.kill(); } break; } // Remove the building b.type = 0; }