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: 4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed
Diff: hockey/hockey.cpp
- Revision:
- 23:214c0c828d98
- Parent:
- 20:73e4f12277bd
- Child:
- 26:163d7ca8c42d
--- a/hockey/hockey.cpp Tue Dec 06 22:48:35 2022 +0000 +++ b/hockey/hockey.cpp Wed Dec 07 23:12:12 2022 +0000 @@ -40,7 +40,6 @@ #define _HOCKEY_GOAL_BOT (_HOCKEY_GOAL_TOP + HOCKEY_GOAL_HEIGHT) - PhysicsBody puck; PhysicsBody paddle_a; PhysicsBody paddle_b; @@ -335,20 +334,23 @@ SetPhysicsBodyRotation(paddle_a, paddle_a->orient + input_sensitivity * 0.05); } + + + // Player 2 Input - if (!(navSwitch & 0b00001)) { // Up + if (myNav.up()) { // Up paddle_b->position.y -= input_sensitivity; } - if (!(navSwitch & 0b01000)) { // down + if (myNav.down()) { // down paddle_b->position.y += input_sensitivity; } - if (!(navSwitch & 0b00100)) { // left + if (myNav.left()) { // left paddle_b->position.x -= input_sensitivity; } - if (!(navSwitch & 0b10000)) { // right + if (myNav.right()) { // right paddle_b->position.x += input_sensitivity; } - if (!(navSwitch & 0b00010)) { // rotate + if (myNav.fire()) { // rotate SetPhysicsBodyRotation(paddle_b, paddle_b->orient + 3.14159 / 4); }