Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Weapons_test.h
00001 #ifndef WEAPONS_TEST_H 00002 #define WEAPONS_TEST_H 00003 00004 /** Weapons Test 00005 * @brief Checks that the weapons draws 00006 * @author Benjamin Evans, University of Leeds 00007 * @date May 2020 00008 * @return true if test are passed 00009 */ 00010 bool weapons_draw_test(int expected_pixel_status,bool direction, 00011 int bullet_movement, int expected_postion_x, int expected_postion_y) { 00012 // Objects required for test 00013 Weapons bullet; 00014 Spaceship spaceship; 00015 N5110 lcd; 00016 00017 // Initialise objects for test 00018 spaceship.init(); 00019 lcd.init(); 00020 bullet.init(spaceship.get_pos(), direction, true); 00021 00022 printf("draw_bullet = %d,%d : ", expected_postion_x, expected_postion_y); 00023 00024 // Draws bullet in different positions 00025 for(int i = 0;i <= bullet_movement; i++) { 00026 bullet.draw_bullet(lcd); 00027 } 00028 00029 // Reads pixel where bullet is expected to be drawn 00030 int actual_pixel_status = lcd.getPixel(expected_postion_x, 00031 expected_postion_y); 00032 00033 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen 00034 if (actual_pixel_status) { 00035 printf ( "Passed!\n"); 00036 return true; 00037 } else { 00038 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status, 00039 expected_pixel_status); 00040 return false; 00041 } 00042 } 00043 00044 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2