Answered step by step
Verified Expert Solution
Link Copied!

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 */ } student submitted image, transcription available below

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 screen

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions