Question: i cant fix the errors. i am using c++ allegro btw #include #include #include void init(); void deinit(); void param_house(int width, int height, int roof_height,

i cant fix the errors. i am using c++ allegro btw
#include
void init(); void deinit(); void param_house(int width, int height, int roof_height, int door_height, int door_width, int wall_color, int roof_color, int door_color);
int main() { init();
srand(time(NULL)); // initialize random seed
while (!key[KEY_ESC]) { clear_to_color(screen, makecol(0, 0, 255)); // blue sky rectfill(screen, 0, 599, 799, 200, makecol(0, 255, 0)); // green lawn
int x = 50, y = 350; int min_distance = 150; // minimum distance between houses
// generate random houses for (int i = 0; i
// check for collision with previous houses int collided = 0; for (int j = 0; j
// draw house if no collision if (!collided) { param_house(x, y, width, height, roof_height, door_height, door_width, wall_color, roof_color, door_color); }
// move to next house position x += min_distance + width; }
rest(50); // sleep for 50 ms to avoid high CPU usage }
deinit(); return 0; } END_OF_MAIN()
void init() { int depth, res; allegro_init(); depth = desktop_color_depth(); if (depth == 0) depth = 32; set_color_depth(depth); res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0); if (res != 0) { allegro_message(allegro_error); exit(-1); }
install_timer(); install_keyboard(); install_mouse(); /* add other initializations here */ }
void deinit() { clear_keybuf(); /* add other deinitializations here */ }
void param_house(int x, int y, int width, int height, int roof_height, int door_height, int door_width, int wall_color, int roof_color, int door_color) { int roof[] = { x, y - roof_height, x + width, y - roof_height, x + width * 0.8, y - roof_height - width * 0.3, x + width * 0.2, y - roof_height - width * 0 };
int wall[] = { x, y, x + width, y, x + width, y - height, x, y - height }; int door[] = { x + width / 2 - door_width / 2, y, x + width / 2 + door_width / 2, y, x + width / 2 + door_width / 2, y - door_height, x + width / 2 - door_width / 2, y - door_height };
// draw roof triangle(screen, roof[0], roof[1], roof[2], roof[3], roof[4], roof[5], roof_color); triangle(screen, roof[0], roof[1], roof[6], roof[7], roof[4], roof[5], roof_color);
// draw wall rectfill(screen, wall[0], wall[1], wall[2], wall[5], wall_color);
// draw door rectfill(screen, door[0], door[1], door[2], door[5], door_color); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
