As a follow-up, here is my (JS) code that won’t convert to blocks:
enum ActionKind {
Walking,
Idle,
Jumping
}
controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
animation.runImageAnimation(
mySprite,
assets.animation`animWalkLeft`,
250,
true
)
})
controller.right.onEvent(ControllerButtonEvent.Pressed, function () {
animation.runImageAnimation(
mySprite,
assets.animation`animWalkRight`,
250,
true
)
})
let enemy: Sprite = null
function spawnEnemy() {
enemy = sprites.create(assets.image`spriteGhrasto`, SpriteKind.Enemy)
tiles.placeOnTile(enemy, tiles.getTileLocation(2, 7))
enemy.follow(mySprite, 20)
}
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
sprites.destroy(otherSprite, effects.spray, 500)
info.changeScoreBy(1)
scene.cameraShake(4, 500)
music.play(music.randomizeSound(music.createSoundEffect(WaveShape.Noise, 5000, 1877, 255, 0, 500, SoundExpressionEffect.Warble, InterpolationCurve.Logarithmic)), music.PlaybackMode.UntilDone)
})
let mySprite: Sprite = null
scene.setBackgroundColor(15)
game.setDialogTextColor(2)
game.splash("Title")
game.setDialogTextColor(9)
game.splash("Dev Name")
scene.setBackgroundColor(9)
scene.createRenderable(scene.HUD_Z, function (target, camera) {
const w = 40
const h = 15
const x = 2
const y = 2
// Draw outline
screen.drawRect(
x,
y,
w,
h,
/** black **/ 0x0
)
// Fill inside rect
screen.fillRect(
x + 1,
y + 1,
w - 2,
h - 2,
/** black **/ 0x0
)
// Fill it in with whatever else you want
// text
let t = info.score()
screen.print(
" " + t.toString(),
x + 2,
y + 4,
/** white **/ 0x1,
image.font8
)
// or an image
screen.drawTransparentImage(
img`
. . b . b . b
. b b b b b .
b . . b . . b
b . . b . . b
b b b b b b b
. b . b . b .
. . . . . . .
. . b b b . .
`,
// if you want to space text horizontally,
// note the t.length * image.font8.charWidth to
// get the width of the text below
x + 2,
y + 4
)
})
tiles.setCurrentTilemap(tilemap`roomBathDoomArena`)
mySprite = sprites.create(assets.image`Ducky`, SpriteKind.Player)
tiles.placeOnTile(mySprite, tiles.getTileLocation(4, 3))
animation.runImageAnimation(
mySprite,
assets.animation`animWalkRight`,
500,
true
)
game.onUpdate(function () {
scene.cameraFollowSprite(mySprite)
controller.moveSprite(mySprite, 50, 50)
})
game.onUpdateInterval(5000, function () {
spawnEnemy()
})