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.
Diff: Weapons/Weapons_test.h
- Revision:
- 23:cc44e26c08fa
- Child:
- 27:8bb2bd97c319
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Weapons/Weapons_test.h Wed May 06 12:15:16 2020 +0000 @@ -0,0 +1,42 @@ +#ifndef WEAPONS_TEST_H +#define WEAPONS_TEST_H + +/** Weapons Test +@brief Checks that the weapons draws +@author Benjamin Evans, University of Leeds +@date May 2020 +@return true if test are passed +*/ + +bool weapons_draw_test(int expected_pixel_status,bool direction, int bullet_movement, int expected_postion_x, int expected_postion_y){ + // Objects reqired for test + Weapons bullet; + Spaceship spaceship; + N5110 lcd; + + // Initialise objects for tets + spaceship.init(); + lcd.init(); + bullet.init(spaceship.get_pos(), direction); + + printf("draw_bullet = %d,%d : ", expected_postion_x, expected_postion_y); + + //Draws bullet in different posisions + for(int i = 0;i <= bullet_movement; i++){ + bullet.draw_bullet(lcd); + } + + // Reads pixel where bullet is expected to be drawn + int actual_pixel_status = lcd.getPixel(expected_postion_x, expected_postion_y); + + // Checks if pixel is drawn and therefor testing it hasnt gone of screen + if (actual_pixel_status) { + printf ( "Passed!\n"); + return true; + } else { + printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status, expected_pixel_status); + return false; + } +} + +#endif \ No newline at end of file