C and C++ Computer Graphics

program for simple animation of football goal

program for simple animation of football goal
#include <graphics.h>
#include <conio.h>
#include <dos.h>

int main() {
int gd = DETECT, gm;
int x, y = 350; // Ball position

initgraph(&gd, &gm, "");

// Draw Goal Post
setcolor(WHITE);
rectangle(450, 150, 550, 350); // Goal boundary
line(450, 150, 500, 100); // Net top
line(550, 150, 500, 100);

// Animate Football
for (x = 50; x <= 480; x += 10) {
cleardevice();

// Draw Goal Again
setcolor(WHITE);
rectangle(450, 150, 550, 350);
line(450, 150, 500, 100);
line(550, 150, 500, 100);

// Draw Football
setcolor(YELLOW);
setfillstyle(SOLID_FILL, YELLOW);
fillellipse(x, y, 15, 15);

delay(100);
}

// Final Message
setcolor(GREEN);
outtextxy(200, 400, "GOAL !!!");

getch();
closegraph();
return 0;
}

Leave a comment

Your email address will not be published. Required fields are marked *