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.
Fork of fy15raf by
Asteroid-test.h
00001 #ifndef Asteroid_TEST_H 00002 #define Asteroid_TEST_H 00003 00004 00005 bool Asteroid_movement() 00006 { 00007 00008 Asteroid A1; 00009 A1.init(5); // initialise with speed =5 00010 00011 A1.update();//expecting x to move to the laft of the screen by 5 steps depending on the speed ((width- size )-5 ) 00012 00013 Vector2D read_A1_pos = A1.get_pos(); 00014 printf("Asteroid with speed 5 x= %f\n", read_A1_pos.x ); //no need for y position because it will be generated randomly 00015 00016 bool success_flag = true; 00017 00018 // Fail the test if the position after updating does not move or move with a wrong speed or direction 00019 if (read_A1_pos.x != WIDTH-5-5 ) { 00020 success_flag = false; 00021 } 00022 00023 00024 ///////////////another asteroid speed to be tested //////////////////////// 00025 00026 Asteroid A2; 00027 A2.init(3);// initialise with speed =3 00028 00029 A2.update();//expecting x to move to the laft of the screen by 3 steps depending on the speed ((width- size )-3 ) 00030 00031 Vector2D read_A2_pos = A2.get_pos(); 00032 printf("Asteroid with speed 3 x= %f\n", read_A2_pos.x); //no need for y position because it will be generated randomly 00033 00034 // Fail the test if the position after updating does not move or move with a wrong speed or direction 00035 if (read_A2_pos.x != WIDTH-5-3 ) { 00036 success_flag = false; 00037 } 00038 00039 00040 00041 00042 00043 00044 return success_flag; 00045 00046 } 00047 #endif
Generated on Thu Jul 14 2022 18:15:41 by
