Пример #1
0
 void World::Draw()
 {
     if(m_state == IDLE)
     {
         if(m_texBanner != nullptr && m_texBanner->GetTexId() != 0)
         {
             DrawBanner();
         }
     }
     else if(m_state == PLAYING)
     {
         DrawPlayField();
         DrawScore();
         DrawBall();
         DrawPlayer1();
         DrawPlayer2();
     } 
     else if(m_state == GAMEOVER) 
     {
         glClear(GL_COLOR_BUFFER_BIT);
         DrawPlayField();
         DrawScore();
     }
 }
void __fastcall TOpenGLFootBall::Draw3D1Paint(TObject *Sender,
      const TRect &ARect)
{
  int R = 40;
  // green color
  TCanvas3D *c = Draw3D1->Canvas;
  c->Brush->Color = FGreen;
  c->Pen->Color = TColor(RGB(0x0,0x80,0x0));

  // bottom base
  int tmp = Draw3D1->ChartXCenter;
  c->Cube(tmp-230,tmp+230,Draw3D1->ChartYCenter-2,Draw3D1->ChartYCenter+4,-100,200,false);

  // bottom carpet
  int y = Draw3D1->ChartYCenter-8;

  // light gray color to draw lines
  c->Pen->Style = psSolid;
  c->Pen->Color = FLines;
  c->Brush->Style = bsClear;

  // big rectangle
  c->RectangleY(tmp-W+20,y,tmp+W-20,-80,180);

  // center line
  c->MoveTo3D(tmp,y,-80);
  c->LineTo3D(tmp,y,180);

  // middle circle }
  DrawArc(c,tmp,y,50,R,0,36);

  // left gate area lines
  DrawGateArea(c,tmp-W+20,y,60,70);
  DrawArc(c,tmp-W+20+35,y,50,40,22,32);
  DrawGateArea(c,tmp-W+20,y,20,30);
  //  left gate and net
  DrawGate(c,tmp-W+20,y,18,50,20);
  DrawGate(c,tmp-W+10,y,12,50,18);
  DrawGateNet(c,tmp-W+20,10,y);

  // right gate area lines
  DrawGateArea(c,tmp+W-20,y,-60,70);
  DrawArc(c,tmp+W-20-35,y,50,40,4,14);
  DrawGateArea(c,tmp+W-20,y,-20,30);

  // right gate and net
  DrawGate(c,tmp+W-20,y,18,50,20);
  DrawGate(c,tmp+W-10,y,12,50,18);
  DrawGateNet(c,tmp+W-20,-10,y);

  // the four corners
  DrawCorner(c,tmp-W+20,y,-80,27,36);
  DrawCorner(c,tmp+W-20,y,-80,0,9);
  DrawCorner(c,tmp-W+20,y,180,18,27);
  DrawCorner(c,tmp+W-20,y,180,9,18);

  // the two penalties and center point
  DrawArc(c,tmp-W+20+45,y,50,1,0,36);
  DrawArc(c,tmp+W-20-45,y,50,1,0,36);
  DrawArc(c,tmp,y,50,1,0,36);

  // the ball
  c->Brush->Color = FBall;
  c->Sphere(Draw3D1->ChartXCenter+Ball.x,y-TrackBar1->Position+1,50+Ball.y,TrackBar1->Position);

  // the back public seats
  if (CheckBox2->Checked) DrawSeats(c,y,tmp,W);
   // Draw players
  if (CheckBox3->Checked)
  {
    y = Draw3D1->ChartYCenter-17;
    for (int t=0;t<5;t++)
    {
      if (t>=4) DrawPlayer2(c,Draw3D1->ChartXCenter+Players[t].x,y,50+Players[t].y);
      else DrawPlayer1(c,Draw3D1->ChartXCenter+Players[t].x,y,50+Players[t].y);
    }
  }
}