Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. void Update() {
  2.         int x=0;
  3.         int y=0;
  4.         int X0=0;
  5.         int X1=0;
  6.         int CurColor=0;
  7.  
  8.         //LINE DRAW
  9.         if (DRAW_TECH==1) {
  10.                 //Buffer to Buffer
  11.                 for (x = 0; x < Width; x++) {
  12.                         for (y = 0; y < Height; y++) {
  13.                                 BufferCarry2[x][y] = BufferDraw[x][y];
  14.                         }
  15.                 }
  16.                 //Convert Analyx to Drawmask Matrix
  17.                 for (x=0; x<Width; x++) {
  18.                         for (y=0; y<Height; y++) {
  19.                                 if (Analyx[x][y]==BufferCarry2[x][y]) {
  20.                                         Analyx[x][y]=1;
  21.                                 } else {
  22.                                         Analyx[x][y]=0;
  23.                                 }
  24.                         }
  25.                 }
  26.  
  27.                 for (x=0; x<Width; x++) {
  28.                         for (y=0; y<Height; y++) {
  29.                                 if (Analyx[x][y]==1) continue;
  30.                                 CurColor=BufferCarry2[x][y];
  31.                                 //try vertical line
  32.                                 int LineY=y;
  33.                                 while (LineY<Height && BufferCarry2[x][LineY]==CurColor) LineY++;
  34.                                 LineY--;
  35.  
  36.                                 //try horizontal line
  37.                                 int LineX=x;
  38.                                 while (LineX<Width && BufferCarry2[LineX][y]==CurColor) LineX++;
  39.                                 LineX--;
  40.  
  41.                                 //chosing the greatest area and draw
  42.                                 int LineYLen=LineY-y+1;
  43.                                 int LineXLen=LineX-x+1;
  44.  
  45.                                 if (LineXLen>=LineYLen) {
  46.                                         _ksys_line(x+OffsetX,y+OffsetY,LineX+OffsetX,y+OffsetY,CurColor);
  47.                                         int i=0;
  48.                                         for (i=x; i<=LineX; i++) Analyx[i][y]=1;
  49.                                         continue;
  50.                                 }
  51.                                 _ksys_line(x+OffsetX,y+OffsetY,x+OffsetX,LineY+OffsetY,CurColor);
  52.                                 int i=0;
  53.                                 for (i=y; i<=LineY; i++) Analyx[x][i]=1;
  54.                         }
  55.                 }
  56.  
  57.                 //From Buffer to Analyx and Reset Buffer
  58.                 for (x = 0; x < Width; x++) {
  59.                         for (y = 0; y < Height; y++) {
  60.                                 Analyx[x][y]=BufferCarry2[x][y];
  61.                                 BufferDraw[x][y]=GLOBAL_BACKGROUNDCOLOR;
  62.                         }
  63.                 }
  64.         }
  65.         //FULL FRAME DRAW
  66.         if (DRAW_TECH==0) {
  67.                 for (x = 0; x < Width; x++) {
  68.                         for (y = 0; y < Height; y++) {
  69.                                 BufferCarry[y][x][0] = BufferDraw[x][y]%256;
  70.                                 BufferDraw[x][y]/=256;
  71.                                 BufferCarry[y][x][1]=BufferDraw[x][y]%256;
  72.                                 BufferDraw[x][y]/=256;
  73.                                 BufferCarry[y][x][2]=BufferDraw[x][y]%256;
  74.                                 BufferDraw[x][y]=GLOBAL_BACKGROUNDCOLOR;
  75.                         }
  76.                 }
  77.                 DrawScreen (OffsetX,OffsetY,Width,Height,BufferCarry);
  78.         }
  79.         //Drawing Level
  80.         int i=0;
  81.         for (i=0; i<Objects; i++) {
  82.                 if (DataBase[i][0]==1) {
  83.                         DrawBlock (DataBase[i][1],DataBase[i][2],GLOBAL_BLOCKCOLOR);
  84.                 }
  85.                 if (DataBase[i][0]==2) {
  86.                         DrawPit (DataBase[i][1],DataBase[i][2],GLOBAL_PITCOLOR);
  87.                 }
  88.                 if (DataBase[i][0]==3) {
  89.                         DrawBatut (DataBase[i][1],DataBase[i][2],GLOBAL_BATUTCOLOR);
  90.                 }
  91.                 if (DataBase[i][0]==4) {
  92.                         DrawFlag (DataBase[i][1],DataBase[i][2],GLOBAL_FLAGCOLOR);
  93.                 }
  94.                 DataBase[i][1]-=GLOBAL_SPEED;
  95.                 if (Objects>0 && DataBase[0][1]<120) isRestart=1;
  96.         }
  97.         CleanDataBase();
  98.  
  99. }
  100.  
  101. void Jump () {
  102.         if (Key==' ') HeroFly=-13;
  103. }
  104.  
  105.  
  106. char CheckCollision() {
  107.         int i=0;
  108.         for (i=0; i<Objects; i++) {
  109.                 if (Abs(DataBase[i][1]-HeroX)>60) continue;
  110.                 int j=0;
  111.                 for (j=0;j<HeroSides; j++) {
  112.                         int PointX=CollideVerts[j][0];
  113.                         int PointY=CollideVerts[j][1];
  114.                         if (DataBase[i][0]==2 && PointX>=DataBase[i][1]+6 && PointX<=DataBase[i][1]+30-6 && PointY>=DataBase[i][2]+10 && PointY<=DataBase[i][2]+48) {
  115.                                 return 1;
  116.                         }
  117.                         if (DataBase[i][0]==3 && PointX>=DataBase[i][1] && PointX<=DataBase[i][1]+43 && PointY>=DataBase[i][2]+25 && PointY<=DataBase[i][2]+48) {
  118.                                 HeroFly=-25;
  119.                                 return 0;
  120.                         }
  121.                         if (DataBase[i][0]==4 && PointX>=DataBase[i][1] && PointX<=DataBase[i][1]+43 && PointY>=DataBase[i][2] && PointY<=DataBase[i][2]+48) {
  122.                                 DrawText (10,510,"checkpoint",GLOBAL_FLAGCOLOR);
  123.                                 GLOBAL_CHECKPOINT=CurrentCheck;
  124.                                 SPAWN_Y=DataBase[i][2];
  125.                         }
  126.  
  127.                         if (DataBase[i][0]==1 && PointX>=DataBase[i][1] && PointX<=DataBase[i][1]+43) {
  128.                                 if (PointY>=DataBase[i][2] && PointY<=DataBase[i][2]+43) {
  129.                                         if (HeroY>=DataBase[i][2] && HeroX<=DataBase[i][1]+6) {
  130.                                                 return 1;
  131.                                         }
  132.                                         if (HeroFly<0) {
  133.                                                 return 1;
  134.                                         }
  135.                                         //correcting edges
  136.                                         HeroAngle=0;
  137.                                         if (HeroSides%2==0) HeroAngle=360/HeroSides/2;
  138.                                         HeroY=DataBase[i][2]-DeltaH[HeroSides-3];
  139.                                         HeroFly=0;
  140.                                         Jump();
  141.                                         return 0;
  142.                                  } else {
  143.                                         if (DataBase[i][2]-HeroY<HeroFly && HeroFly>0 && DataBase[i][2]-HeroY>0) HeroFly=DataBase[i][2]-HeroY;
  144.                                  }
  145.                          }
  146.                 }
  147.         }
  148.         if (HeroY<500-DeltaH[HeroSides-3]) {
  149.                 HeroFly++;
  150.         } else {
  151.                 HeroFly=0;
  152.                 HeroAngle=0;
  153.                 if (HeroSides%2==0) HeroAngle=360/HeroSides/2;
  154.                 HeroY=500-DeltaH[HeroSides-3];
  155.                 Jump();
  156.         }
  157.         return 0;
  158. }
  159.