Im stuck on level 11 game development 2

I call that the BSON…blank screen of nothing. Usually, simply doing a hard refresh (control + F5) will resolve, but I seem to remember having to close and restart my browser, at least once to fix the issue.

The only issue I see is:

        # Increase game.throwerSpawnTime by 9:
        game.throwerSpawnTime = game.muchkinSpawnTime + 6

But, there is also the final two statements, which are not needed. However, since they are not indented, they are not a part of the while true loop, so will never fire anyway.

I just added the extra hp and dmg because my computer is somewhat slower and so killing the enemies can be more difficult on here. Thanks for pointing out the + 6 time instead of + 9. I will try changing that and removing the last two lines of code and see if that solves the problem.

Now instead of getting any errors or bson ect, the throwers are not spawning at all. (with changes applied)

heh…I’m a slow clicker, so I did the same, but did it right after spawning the player.

If you hate typing like me, don’t forget that you can increase a variable by using +=…

You must have something else going on then. I copied your code, made the += 9 change and it worked fine.

Well since the other parts of the code are working let’s pinpoint the throwers code.

# This spawns two aggressive throwers.
def spawnThrowers():
    thrower1 = game.spawnXY("thrower", 2, 16)
    thrower1.behavior = "AttacksNearest"
    thrower2 = game.spawnXY("thrower", 2, 52)
    thrower2.behavior = "AttacksNearest"
    if game.Time > game.throwerSpawnTime:
        # Increase game.throwerSpawnTime by 9:
        game.throwerSpawnTime = game.muchkinSpawnTime + 9
        # Call the spawnThrowers function:
        spawnThrowers()
    # Update the UI timer until the next potion
    game.nextPotionIn = game.potionSpawnTime - game.time

I think I may have found it. I re-copied your code from your original post, made no changes and got the BSON. I deleted the two lines at the bottom and the hero showed up…the code ran. Made the += 9 change and it looks like it worked…hero died and I did not bother buffing him up any.

Ill try restarting my browser.

I restarted my browser and ran the code but the same result. Did the throwers spawn when you tried it?

found the problem! I had munchkin in place of thrower on one of the spawn commands. Thanks!

Well it appears I spoke too soon. Same problem where the throwers spawn but I can go through the level just fine fighting the munchkins. This is just weird.

# Use timers to spawn enemies and items.

# This spawns two aggressive munchkins.
def spawnMunchkins():
    munchkin1 = game.spawnXY("munchkin", 2, 12)
    munchkin2 = game.spawnXY("munchkin", 2, 56)
    munchkin1.behavior = "AttacksNearest"
    munchkin2.behavior = "AttacksNearest"

# This spawns two aggressive throwers.
def spawnThrowers():
    thrower1 = game.spawnXY("thrower", 2, 16)
    thrower1.behavior = "AttacksNearest"
    thrower2 = game.spawnXY("thrower", 2, 52)
    thrower2.behavior = "AttacksNearest"

# This spawns a health potion near the village.
def spawnPotion():
    game.spawnXY("potion-large", 46, 34)

# Survive 30 seconds.
game.addSurviveGoal(20)

# The inital values of timers define the first appearance.
game.munchkinSpawnTime = 0
game.throwerSpawnTime = 0
game.potionSpawnTime = 6
# This is used for UI.
game.nextPotionIn = 0

ui.track(game, "time")
# Lets show how long until the next potion.
ui.track(game, "nextPotionIn")

player = game.spawnPlayerXY("duelist", 40, 34)
player.maxSpeed = 15

# This checks and updates timers.
def updateTimers():
    # If game time is greater than the munchkinSpawnTime
    if game.time > game.munchkinSpawnTime:
        # Update the timer and spawn the munchkins.
        game.munchkinSpawnTime = game.munchkinSpawnTime + 6
        spawnMunchkins()
    # If game time is greater than potionSpawnTime
    if game.time > game.potionSpawnTime:
        player.say("The potion is here!")
        # Increase game.potionSpawnTime by 6:
        game.potionSpawnTime = game.potionSpawnTime + 6
        # Call the spawnPotion function:
        spawnPotion()
    # If game time is greater than throwerSpawnTime:
    if game.Time > game.throwerSpawnTime:
        # Increase game.throwerSpawnTime by 9:
        game.throwerSpawnTime = game.throwerSpawnTime + 9
        # Call the spawnThrowers function:
        spawnThrowers()
    # Update the UI timer until the next potion
    game.nextPotionIn = game.potionSpawnTime - game.time
    
while True:
    updateTimers()

    
    

@CHARLES_CRAWFORD found it! Spelling and caps count :wink:

Line 53 (from your original code, corrected for the +9 and the 2 unneeded lines):

    if game.Time > game.throwerSpawnTime:

My code combat must have a bug because none of this is working. Im going to repost on the bug forum.

Please don’t…it’s not a bug. Let me send you what I did and see how that goes first.

1 Like

It is a bug, I have the same problem and no mistakes in my code.

Welcome‌ ‌welcome‌ @ojo_ojos ‌to‌ ‌the‌ ‌forum!‌ ‌It‌ ‌is‌ ‌a‌ ‌lovely‌ ‌place‌ ‌where‌ ‌you‌ ‌can‌ ‌share‌ ‌all‌ ‌kinds‌ ‌of‌ stuff‌ ‌(appropriate‌ ‌of‌ ‌course),‌ ‌share‌ ‌bugs,‌ ‌and‌ ‌even‌ ‌get‌ ‌assistance‌ ‌for‌ ‌code!‌ ‌We‌ ‌suggest‌ ‌that‌ ‌you‌ ‌review‌ ‌this‌‌ topic‌ ‌which‌ ‌shows‌ ‌all‌ ‌essentials‌ ‌of‌ ‌this‌ ‌board!‌ ‌And‌ ‌we‌ ‌suggest‌ ‌you‌ ‌review‌ this topic‌ ‌which‌ ‌shows‌ ‌how‌ ‌to‌ ‌post‌ ‌your‌ ‌code‌ ‌correctly!‌ ‌Thanks!!‌ ‌ :partying_face: :partying_face:
It might not be a bug! Send us your code (formatted correctly) and we’ll help you pass the level! All you have to do is ask.
Lydia

Is there anything wrong in this line?
Screenshot 2020-10-25 at 1.12.37 PM

Never mind I figured it out. but now the throwers will not spawn when I hit the play button

I also have the problem. the throwers won`t show up

Welcome‌ ‌welcome‌ ‌to‌ ‌the‌ ‌forum!‌ ‌It‌ ‌is‌ ‌a‌ ‌lovely‌ ‌place‌ ‌where‌ ‌you‌ ‌can‌ ‌share‌ ‌all‌ ‌kinds‌ ‌of‌ stuff‌ ‌(appropriate‌ ‌of‌ ‌course),‌ ‌share‌ ‌bugs,‌ ‌and‌ ‌even‌ ‌get‌ ‌assistance‌ ‌for‌ ‌code!‌ ‌We‌ ‌suggest‌ ‌that‌ ‌you‌ ‌review‌ ‌this‌‌ topic‌ ‌which‌ ‌shows‌ ‌all‌ ‌essentials‌ ‌of‌ ‌this‌ ‌board!‌ ‌And‌ ‌we‌ ‌suggest‌ ‌you‌ ‌review‌ this topic‌ ‌which‌ ‌shows‌ ‌how‌ ‌to‌ ‌post‌ ‌your‌ ‌code‌ ‌correctly!‌ ‌Thanks!!‌ ‌ :partying_face: :partying_face:
Send us your code formatted correctly and we’ll be more than willing to help!
Lydia