C Program to Draw a Rocket on Canvas Using Graphics Programming in Command Line Full Project For Beginners

  • Post author:
  • Post category:c++
  • Post comments:0 Comments

 

 

rocket.c

 

 

// C program for the above approach

#include <conio.h>
#include <graphics.h>
#include <stdio.h>

// Driver Code
void main()
{
    // Initialize of gdriver with
    // DETECT macros
    initgraph(&gd, &gm, "C:\\turboc3\\bgi");

    setfillstyle(SOLID_FILL, BROWN);
    rectangle(650, 450, 700, 650);

    // Rocket body
    floodfill(652, 648, 15);
    line(0, 650, 1500, 650);

    // Land outline
    setfillstyle(SOLID_FILL, WHITE);
    line(650, 450, 700, 450);
    line(650, 450, 675, 350);
    line(675, 350, 700, 450);

    // Rocket head
    floodfill(652, 448, 15);
    setfillstyle(SOLID_FILL, BLUE);
    line(650, 500, 650, 450);
    line(625, 500, 650, 500);
    line(625, 500, 650, 450);

    // Rocket left up wing
    floodfill(648, 498, 15);
    setfillstyle(SOLID_FILL, BLUE);
    line(700, 450, 700, 500);
    line(725, 500, 700, 500);
    line(700, 450, 725, 500);

    // Rocket right up wing
    floodfill(702, 498, 15);
    setfillstyle(SOLID_FILL, BLUE);
    line(625, 650, 650, 650);
    line(650, 575, 650, 650);
    line(625, 650, 650, 575);

    // Rocket left down wing
    floodfill(627, 648, 15);
    setfillstyle(SOLID_FILL, GREEN);
    floodfill(627, 698, 15);

    setfillstyle(SOLID_FILL, BLUE);
    line(725, 650, 700, 650);
    line(700, 575, 700, 650);
    line(725, 650, 700, 575);

    // Rocket right down wing
    floodfill(702, 648, 15);
    line(0, 650, 1500, 650);

    // Draw the land with green color
    setfillstyle(SOLID_FILL, GREEN);
    floodfill(627, 698, 15);
    getch();

    // Close the initialized gdriver
    closegraph();
}

Leave a Reply