Question
#include #include #include #include #include #define DELAY 10 /* milliseconds */ bool game_over = false; bool update_screen = true; // (a) Declare a global sprite_id
#include
#define DELAY 10 /* milliseconds */
bool game_over = false; bool update_screen = true;
// (a) Declare a global sprite_id called bomb;
void setup(void) { // (b) Initialise the bomb to display a 1x1 image consisting of a string // containing a single 'o' character. The sprite should appear at // initial location (12,15).
// (c) Declare a double precision floating point variable called dx // and set it equal to the difference between the x-coordinate of the // star and that of the bomb.
// (d) Declare a double precision floating point variable called dy // and set it equal to the difference between the y-coordinate of the // star and that of the bomb.
// (e) Declare a double precision floating point value called dist // and set it equal to the distance between the bomb and the star. // The distance can be calculated using dx and dy, and applying the // Theorem of Pythagoras. // Hint: the right-hand side of the assignment statement should look // like this: sqrt( dx * dx + dy * dy );
// (f) Multiply dx by the desired speed, then divide it by the distance.
// (g) Do the same to dy. // (h) Turn the bomb to move towards the star. This involves dx and dy.
// (i) Draw the bomb.
// (j) Draw the star at its designated location, (74,7). }
// Play one turn of game. void process(void) { // Keep the next line intact. clear_screen();
// (k) Move the bomb forward one step.
// (l) Draw the bomb.
// (m) Draw the star at its designated location, (74,7).
// (n) Get the position of the bomb on the screen, and compare it to the // location of the star. If they are both the same, set game_over true. }
// Clean up game void cleanup(void) { // STATEMENTS }
// Program entry point. int main(void) { setup_screen();
#if defined(AUTO_SAVE_SCREEN) auto_save_screen(true); #endif
setup(); show_screen();
while ( !game_over ) { process();
if ( update_screen ) { show_screen(); }
timer_pause(DELAY); }
cleanup();
return 0; }
Complete the implementation of the shooting_star program. This program simulates the flight of an object along a straight line between two points. The hash-tags for this exercise are: #ca0202 and #cab202ShootingStar lhis exercise will give you further practice with collision detection and help you learn how to direct an object along a path between two points in a two-dimensional space In this program, you will use a sprite to represent the location of a bomb which, after launching from position (12,15), flies straight toward a star which is located at (74,7) at a speed of 0.3 screen units per time-step. To complete the program, follow the instructions detailed in the in-line comments in the setup() and process() functions Notes . The supplied test driver produces output similar lo that shown below. /cygdrive/a/AMS/AMS_2017/CAB202/ExerciseDevelopment/Topic03_Advancedif_For/Exer 0 A ZDK Movie that captures the fe ycle of the running program is available to download here. The movie can be viewed using the on-line viewer at http:/sefams01.qut.edu.au CAB202MoviePlayer: Index.html . The sample image and movie were generated with the settings listed in the "Movie Value" column in the table below. The settings you should use in your submission are listed in the Your Valuc column. Parameter Terminal width 79 Terminal height 29 Initial bombx 17 Inilial bomby 13 Star X Star y Bomb speed 0.15 units per time step 0.3 ts per time step Movie Value Your Value n/a set by AMS n/a set by AMS 12 15 74 58 If you would like to record your own ZDK Movie to compare the frames against the reference movie, add the following option to your gcc command: -DAUTO_SAVE_SCREEN This will enable the auto-save function in the test driver, causing it to produce a text file containing your movie. The file will be created in your present orking directory Each time the program runs, a new file is generated. Complete the implementation of the shooting_star program. This program simulates the flight of an object along a straight line between two points. The hash-tags for this exercise are: #ca0202 and #cab202ShootingStar lhis exercise will give you further practice with collision detection and help you learn how to direct an object along a path between two points in a two-dimensional space In this program, you will use a sprite to represent the location of a bomb which, after launching from position (12,15), flies straight toward a star which is located at (74,7) at a speed of 0.3 screen units per time-step. To complete the program, follow the instructions detailed in the in-line comments in the setup() and process() functions Notes . The supplied test driver produces output similar lo that shown below. /cygdrive/a/AMS/AMS_2017/CAB202/ExerciseDevelopment/Topic03_Advancedif_For/Exer 0 A ZDK Movie that captures the fe ycle of the running program is available to download here. The movie can be viewed using the on-line viewer at http:/sefams01.qut.edu.au CAB202MoviePlayer: Index.html . The sample image and movie were generated with the settings listed in the "Movie Value" column in the table below. The settings you should use in your submission are listed in the Your Valuc column. Parameter Terminal width 79 Terminal height 29 Initial bombx 17 Inilial bomby 13 Star X Star y Bomb speed 0.15 units per time step 0.3 ts per time step Movie Value Your Value n/a set by AMS n/a set by AMS 12 15 74 58 If you would like to record your own ZDK Movie to compare the frames against the reference movie, add the following option to your gcc command: -DAUTO_SAVE_SCREEN This will enable the auto-save function in the test driver, causing it to produce a text file containing your movie. The file will be created in your present orking directory Each time the program runs, a new file is generatedStep 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