here is the code:
run it here
let score = 0
let dead = false
let difficulty = 1
let bopper = game.createSprite(2, 2)
let bopOne = game.createSprite(2,2)
//create bopper that follows tilt
function setBopper() {
bopper.set(LedSpriteProperty.Brightness, 125)
bopper.set(LedSpriteProperty.X, Math.map(input.acceleration(Dimension.X), -1023, 1023, 0, 4))
bopper.set(LedSpriteProperty.Y, Math.map(input.acceleration(Dimension.Y), -1023, 1023, 0, 4))
}
function bopBopped() {
//if bopper bopped the bop, add score, reset bop
if (bopper.isTouching(bopOne) == true) {
score = score + 1
}
basic.showNumber(score)
}
//input.onButtonPressed(Button.A, bopBopped)
basic.forever(function() {
//bop1 to random position
bopOne.set(LedSpriteProperty.X, 0)
bopOne.set(LedSpriteProperty.Y, 2)
basic.pause(1000)
})
basic.forever(function() {
setBopper()
if(input.buttonIsPressed(Button.A)) {
if (bopOne.isTouching(bopper) == true) {
score += 1
}
basic.showNumber(score)
}
})
I tried to print some text to see if the if statement asking if they were touching was working, but nothing came out. I don’t see why this doesn’t work since the led’s are on the same tile.