
By the end of Task 2, one method draws all three buildings. You give it where the building stands, how wide it is, and how many floors it has. The method works out the rest — how tall it is, where its roof goes, and how many windows to light on every floor.
Task 3 is not shown. That city is yours to design.
'F' → Fullscreen
Today you build a city at night in a new program named 2-4-skyline. Every building comes from one method. The deck's trees used their parameters for sizes; your buildings use them to decide how many times a loop runs, so a bigger argument means more windows, not just a bigger shape.
How to read the code blocks. Each task's code block shows your whole program, from line 1, as it should look when that task is finished.
The green lines marked with a + are the ones you add or change for that task — everything else is already in your file. Do not type the + sign.
DrawBuilding takes a position, a width, and a number of floors. Each floor is 30 pixels tall, so the method works out the height, and from that the top of the building: 400, the street, minus the height.Raylib.CloseWindow();, at the very bottom, the same as every method in this course.#:package Raylib-cs@8.0.0
using Raylib_cs;
Raylib.InitWindow(800, 450, "Skyline");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(Color.DarkBlue); Raylib.DrawRectangle(0, 400, 800, 50, Color.Black);
DrawBuilding(80, 100, 6); DrawBuilding(250, 70, 11); DrawBuilding(400, 130, 4);
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawBuilding(int x, int width, int floors){ int height = floors * 30; int top = 400 - height;
Raylib.DrawRectangle(x, top, width, height, Color.Gray);}DrawBuilding. The outer loop runs once per floor; the inner loop draws one window every 30 pixels across, so width / 30 windows per floor. Activity 1.21's nested loops, inside a method.width / 30.#:package Raylib-cs@8.0.0
using Raylib_cs;
Raylib.InitWindow(800, 450, "Skyline");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(Color.DarkBlue); Raylib.DrawRectangle(0, 400, 800, 50, Color.Black);
DrawBuilding(80, 100, 6); DrawBuilding(250, 70, 11); DrawBuilding(400, 130, 4);
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawBuilding(int x, int width, int floors){ int height = floors * 30; int top = 400 - height;
Raylib.DrawRectangle(x, top, width, height, Color.Gray);
for (int floor = 0; floor < floors; floor++) { for (int col = 0; col < width / 30; col++) { Raylib.DrawRectangle(x + 10 + col * 30, top + 8 + floor * 30, 15, 15, Color.Yellow); } }}DrawBuilding a fourth parameter, Color lights, and use it for the windows instead of Color.Yellow. A call then looks like this: DrawBuilding(420, 90, 8, Color.Orange);Color.Gold, Color.SkyBlue, Color.Orange, Color.Pink, and more.x plus its width tells you where the next one can start.#:package Raylib-cs@8.0.0
using Raylib_cs;
Raylib.InitWindow(800, 450, "Skyline");Raylib.SetTargetFPS(60);
while (!Raylib.WindowShouldClose()){ Raylib.BeginDrawing(); Raylib.ClearBackground(Color.DarkBlue); Raylib.DrawRectangle(0, 400, 800, 50, Color.Black);
DrawBuilding(80, 100, 6); DrawBuilding(250, 70, 11); DrawBuilding(400, 130, 4);
// Task 3: give DrawBuilding a fourth parameter, Color lights, for the // windows. Then replace these three buildings with a skyline of at // least six, at least two different heights and two different colors.
Raylib.EndDrawing();}
Raylib.CloseWindow();
void DrawBuilding(int x, int width, int floors){ int height = floors * 30; int top = 400 - height;
Raylib.DrawRectangle(x, top, width, height, Color.Gray);
for (int floor = 0; floor < floors; floor++) { for (int col = 0; col < width / 30; col++) { Raylib.DrawRectangle(x + 10 + col * 30, top + 8 + floor * 30, 15, 15, Color.Yellow); } }}Two changes, made to a copy of your Task 2 program, one at a time. Screenshot or describe what you see each time, and put it back before the next.
DrawBuilding's outer loop, change floor < floors to floor < 5.DrawBuilding(80, 6, 100);.Neither change gives an error. For each one, say what is wrong with the picture, building by building, and which number the method used that it should not have. Number 1 has something in the street that should not be there.
bool antenna parameter. When it is true, draw an antenna on the roof: a line straight up from the middle of the roof, 40 pixels tall, with a small red light on top.Raylib.DrawLine(x1, y1, x2, y2, color) draws a line between two points. The middle of the roof is x + width / 2, and the roof is at top.Your two broken versions from Task 4 should look like this. If yours looked different, you changed something else as well.

Task 4, change 1 — the loop ignores floors

Task 4, change 2 — width and floors swapped
DrawBuilding method draws every building, and it is below the main programAnswer the following questions before submitting your work.
DrawBuilding parameters affects functionality, and how would you prove it to someone in ten seconds?Raylib.DrawRectangle takes parameters too, and you have called it since Lab 1. Explain why the Create task would not count it as a student-developed procedure, when it would count DrawBuilding.Submit four things to the dropbox: