значится так тема содержит часть программы(игрушка Stack Attack) в которой описывается прорисовка и падение ящиков
последнего (т.е. падения не происходит) никак не могу исправить это
программирование в графическом режиме в среде bc3.1 с использованием псевдо-графики вот код (ps знаю задание не айс но кто сможет помогите понять проблему плиз)
Код:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <time.h>
const int Width=16;
const int Height=16;
const int CellSize=30;
int i,j,x=8,y=14;
time_t u;
time_t u1;
time_t time1;
time_t time2;
int Cell[16][16]={
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, // поле игры
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
void Graphinit()
{
int gdriver=DETECT,gmode,errorcode;
initgraph(&gdriver,&gmode,""); // инициализация графики
errorcode=graphresult();
if(errorcode !=grOk)
{
printf("Grafics error:%s\n",grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
}
void DrawField() //функция прорисовки
{
int i;
int j;
setcolor(WHITE);
rectangle(0, 0, 30 * Width, 30 * Height);
for (i = 1; i < (Width - 1); i++){
line(i*CellSize,1, i*CellSize,Height*CellSize);
for (j = 1; j <= (Height - 1); j++){
line(1, i * CellSize, Width * CellSize, i * CellSize);
setfillstyle(1, WHITE);
}
}
for (i = 0; i < Height; i++)
{
for (j = 0; j < Width; j++)
{
if (Cell[i][j] == 1)
{
bar(j * CellSize, i * CellSize, (j + 1) * CellSize, (i + 1) * CellSize);
}
}
}
setfillstyle(1, YELLOW);
for (i=0; i<Height;i++)
{
for (j=0;j<Width; j++)
{
if (Cell[i][j] == 0)
{
bar(j * CellSize, i * CellSize, (j + 1) * CellSize, (i + 1) * CellSize);
}
}
}
setfillstyle(1, BLUE);
for (i=0; i<Height;i++)
{
for (j=0;j<Width; j++)
{
if (Cell[i][j] == 3)
{
bar(j * CellSize, i * CellSize, (j + 1) * CellSize, (i + 1) * CellSize);
}
}
}
}
int randomstack(){
int w=0;
srand (time(NULL));
int h=rand()%14+1;
Cell[w][h]=3;
return(h);
return(w);
}
int death()
{
int gameover;
int w,h;
int life=3;
if (w==x&&h==y-1)
{
life=life-1;
}
if(life==0)
{
gameover=1;
}
return(gameover);
}
void quit()
{
closegraph();
}
void main(void)
{
Graphinit();
DrawField();
int gameover=0;
time1 = time(NULL);
cycle:
int r=0;
randomstack();
for(w=r;w<15;w++){ // собственно цикл падения
time2 = time(NULL);
if ((time2-time1)>1){
w=w+1;
while (Cell[w][h]==0){
w=w-1;
Cell[w][h]=0;
w=w+1;
Cell[w][h]=3;
r=w;
DrawField();
}
time1=time2;
}
}
goto cycle;
death();
if(gameover!=1)
{
quit();
}
};
в конце есть не совсем приятная метка cycle прошу не ругаться я знаю что это нехороший стиль но пока пусть будет