Advertisement
ChaOSzz

Untitled

Jun 12th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. let x = 0
  2. let y = 0
  3.  
  4. let px = 0
  5. let py = 0
  6. let score = 0
  7. let PastTime = 0
  8. basic.forever(function () {
  9. basic.clearScreen()
  10. led.plot(x, y)
  11. led.plot(px, py)
  12.  
  13. if(control.millis() - PastTime > 3000)
  14. {
  15. PastTime = control.millis()
  16. px = randint(0, 4)
  17. py = randint(0, 4)
  18. }
  19.  
  20. if(x == px && y == py)
  21. {
  22. px = randint(0,4)
  23. py = randint(0,4)
  24. score++
  25. console.log(score)
  26. }
  27.  
  28. if(input.buttonIsPressed(Button.B))
  29. {
  30. if(x<4) x++
  31. }
  32. if(input.buttonIsPressed(Button.A))
  33. {
  34. if(x>0) x--
  35. }
  36. if(input.pinIsPressed(TouchPin.P0))
  37. {
  38. if(y<4) y++
  39. }
  40. if(input.pinIsPressed(TouchPin.P1))
  41. {
  42. if(y>0) y--
  43. }
  44. basic.pause(200)
  45. })
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement