Mochu Yao explorer game
Dependencies: mbed
Diff: Gameengine/Gameengine.cpp
- Revision:
- 34:66e37a0d59c3
- Parent:
- 33:ea83f08fa466
- Child:
- 35:3d4dd92bc82b
diff -r ea83f08fa466 -r 66e37a0d59c3 Gameengine/Gameengine.cpp --- a/Gameengine/Gameengine.cpp Wed Apr 29 13:28:41 2020 +0000 +++ b/Gameengine/Gameengine.cpp Wed Apr 29 13:43:20 2020 +0000 @@ -54,25 +54,24 @@ { _player.fall(_f_flag, gamepad); } else { - _player.set_y_coordinate(X_flag, _jump_height); } + _player.set_y_coordinate(X_flag, _jump_height, _y_flag); } _f_flag = _player.get_fall_flag(); _player_y = _player.get_y(); _jump_height = _player.get_jump_height(); } void Gameengine::set_fall_flag() { - if (((set_line_1.right < _player_x) && (_player_x < (set_line_1.left - 5))) && _player_y == 20) { + if (((set_line_1.right < _player_x) && (_player_x < (set_line_1.left - 5))) && _player_y == 23) { _f_flag = true; } - else if (((set_line_2.right < _player_x) && (_player_x < (set_line_2.left - 5))) && _player_y == 20) { + else if (((set_line_2.right < _player_x) && (_player_x < (set_line_2.left - 5))) && _player_y == 23) { _f_flag = true; } - else if (((set_line_3.right < _player_x) && (_player_x < (set_line_3.left - 5))) && _player_y == 20) { + else if (((set_line_3.right < _player_x) && (_player_x < (set_line_3.left - 5))) && _player_y == 23) { _f_flag = true; } else if ((_player_x <= 0) && (_player_x >= 80)) { _f_flag = true; } } void Gameengine::check_collision(Gamepad &gamepad) { - if ((_player_x == _item.get_item_x()-3) - && (_player_y == _item.get_item_y() - 5)) { + if ((_player_x - _item.get_item_x()) < 5) && ((_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