Jump to content

Campo de futebol


fernas
 Share

Recommended Posts

Preciso de fazer um campo de futebol com 2 jogadores e uma bola. O problema é que não consigo fazer as áreas e as balizas..

#include <graphics.h>

int main() 
{ 
  initwindow(800,600); //open a 400x300 graphics window
  setbkcolor(GREEN);
  int poly[8];
  poly[0] = 20;          
  poly[1] = 100;
  poly[2] = 800 - 20; 
  poly[3] = 100;
  poly[4] = 800-20;     
  poly[5] = 500-20;
  poly[6] = 20;       
  poly[7] = 500-20; 
  setfillstyle(1, GREEN);
  fillpoly(4, poly);
  moveto(400,100);
  lineto(400, 480);        
  circle(400, 300, 50);
  setfillstyle(1, BLUE); 
  fillellipse(200, 150, 10, 10);  //jogador de cima
  fillellipse(200, 400, 10, 10);  //jogador de baixo
  setfillstyle(1, WHITE); //cor da bola
  fillellipse(200, 160, 3, 3); //bola
  while(!kbhit());     //wait for user to press a key
  closegraph();        //close graphics window
  return 0; 
}

Aqui está o que já fiz:

2exufyf.png

P.S: O compilador que estou a usar é o Dev-C++

Link to comment
Share on other sites

Sou mesmo distraído, postei isto na área de C, o programa tá em C++ lol

Update:

#include <graphics.h>

int main() 
{ int poly[8], det, mod;
    detectgraph(&det, &mod);   // Obtém o driver gráfico e o modo  de acordo com o hardware 
    initgraph(&det, &mod, "");  // inicializa  modo gráfico de acordo com os parâmetros obtidos

  initwindow(800,600); //open a 400x300 graphics window
  setbkcolor(GREEN);

  poly[0] = 20;          
  poly[1] = 100;
  poly[2] = 800 - 20; 
  poly[3] = 100;
  poly[4] = 800-20;     
  poly[5] = 500-20;
  poly[6] = 20;       
  poly[7] = 500-20; 
  setfillstyle(1, GREEN);
  fillpoly(4, poly);
  moveto(400,100); //posiciona cursor na posição
  lineto(400, 480);   //desenha uma linha     
  circle(400, 300, 50);
  rectangle(20, 150, 160, 430);
  rectangle(20, 220, 80, 360);
  rectangle(5, 260, 20, 320);
  rectangle(630, 150, 800-20, 430);
  rectangle(800-20, 220, 720, 360);
  rectangle(800-20, 260, 800-5, 320);
  //-------------//
  setfillstyle(1, BLUE); //cor jogadores porto
  fillellipse(150, 150, 10, 10); //defesa esquerdo porto
  fillellipse(150, 250, 10, 10); //defesa centro porto
  fillellipse(150, 350, 10, 10); //defesa centro2 porto
  fillellipse(150, 450, 10, 10); //defesa direito porto
  fillellipse(250, 150, 10, 10); //médio esquerdo porto
  fillellipse(250, 250, 10, 10); //médio centro porto
  fillellipse(250, 350, 10, 10); //médio centro2 porto
  fillellipse(250, 450, 10, 10); //médio direito porto
  fillellipse(350, 250, 10, 10); //Avançado porto
  fillellipse(350, 350, 10, 10); //Avançado2 porto
  //---------------//
  setfillstyle(1, BLACK); //cor guarda-redes porto
  fillellipse(50, 295, 10, 10); //guarda-redes porto
  //--------------//
  setfillstyle(1, RED); //cor jogadores benfica
  fillellipse(450, 300, 10, 10); //Avançado benfica
  fillellipse(550, 150, 10, 10); //médio direito benfica
  fillellipse(550, 300, 10, 10); //médio centro benfica
  fillellipse(550, 450, 10, 10); //médio esquerdo benfica
  fillellipse(620, 350, 10, 10); //médio defensivo benfica
  fillellipse(620, 250, 10, 10); //médio defensivo2 benfica
  fillellipse(690, 150, 10, 10); //defesa direito benfica
  fillellipse(710, 250, 10, 10); //defesa centro benfica
  fillellipse(710, 350, 10, 10); //defesa centro2 benfica
  fillellipse(690, 450, 10, 10); //defesa esquero benfica
  //-----------//
  setfillstyle(1, YELLOW); //cor guarda-redes benfica
  fillellipse(750, 295, 10, 10); //guarda-redes benfica
  //----------//
  setfillstyle(1, WHITE); //cor da bola
  fillellipse(400, 300, 5, 5); //bola
  //--------//
  while(!kbhit());     //wait for user to press a key
  closegraph();        //close graphics window
  return 0; 
}

wb6kir.png

P.S: Decidi meter mais jogadores.. 😉

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.