#Can somebody correct my code?

5 messages · Page 1 of 1 (latest)

spare zinc
#

#include <iostream>
#include "splashkit.h"

void draw_star(color clr, double x, double y, int width, int height) {
int x2 = x + width;
int y2 = y + height;
int left_x = x - width;
int mid_y = y + height / 2;
int mid_x = x + width / 2;
int right_x = x2 + width;
int top_y = y - height;
int bottom_y = y2 + height;

fill_rectangle(clr, x, y, width, height);
fill_triangle(clr, left_x, mid_y, x, y, x, y2);
fill_triangle(clr, mid_x, top_y, x, y, x2, y);
fill_triangle(clr, right_x, mid_y, x2, y, x2, y2);
fill_triangle(clr, mid_x, bottom_y, x, y2, x2, y2);

}

int main() {
open_window("Stars", 800, 600); // Increase window size
int row = 1;
while (row <= 10) {
int column = 1;
while (column <= row) {
color random_color = rgb_color(rand() % 256, rand() % 256, rand() % 256);
draw_star(random_color, column * 70, row * 70, 30, 30);
column++;
}
row++;
}

delay(5000);
return 0;

}

idk what I did wrong it doesn't show anything
This is the output that I have to execute

vestal mossBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

cobalt crescent
#
  1. The screen size is 800x600, I think the last rows of stars would go out of screen.
  2. For draw stars you make x and y in the parameter double but then give them int values as arguments
cobalt crescent
#

np, can you see anything now or is your output still empty?