# \[SOLVED\]Glitches in game development 2

**URL:** <https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001>\
**Category:** Level Help\
**Created:** [October 26, 2020, 2:15pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001 "2020-10-26T14:15:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 2:15pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/1 "2020-10-26T14:15:39Z")

</div>

When I try and attack a ogre It just does stuff that I previously did and it freezes a lot

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 2:38pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/2 "2020-10-26T14:38:01Z")

</div>

Can you tell in what level it is and a screenshot of your problem?

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 2:47pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/3 "2020-10-26T14:47:28Z")

</div>

![Screen Shot 2020-10-26 at 10.45.45 AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/b/bea6884f2b4a2e14953dd10157cfce5ac5add467.jpeg)

It just freezes

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 2:53pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/4 "2020-10-26T14:53:16Z")

</div>

Did you write all code?

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 2:55pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/5 "2020-10-26T14:55:03Z")

</div>

I wrote all the code

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 2:57pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/6 "2020-10-26T14:57:14Z")

</div>

here it is  
game.spawnMaze(5)  
game.spawnXY(“scout”, 60, 58)  
game.spawnXY(“scout”, 28, 29)  
game.spawnXY(“scout”, 61, 24)  
ogref = game.spawnXY(“ogre-f”, 60, 12)

# Spawn and configure the hero.

hero = game.spawnPlayerXY(“captain”, 12, 56)  
hero.maxHealth = 700000  
hero.maxSpeed = 1000000  
hero.attackDamage = 25

# Spawn a munchkin generator.

generator = game.spawnXY(“generator”, 41, 13)  
generator.spawnDelay = 5  
generator.spawnType = “munchkin”

# Survive goal.

game.addSurviveGoal()  
game.spawnXY(“potion-medium”, 28, 12)

# addManualGoal adds an incomplete goal with a description

# The description will be shown to players.

# NOTE that we save it in a variable called scoutGoal

scoutGoal = game.addManualGoal(“Defeat all scouts”)

# Use addManualGoal to add a goal to defeat the boss

# Save it in a variable called bossGoal

game.addManualGoal(“bossGoal”)game.setActionFor(“scout”, “spawn”, onSpawn)  
game.setActionFor(“ogre”, “spawn”, onSpawn)

# Count how many scouts are defeated.

scoutsDefeated = 0

# Update our manual goals whenever an enemy is defeated.

# This is an example of an algorithm using if-statements.

def onDefeat(event):  
unit = event.target  
if unit.type == “scout”:  
scoutsDefeated += 1  
hero.say(“Scout down!”)  
if scoutsDefeated \>= 3:  
# Use setGoalState to mark scoutGoal complete.  
game.setGoalState(scoutGoal, complete)  
hero.say(“All Scouts down!”)  
if unit.type == “ogre”:  
# Use game.setGoalState to mark bossGoal complete.  
# Don’t forget about the second parameter.  
game.setGoalState(bossGoal, complete)  
hero.say(“Defeated the big boss!”)

# Assign the onDefeat handler to the ogres" “defeat”

# NOTE that munchkins don’t count toward success!

game.setActionFor(“scout”, “defeat”, onDefeat)  
game.setActionFor(“ogre”, “defeat”, onDefeat)

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 4:25pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/7 "2020-10-26T16:25:34Z")

</div>

So to kill ogres by clicking on them. To move - click on that place where you want to go. Also, please format your code correctly as it says in this topic:

> [@\[Essentials\] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521):
>
> Formatting your code before posting code is essential to our community, and if you don’t we might not be able to help frowning Everyone must know how to format ALL of your code properly. It’s really easy and only requires a very small amount of effort. To post your code from the game , use the \</\> button or it won’t format properly. When you click the \</\> button, the following will appear: Please paste ALL …

It will be easier for everyone to see your code.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 26, 2020, 4:25pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/8 "2020-10-26T16:25:36Z")

</div>

Please format it correctly so we can see what is going on.  
Lydia

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 26, 2020, 4:30pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/9 "2020-10-26T16:30:31Z")

</div>

And please send a link.  
Lydia

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 4:31pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/10 "2020-10-26T16:31:46Z")

</div>

> **[CodeCombat - Coding games to learn Python and JavaScript](https://codecombat.com/play/campaign-game-dev-2)**
>
> Learn typed code through a programming game. Learn Python, JavaScript, and HTML as you solve puzzles and learn to make your own coding games and websites.

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 4:33pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/11 "2020-10-26T16:33:20Z")

