一個 MakeCode 專案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

80 lines
2.9 KiB

controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
projectile = sprites.createProjectileFromSprite(img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . 7 7 . . . . . . .
. . . . . . . 7 7 . . . . . . .
. . . . . . . 7 7 . . . . . . .
. . . . . . . 7 7 . . . . . . .
. . . . . . . 7 7 . . . . . . .
`, mySprite, 0, -60)
music.pewPew.play()
})
sprites.onOverlap(SpriteKind.Enemy, SpriteKind.Projectile, function (sprite, otherSprite) {
otherSprite.destroy()
sprite.destroy(effects.disintegrate, 500)
info.changeScoreBy(1)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
otherSprite.destroy(effects.fire, 500)
scene.cameraShake(4, 500)
info.changeLifeBy(-1)
})
let projectile2: Sprite = null
let projectile: Sprite = null
let mySprite: Sprite = null
info.setScore(0)
info.setLife(3)
effects.starField.startScreenEffect()
mySprite = sprites.create(img`
. . . . . . . c d . . . . . . .
. . . . . . . c d . . . . . . .
. . . . . . . c d . . . . . . .
. . . . . . . c b . . . . . . .
. . . . . . . f f . . . . . . .
. . . . . . . c 7 . . . . . . .
. . . . . . . f f . . . . . . .
. . . . . . . 8 7 . . . . . . .
. . . . . . 8 8 5 6 . . . . . .
. . . . . . 8 7 5 6 . . . . . .
. . . . . c c c 6 6 6 . . . . .
. . . . 8 8 7 7 7 5 6 6 . . . .
. . 8 f f f c c 6 6 f f 6 6 . .
. 8 8 8 8 6 6 7 7 7 7 5 7 6 6 .
8 8 8 8 8 8 6 6 7 7 7 5 7 7 6 6
8 8 8 8 8 8 6 6 7 7 7 7 5 7 6 6
`, SpriteKind.Player)
mySprite.setPosition(76, 108)
controller.moveSprite(mySprite)
mySprite.setStayInScreen(true)
game.onUpdateInterval(1000, function () {
projectile2 = sprites.createProjectileFromSide(img`
. . . . . . . . . c c 8 . . . .
. . . . . . 8 c c c f 8 c c . .
. . . c c 8 8 f c a f f f c c .
. . c c c f f f c a a f f c c c
8 c c c f f f f c c a a c 8 c c
c c c b f f f 8 a c c a a a c c
c a a b b 8 a b c c c c c c c c
a f c a a b b a c c c c c f f c
a 8 f c a a c c a c a c f f f c
c a 8 a a c c c c a a f f f 8 a
. a c a a c f f a a b 8 f f c a
. . c c b a f f f a b b c c 6 c
. . . c b b a f f 6 6 a b 6 c .
. . . c c b b b 6 6 a c c c c .
. . . . c c a b b c c c . . . .
. . . . . c c c c c c . . . . .
`, 0, randint(30, 60))
projectile2.setKind(SpriteKind.Enemy)
projectile2.x = randint(0, scene.screenWidth())
})