-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ts
28 lines (26 loc) · 953 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const numRuns: number = 5
let currRun: number = 1
let beginSprite: Sprite = sprites.create(sprites.castle.skellyFront, 1)
let endSprite: Sprite = sprites.create(sprites.food.smallBurger, 2)
resetBoard()
sprites.onOverlap(1, 2, function (sprite: Sprite, otherSprite: Sprite) {
sprite.say(":)")
sprite.vx = 0
sprite.vy = 0
loops.pause(1000)
currRun++
if (currRun <= numRuns) {
resetBoard()
} // if (currRun <= numRuns)
}) // sprites.onOverlap(1, 2, ...)
function resetBoard() {
beginSprite.say("")
beginSprite.x = Math.randomRange(0, screen.width)
beginSprite.y = Math.randomRange(0, screen.height)
endSprite.x = Math.randomRange(0, screen.width)
endSprite.y = Math.randomRange(0, screen.height)
let vector: Vector =
vectorMath.createVectorFromSprites(beginSprite, endSprite)
beginSprite.vx = vector.x
beginSprite.vy = vector.y
} // resetBoard()