</div>

this is the link too were the glitches are (for me)

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 4:34pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/12 "2020-10-26T16:34:42Z")

</div>

Did you try what I said?

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 26, 2020, 4:36pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/13 "2020-10-26T16:36:05Z")

</div>

There is not a glitch, it worked perfectly fine for me.  
Your code is not good however, and that may be the reason why. So PLEASE format your code CORRECTLY!  
Lydia

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 4:37pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/14 "2020-10-26T16:37:37Z")

</div>

I did what you asked me to do @PeterPalov but it just freezes when try and click on it

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 26, 2020, 4:38pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/15 "2020-10-26T16:38:08Z")

</div>

Like I said, it is your code, format it correctly so we can help you. It only takes 30 seconds.  
Lydia

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 26, 2020, 4:38pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/16 "2020-10-26T16:38:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/9/91ea56e1df6cc155920fa2ab336ed35e0cf765a9.jpeg)  
Not a glitch.  
Lydia

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 4:52pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/17 "2020-10-26T16:52:30Z")

</div>

Can you send a link to the _ **level** _ where you have problem?

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [October 26, 2020, 4:53pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/18 "2020-10-26T16:53:03Z")

</div>

[https://codecombat.com/play/level/stick-shift](https://codecombat.com/play/level/stick-shift)?

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [October 26, 2020, 5:05pm UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/19 "2020-10-26T17:05:49Z")

</div>

Thanks. So can you format your code correctly?

---

<div class="post-metadata">

**Author:** ![ineedhelpwithcoding](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ineedhelpwithcoding/32/30168_2.png) [@ineedhelpwithcoding](https://discourse.codecombat.com/u/ineedhelpwithcoding)\
**Post date:** [October 27, 2020, 5:32am UTC](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001/20 "2020-10-27T05:32:04Z")

</div>

this is the code formatted i had to guess some because i can’t just read your mind

```python
game.spawnMaze(5)
game.spawnXY(“scout”, 60, 58)
game.spawnXY(“scout”, 28, 29)
game.spawnXY(“scout”, 61, 24)
ogref = game.spawnXY(“ogre-f”, 60, 12)

#Spawn and configure the hero.
hero = game.spawnPlayerXY(“captain”, 12, 56)
hero.maxHealth = 700000
hero.maxSpeed = 1000000
hero.attackDamage = 25

#Spawn a munchkin generator.
generator = game.spawnXY(“generator”, 41, 13)
generator.spawnDelay = 5
generator.spawnType = “munchkin”

#Survive goal.
game.addSurviveGoal()
game.spawnXY(“potion-medium”, 28, 12)

#addManualGoal adds an incomplete goal with a description
#The description will be shown to players.
#NOTE that we save it in a variable called scoutGoal
scoutGoal = game.addManualGoal(“Defeat all scouts”)

#Use addManualGoal to add a goal to defeat the boss
#Save it in a variable called bossGoal
game.addManualGoal(“bossGoal”)game.setActionFor(“scout”, “spawn”, onSpawn)
game.setActionFor(“ogre”, “spawn”, onSpawn)

#Count how many scouts are defeated.
scoutsDefeated = 0

#Update our manual goals whenever an enemy is defeated.
#This is an example of an algorithm using if-statements.
def onDefeat(event):
    unit = event.target
    if unit.type == “scout”:
        scoutsDefeated += 1
        hero.say(“Scout down!”)
    if scoutsDefeated >= 3:
        # Use setGoalState to mark scoutGoal complete.
        game.setGoalState(scoutGoal, complete)
        hero.say(“All Scouts down!”)
    if unit.type == “ogre”:
        # Use game.setGoalState to mark bossGoal complete.
        # Don’t forget about the second parameter.
        game.setGoalState(bossGoal, complete)
        hero.say(“Defeated the big boss!”)
    #Assign the onDefeat handler to the ogres" “defeat”
    #NOTE that munchkins don’t count toward success!
    game.setActionFor(“scout”, “defeat”, onDefeat)
    game.setActionFor(“ogre”, “defeat”, onDefeat)

```

and also i can’t help you as i have restarted

[Next page](https://discourse.codecombat.com/t/solved-glitches-in-game-development-2/25001.md?page=2)
