Skip to content

Commit

Permalink
Added attack routine function block
Browse files Browse the repository at this point in the history
  • Loading branch information
noqman committed Nov 15, 2024
1 parent e4ad943 commit 42dfc94
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions robot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum SumobitDirection {

};

enum SumobitTesting {
enum SumobitAttack{

//% block="testing"
Test = 0,
Expand Down Expand Up @@ -122,9 +122,47 @@ namespace sumobit {
//% block="attack %mode"
//% second.fieldOptions.decompileLiterals=true
//% advanced=true
export function attack(mode: SumobitTesting): void {
export function attack(mode: SumobitAttack): void {
let speed = sumobitInitialSpeed

switch(mode){
case SumobitAttack.Test:
if (oppSensorDetection(2)) {

} else if (oppSensorDetection(0)) {
sumobit.setMotorsSpeed(0, speed, 9)
basic.pause(300)
} else if (oppSensorDetection(4)) {
sumobit.setMotorsSpeed(speed, 0, 9)
basic.pause(300)
} else if (oppSensorDetection(1)) {
sumobit.setMotorsSpeed(speed * 0.5, speed, 9)
basic.pause(100)
} else if (oppSensorDetection(2)) {
sumobit.setMotorsSpeed(speed, speed * 0.5, 9)
basic.pause(100)
}


case SumobitAttack.Game:
if (oppSensorDetection(2)) {
sumobit.setMotorsSpeed(speed, speed,9)
} else if (oppSensorDetection(0)) {
sumobit.setMotorsSpeed(0, speed,9)
basic.pause(300)
} else if (oppSensorDetection(4)) {
sumobit.setMotorsSpeed(speed, 0, 9)
basic.pause(300)
} else if (oppSensorDetection(1)) {
sumobit.setMotorsSpeed(speed*0.5, speed, 9)
basic.pause(100)
} else if (oppSensorDetection(2)) {
sumobit.setMotorsSpeed(speed, speed*0.5, 9)
basic.pause(100)
}

}

}


Expand Down

0 comments on commit 42dfc94

Please sign in to comment.