0

i am using replit and on replit Kaboom please tell me if you know any fixes i have done many many many things and can not fix it PLEASE HELP ME code is below

import kaboom from "kaboom"

// initialize context
kaboom()

// load assets
loadSprite("Soldier", "sprites/Soldier.png")

// add a character to screen
add([
    // list of components
    sprite("Soldier"),
    pos(80, 40),
    area(),
        body()
])
// add platform
add([
rect(width(), 48),
pos(0, height() - 48),
outline(4),
area(),
solid(),
color(170, 150, 0),
])
onKeyPress("space", () => {
  Soldier.jump()
})

// burp on "b"
onKeyPress("b", burp)

I have not been able to find out anything

1 Answers1

1

Assign the value from add, otherwise Soldier will not be defined:

const Soldier = add([
  // ...
])

(Also, naming it Soldier goes against programming style; though it is not an error as such, const soldier = add... and soldier.jump() would be better.)

Amadan
  • 191,408
  • 23
  • 240
  • 301