Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include #include void init(); void deinit(); int main() { init(); // while (!key[KEY_ESC]) { int x=100, y=100 , numdots = 1000; int i , ax[1000],
#include#include void init(); void deinit(); int main() { init(); // while (!key[KEY_ESC]) { int x=100, y=100 , numdots = 1000; int i , ax[1000], ay[1000]; for (i = 0 ; i <=numdots ; ++i ) { /* 1000 dots in random positions and random colors*/ x=rand()%1000 ; ax[i] = x; y=rand()%1000 ; ay[i] = y; putpixel(screen, x, y, makecol(255, 255, 255)); } for (i = 0 ; i <=numdots ; i++ ) { /* move pixels outward */ x= ax[i]; y= ay[i]; // to move star, kill where it was putpixel(screen, x, y, makecol(0, 0, 0 )); if (x < 1000/2 ) x-- ; //move star to the left else x++ ; //move star to the rightt if (y < 1000/2 ) y-- ; //move star upward else y++ ;//move star downward ax[i] = x; ay[i] = y; // x=rand()%1000 ; y=rand()%1000 ; putpixel(screen, x, y, makecol(255, 255, 255)); } system("pause"); } 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, 1000, 1000, 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 */ }
This program uses dev c++ and the code isnt working3
Make a star field as in Star Trek (the original series), like MS's screensaver. I want to fly! Hint: Store stars in an array. Erase when they move off screen and creat new stars in the middle of screenStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started