
Final Commit
Dependencies: mbed
Food/Food-test.h
- Committer:
- JRM1986
- Date:
- 2018-05-08
- Revision:
- 27:bd0f69a75d8b
- Parent:
- 25:f03439ee32c6
File content as of revision 27:bd0f69a75d8b:
#ifndef FOOD_TEST_H #define FOOD_TEST_H /** * \brief Check that food changes position within game area * * \returns true if all the tests passed */ bool food_test_position() { Food food; int i; int frame_count = g_fc; // initialise food with a collision food.set_food_position(1,1,true); // get a random position Vector2D rand_pos = food.get_rand_pos(); printf("%f, %f \n", rand_pos.x, rand_pos.y); bool success_flag = true; // if the random position is within the screen boundaries return true if((0 >= rand_pos.x >= 83) && (0 >= rand_pos.y >= 47)) { success_flag = false; } for(i = 0; i <=1; i++) { // check update method food.update(true, 0); // get new positions wait(1.0); Vector2D rand_pos_1 = food.get_rand_pos(); printf("%f, %f \n", rand_pos_1.x, rand_pos_1.y); if((rand_pos.x == rand_pos_1.x) && (rand_pos.y == rand_pos_1.y)) { success_flag = false; } printf("%i\n", frame_count); } // check counter increments in update if(frame_count != 0) { success_flag = false; } return success_flag; } #endif