Starting from:

$25

CS2261- Lab 01 Solved

Drawing Triangles

 

Provided Files

      ●    lab01.c

Files to Edit/Add
●     lab01.c

●     Your Makefile

 

Instructions
In this lab, you will be completing TODOs to finish writing two functions:

●     void setPixel(int row,int col,unsigned short color)

○      Fills the pixel at the specified row and column with the specified color

●     void drawTriangle(int row,int col)

○      Draws a triangle at the specified row and column

                  ○    May be any color, either filled in or not (your choice)

○    May NOT be hardcoded. You may not just call setPixel for every colored-in dot on your triangle. You must use iteration to do so.

 

After writing the two functions, call the ​drawTriangle​ function at least three times in your main function, with different parameters. The output of your program should look something like this(next page):

 

 

 

Your triangles may be any size, shape, color, rotation, or position you want, as long as we can see that you drew three of them. If you want, you can add parameters to the function to control color, size, or shape. After you have completed all the TODOs and your output looks correct, you are finished with the lab after you submit it.

 

Tips
●     If your code is not compiling, make sure that your Makefile has ​lab02.c​ as

SOURCES

●     For-loops are really great for drawing lines.

●     The GBA screen size is 240 pixels wide and 160 pixels tall

●     If you add parameters to your ​drawTriangle​ function, you must change its prototype

 

More products