KRITSADA

Run in Background Example

Jan 17th, 2018
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let x3: game.LedSprite = null
  2. let x1: game.LedSprite = null
  3. let x2: game.LedSprite = null
  4. x2 = game.createSprite(2, 1)
  5. x1 = game.createSprite(2, 2)
  6. x3 = game.createSprite(1, 2)
  7. x2.turn(Direction.Right, 45)
  8. x2.turn(Direction.Left, 90)
  9. x3.turn(Direction.Right, 45)
  10. control.inBackground(() => {
  11.     while (true) {
  12.         x2.move(1)
  13.         x2.ifOnEdgeBounce()
  14.         basic.pause(100)
  15.     }
  16. })
  17. control.inBackground(() => {
  18.     while (true) {
  19.         x1.move(2)
  20.         x1.ifOnEdgeBounce()
  21.         basic.pause(100)
  22.     }
  23. })
  24. control.inBackground(() => {
  25.     while (true) {
  26.         x3.move(1)
  27.         x3.ifOnEdgeBounce()
  28.         basic.pause(100)
  29.     }
  30. })
Advertisement
Add Comment
Please, Sign In to add comment