Question:
I have a function that is supposed to spawn mobs, but it’s not working.
Repl link:
replit.com/@element1010/Bean-Defense#code/main.ts
loop(1, () => {
let comps = [];
let choice = randi(4);
switch(choice) {
case 0:
add([
sprite("apple"),
pos(width(), rand(height())),
"apple"
]);
break;
case 1:
add([
sprite("coin"),
pos(width(), rand(height())),
"coin"
]);
break;
case 2:
let ghostChoice = randi(4);
//comps.push(sprite("ghosty"), "ghost");
switch(ghostChoice) {
case 0:
add([
sprite("ghosty"),
pos(width(), rand(height())),
"ghost",
health(10),
{
size: "tiny"
}
]);
break;
case 1:
add([
sprite("ghosty"),
pos(width(), rand(height())),
"ghost",
health(20),
{
size: "small"
}
])
break;
case 2:
add([
sprite("ghosty"),
pos(width(), rand(height())),
"ghost",
health(35),
{
size: "medium"
}
])
break;
case 3:
add([
sprite("ghosty"),
pos(width(), rand(height())),
"ghost",
health(50),
{
size: "big"
}
]);
break;
}
break;
case 3:
add([
sprite("bag"),
pos(width(), rand(height())),
"bag",
health(75)
]);
break;
}
});