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.
Dependencies: mbed
Food-test.h
00001 #ifndef FOOD_TEST_H 00002 #define FOOD_TEST_H 00003 00004 /** 00005 * \brief Check that food changes position within game area 00006 * 00007 * \returns true if all the tests passed 00008 */ 00009 00010 bool food_test_position() 00011 { 00012 00013 Food food; 00014 int i; 00015 int frame_count = g_fc; 00016 00017 // initialise food with a collision 00018 food.set_food_position(1,1,true); 00019 00020 // get a random position 00021 00022 Vector2D rand_pos = food.get_rand_pos(); 00023 printf("%f, %f \n", rand_pos.x, rand_pos.y); 00024 00025 bool success_flag = true; 00026 00027 // if the random position is within the screen boundaries return true 00028 00029 if((0 >= rand_pos.x >= 83) && (0 >= rand_pos.y >= 47)) { 00030 00031 success_flag = false; 00032 00033 } 00034 00035 for(i = 0; i <=1; i++) { 00036 00037 // check update method 00038 00039 food.update(true, 0); 00040 00041 // get new positions 00042 wait(1.0); 00043 Vector2D rand_pos_1 = food.get_rand_pos(); 00044 printf("%f, %f \n", rand_pos_1.x, rand_pos_1.y); 00045 00046 if((rand_pos.x == rand_pos_1.x) && (rand_pos.y == rand_pos_1.y)) { 00047 00048 success_flag = false; 00049 00050 } 00051 00052 00053 printf("%i\n", frame_count); 00054 00055 } 00056 00057 // check counter increments in update 00058 00059 if(frame_count != 0) { 00060 00061 success_flag = false; 00062 00063 } 00064 00065 00066 return success_flag; 00067 00068 } 00069 00070 #endif
Generated on Wed Aug 3 2022 05:55:53 by
1.7.2