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.
Explosion_test.h
00001 #ifndef EXPLOSION_TEST_H 00002 #define EXPLOSION_TEST_H 00003 00004 /** EXPLOSION Test 00005 * @brief Checks explosion animation is drawn 00006 * @author Benjamin Evans, University of Leeds 00007 * @date May 2020 00008 * @return true if test are passed 00009 */ 00010 bool explosion_draw_test(int expected_pixel_status, int expected_postion_x, 00011 int expected_postion_y) { 00012 // Objects required for test 00013 Gamepad pad; 00014 Explosion explosion; 00015 N5110 lcd; 00016 00017 // Sets position of explosion 00018 Vector2D detroyed_pos = {expected_postion_x,expected_postion_y}; 00019 00020 // Initialise objects 00021 pad.init(); 00022 lcd.init(); 00023 explosion.init(detroyed_pos); 00024 00025 // Reads start spaceship position 00026 printf("explosion_draw x,y= %d,%d : ",expected_postion_x, 00027 expected_postion_y); 00028 00029 // Draws explosion 00030 explosion.draw_explosion(lcd); 00031 00032 // Reads pixel where explosion is expected to be drawn 00033 int actual_pixel_status = lcd.getPixel(expected_postion_x + 3, 00034 expected_postion_y + 3); 00035 00036 // Checks if pixel is drawn and therefor testing if it has gone of screen 00037 if (actual_pixel_status == expected_pixel_status) { 00038 printf ( "Passed!\n"); 00039 return true; 00040 } else { 00041 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status, 00042 expected_pixel_status); 00043 return false; 00044 } 00045 } 00046 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2