#include <all312.h> #include <jgmod.h> #include "map.h" #include "sprite.h" RGB_MAP rgb_table; COLOR_MAP trans_table; DATAFILE *music; void generate_explosions() { BITMAP *bmp = create_bitmap(EXPLODE_SIZE, EXPLODE_SIZE); unsigned char *p; int c, c2; int x, y; int xx, yy; int color; char tbuf[25]; #define HOTSPOTS 64 struct HOTSPOT { int x, y; int xc, yc; } hot[HOTSPOTS]; for (c=0; c<HOTSPOTS; c++) { hot[c].x = hot[c].y = (EXPLODE_SIZE/2)<<16; hot[c].xc = (random()&0xFFFF)-0x7FFF; hot[c].yc = (random()&0xFFFF)-0x7FFF; } for (c=0; c<EXPLODE_FRAMES; c++) { clear(bmp); color = ((c<16) ? c*4 : (80-c)) >> 2; for (c2=0; c2<HOTSPOTS; c2++) { for (x=-6; x<=6; x++) { for (y=-6; y<=6; y++) { xx = (hot[c2].x>>16) + x; yy = (hot[c2].y>>16) + y; if ((xx>0) && (yy>0) && (xx<EXPLODE_SIZE) && (yy<EXPLODE_SIZE)) { p = bmp->line[yy] + xx; *p += (color >> ((ABS(x)+ABS(y))/3)); if (*p > 63) *p = 63; } } } hot[c2].x += hot[c2].xc; hot[c2].y += hot[c2].yc; } for (x=0; x<EXPLODE_SIZE; x++) { for (y=0; y<EXPLODE_SIZE; y++) { c2 = bmp->line[y][x]; if (c2 < 8) bmp->line[y][x] = 0; else bmp->line[y][x] = 16+c2/4; } } if(c%6==0){ explosion[c/6] = get_rle_sprite(bmp); // sprintf(tbuf,"expl%02d.bmp",c/6); // save_bitmap(tbuf,bmp,spritegfx[GAME_PAL].dat); } } destroy_bitmap(bmp); } void generate_map() { int x,y; for(x=0;x<10;x++) for(y=0;y<2000;y++){ if(random()%3>0) map[x][y]=random()%256; } } int main(int argc,char *argv[]) { char zvuk=1,r; if(argc>1){ if(!strcasecmp(argv[1],"-nosound")) zvuk=0; } allegro_init(); install_keyboard(); install_timer(); printf("loading...\n"); if(zvuk){ reserve_voices(16,-1); install_sound(-1,0,0); install_mod(8); } check_cpu(); packfile_password("IdeaZ"); generate_map(); set_color_depth(8); tex=load_datafile("tex.dat"); spritegfx=load_datafile("sprite.dat"); if(zvuk) music=load_datafile("music.dat"); create_rgb_table(&rgb_table, spritegfx[GAME_PAL].dat, 0); rgb_map = &rgb_table; create_light_table(&trans_table, spritegfx[GAME_PAL].dat,22,22,22, 0); color_map = &trans_table; set_gfx_mode(0,640,480,0,0); set_gfx_mode(0,640,480,0,0); set_palette(spritegfx[GAME_PAL].dat); generate_explosions(); set_projection_viewport(0,0,480,480); set_palette(spritegfx[GAME_PAL].dat); if(zvuk) play_mod(music[0].dat,1); r=game(); if(zvuk) stop_mod(); allegro_exit(); if(r==-1) prehral1(); if(r==-2) prehral2(); if(r==2) vyhral1(); exit(0); }