Starting from:
$30

$24

Lab 01: Drawing Shapes Solution

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 col, int row, unsigned short color)

Fills the pixel at the specified col and row with the specified color



void drawTriangle(int col, int row)



Draws a triangle at the specified column and row



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



May be any (GBA appropriate) size



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!
void drawRect(int col, int row)



Draws a rectangle at the specified column and row



You may NOT draw a square​. Points will be deducted from your lab grade if you draw a rectangle that has the same width and height.



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



May be any (GBA appropriate) size



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






After writing the two functions, ​call the ​drawTriangle ​function two times and call the
drawRect function one time in your main function,​with different parameters. The output of your program should look something like the following.

































































































Your triangles and your rectangle may be any size, shape (given the rectangle is not a square), color, rotation, or position you want, as long as we can see that you drew two triangles and one rectangle. 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




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



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



Submission Instructions







Zip up your entire project folder, including all source files, the Makefile, and everything
produced during compilation ​(including the .gba file)​. Submit this zip on Canvas. Name your submission Lab01_FirstameLastname, for example:“Lab01_GeorgeBurdell.zip”.

More products