Mochu Yao explorer game
Dependencies: mbed
Diff: item/item.h
- Revision:
- 31:8e92b65e0779
- Parent:
- 28:4a1260ad0346
- Child:
- 32:47d98959b4ef
diff -r 65e639ace415 -r 8e92b65e0779 item/item.h --- a/item/item.h Wed Apr 29 03:18:13 2020 +0000 +++ b/item/item.h Wed Apr 29 04:49:10 2020 +0000 @@ -31,13 +31,12 @@ srand(time(NULL));// generate random values _player_score = 0;// set player score to 0; _player_x = 40; - _player_y = 10;//make sure they are not in the same position at first,but player on the underlevel + _player_y = 25;//make sure they are not in the same position at first,but player on the underlevel while(1) { // becasue the module of the player is big so it has to be make sure that //the item will be collected when the edge of the module collide with the item - if ((_player_x == _item.get_item_x() - && (_player_y == _item.get_item_y() - 8)) { + if (abs((_player_x - _item.get_item_x())= 5 && abs((_player_y - _item.get_item_y() = 5))) { _collision_flag = true; _player_score++; _item.set_item(((rand()%80)+ 5) , ((rand()%80)+ 5)); // use the rand()%m function to generate a number from 80 to 1