| Посмотрите ктонибудь, где ошибка! Пишет: Инструкция по адресу "0х668d2b25" обратилась к памяти по адресу "0x0000000c". Памятьне может быть "read"
#include <stdio.h>
#include "allegro.h"
#include <time.h>
#define NUM_STEPS 100
#define BUFFER_SIZE 1024
class Pole
{
public:
int game_pole[9][9],a,b,i,k,fl[9][9];
int l;
Pole()
{
a=0;b=0;i=0;k=0;
for (i=0;i<9;i++)
{
for (k=0;k<9;k++)
{
game_pole[i][k]=0;
fl[i][k]=0;
}
}
setBomb();
}
void setBomb()
{
//случайно выдает бомбы
for (i=0;i<10;i++)
{
a=(rand()%9);
b=(rand()%9);
if (game_pole[a][b]== 10)i=i-1;
game_pole[a][b]=10;
}
//анализ бомб
for (i=0;i<9;i++)
{
for (k=0;k<9;k++)
{
a=0;
if (game_pole[i+1][k] == 10 && i+1 != 9 ) a=a+1;
if (game_pole[i-1][k] == 10 && i-1 != -1) a=a+1;
if (game_pole[i+1][k+1] == 10 && i+1 != 9 && k+1 != 9 ) a=a+1;
if (game_pole[i-1][k+1] == 10 && i-1 != -1 && k+1 != 9) a=a+1;
if (game_pole[i+1][k-1] == 10 && i+1 != 9 && k-1 != -1) a=a+1;
if (game_pole[i-1][k-1] == 10 && i-1 != -1 && k-1 != -1) a=a+1;
if (game_pole[i][k+1] == 10 && k+1 != 9 ) a=a+1;
if (game_pole[i][k-1] == 10 && k-1 != -1) a=a+1;
if (game_pole[i][k] == 10) a=10;
game_pole[i][k]=a;
}
}
}
// No description
int click(int b)
{
if (b == 1)
for (i=0; i<9; i++)
for (k=0; k<9; k++)
if (mouse_x > 10+20*i && mouse_x < 10+20*(i+1) && mouse_y > 11+20*k && mouse_y < 11+20*(k+1))
{
if (fl[i][k]!=7) a=game_pole[i][k];
fl[i][k]=8;
}
if (b == 2)
for (i=0; i<9; i++)
for (k=0; k<9; k++)
if (mouse_x > 10+20*i && mouse_x < 10+20*(i+1) && mouse_y > 11+20*k && mouse_y < 11+20*(k+1))
if (fl[i][k]!=8)
if (fl[i][k]!=7)
{
fl[i][k]=7;
a=7;
}
else {fl[i][k]=0;a=13;}
l=0;
//проверка условия выигрыша
for (i=0;i<9;i++)
for (k=0;k<9;k++)
{
if (fl[i][k]!=8) l=l+1;
if (l==71) a=11;
}
return a;
}
};
int main(int argc, char *argv[])
{
Pole Mini;
SAMPLE *amatory;
SAMPLE *amatory1;
BITMAP *fon;
BITMAP *c[13];
BITMAP *winer;
BITMAP *looser;
PALETTE the_palette;
BITMAP *ZAST3;
BITMAP *ZAST4;
char bmp_name[256];
char pcx_name[256];
int bomb[10][2];
int game_pole[9][9];
int your_pole[9][9];
int a=0,b=0,m=0,n=0;
int i,k,l,r=0;
if (allegro_init() != 0)
return 1;
install_keyboard();
install_mouse();
install_timer();
srand(time(NULL));
if (set_gfx_mode(GFX_DIRECTX_WIN, 400, 199, 0, 0) != 0) {
if (set_gfx_mode(GFX_SAFE, 400, 199, 0, 0) != 0) {
set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
return 1;
}
}
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, argv[0]) != 0) {
allegro_message("Error initialising sound system\n%s\n", allegro_error);
return 1;
}
//музыка
amatory = load_wav("1.wav");
play_sample(amatory, 128, 128, 0, TRUE);
//picture Ivanov games
ZAST3 = load_bmp("zast3.bmp", desktop_palette);
blit(ZAST3, screen, 0, 0, 0, 0, ZAST3->w, ZAST3->h);
set_palette(desktop_palette);
_sleep (3000);
//picture presents
ZAST4 = load_bmp("ZAST4.bmp", desktop_palette);
blit(ZAST4, screen, 0, 0, 0, 0, ZAST4->w, ZAST4->h);
set_palette(desktop_palette);
_sleep (3000);
set_gfx_mode(GFX_DIRECTX_WIN, 400, 199, 0, 0);
fon = load_bmp("fon4.bmp", the_palette);
winer = load_bmp("winer.bmp", desktop_palette);
looser = load_bmp("looser.bmp", desktop_palette);
set_palette(the_palette);
blit(fon, screen, 0, 0, 0, 0, fon->w, fon->h);
c[0] = load_bmp("0.bmp", the_palette);
c[1] = load_bmp("1.bmp", the_palette);
c[2] = load_bmp("2.bmp", the_palette);
c[3] = load_bmp("3.bmp", the_palette);
c[4] = load_bmp("4.bmp", the_palette);
c[5] = load_bmp("5.bmp", the_palette);
c[6] = load_bmp("6.bmp", the_palette);
c[7] = load_bmp("bomba1.bmp", the_palette);
c[8] = load_bmp("pusto.bmp", the_palette);
c[9] = load_bmp("vopros.bmp", the_palette);
c[10] = load_bmp("bomba.bmp", the_palette);
c[13] = load_bmp("kletka.bmp", the_palette);
show_mouse(screen);
do {
if (mouse_b == 1)
{
scare_mouse(); //скрыть мышь чтобы небыло косяков
r=Mini.click(mouse_b);
if (r=10)
{
_sleep(2000);
set_palette(desktop_palette);
clear_to_color(screen, makecol(255, 255, 255));
blit(looser, screen, 0, 0, 0, 0, 400, 199);
_sleep(3000);return 0;
}
else if (r=11)
{
set_palette(desktop_palette);
clear_to_color(screen, makecol(255, 255, 255));
blit(winer, screen, 0, 0, 0, 0, 400, 199);
_sleep(5000);return 0;
}
blit(c[r], screen, 0, 0, 10+20*i, 11+20*k, c[0]->w, c[0]->h);
}
if (mouse_b == 2)
{
scare_mouse();
r=Mini.click(mouse_b);
blit(c[r], screen, 0, 0, 10+20*i, 11+20*k, c[0]->w, c[0]->h);
}
show_mouse(screen);
vsync();
} while (!key[KEY_ESC]);
system("PAUSE");
return 0;
}
END_OF_MAIN();
|
| |