Skip to content

Commit b84e311

Browse files
authored
Merge pull request #16 from JustinBoverhof/bugfix/drive_controls_patch
fixed error in Key up event
2 parents 57ef520 + 07fa2da commit b84e311

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/driveControls.jsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ class DriveControlPanel extends React.Component {
8888
if(this.props.drivingMode){
8989
if(this.controlMap[evt.key]){
9090
this.controlMap[evt.key].pressed = false
91-
if(this.controlMap[evt.key].fn == "back") this.x++;
92-
if(this.controlMap[evt.key].fn == "forward") this.x--;
93-
if(this.controlMap[evt.key].fn == "right") this.y++;
94-
if(this.controlMap[evt.key].fn == "left") this.y--;
95-
if(this.controlMap[evt.key].fn == "tright") this.t++;
96-
if(this.controlMap[evt.key].fn == "tleft") this.t--;
91+
if(this.controlMap[evt.key].fn == "back" && this.x < 1) this.x++;
92+
if(this.controlMap[evt.key].fn == "forward" && this.x > -1) this.x--;
93+
if(this.controlMap[evt.key].fn == "right" && this.y < 1) this.y++;
94+
if(this.controlMap[evt.key].fn == "left" && this.y > -1) this.y--;
95+
if(this.controlMap[evt.key].fn == "tright" && this.t < 1) this.t++;
96+
if(this.controlMap[evt.key].fn == "tleft" && this.t > -1) this.t--;
9797
}
9898

9999
// Stops robot if it finds that all keys have been lifted up, acts as a failsafe to above logic

0 commit comments

Comments
 (0)