# Game Dev 2 Game Of Coins Step 3

**URL:** <https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737>\
**Category:** Bugs\
**Created:** [December 13, 2018, 2:54am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737 "2018-12-13T02:54:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angel\_Bazaldua](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Angel\_Bazaldua](https://discourse.codecombat.com/u/Angel_Bazaldua)\
**Post date:** [December 13, 2018, 2:54am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/1 "2018-12-13T02:54:31Z")

</div>

Would anybody mind sharing their working javascript code for this level? No matter what I’m doing, I can’t seem to get the spawned units to one hit kill the player. I would share my code here myself, but I don’t have a computer to access it on at the moment.

---

<div class="post-metadata">

**Author:** ![Seojin\_Roy\_Lee](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/seojin_roy_lee/32/23539_2.png) [@Seojin\_Roy\_Lee](https://discourse.codecombat.com/u/Seojin_Roy_Lee)\
**Post date:** [December 13, 2018, 3:32am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/2 "2018-12-13T03:32:08Z")

</div>

isn’t the title supposed to be Game Dev _3?_

---

<div class="post-metadata">

**Author:** ![Angel\_Bazaldua](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Angel\_Bazaldua](https://discourse.codecombat.com/u/Angel_Bazaldua)\
**Post date:** [December 13, 2018, 4:17am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/3 "2018-12-13T04:17:56Z")

</div>

No? It’s the 27th Level of game dev 2.

---

<div class="post-metadata">

**Author:** ![123hi123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/123hi123/32/9541_2.png) [@123hi123](https://discourse.codecombat.com/u/123hi123)\
**Post date:** [December 13, 2018, 2:00pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/4 "2018-12-13T14:00:02Z")

</div>

It is not allowed to post working code on Discourse. Also, you say

> [@Angel\_Bazaldua](#):
>
> I don’t have a computer to access it on at the moment.

So then how are you posting this?

---

<div class="post-metadata">

**Author:** ![Angel\_Bazaldua](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Angel\_Bazaldua](https://discourse.codecombat.com/u/Angel_Bazaldua)\
**Post date:** [December 13, 2018, 4:57pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/5 "2018-12-13T16:57:02Z")

</div>

A phone with mobile data enabled. Anyways, my mistake. I’ve actually got my code now so I can go ahead and post it for feedback:

```python
game.spawnXY("forest", 16, 16);
game.spawnXY("forest", 32, 16);
game.spawnXY("forest", 48, 16);
game.spawnXY("forest", 64, 16);
game.spawnXY("forest", 16, 32);
game.spawnXY("forest", 32, 32);
game.spawnXY("forest", 48, 32);
game.spawnXY("forest", 64, 32);
game.spawnXY("forest", 16, 48);
game.spawnXY("forest", 32, 48);
game.spawnXY("forest", 48, 48);
game.spawnXY("forest", 64, 48);
game.spawnXY("bronze-coin", 16, 8);
game.spawnXY("bronze-coin", 24, 8);
game.spawnXY("bronze-coin", 32, 8);
game.spawnXY("bronze-coin", 48, 8);
game.spawnXY("bronze-coin", 56, 8);
game.spawnXY("bronze-coin", 64, 8);
game.spawnXY("bronze-coin", 72, 8);
game.spawnXY("bronze-coin", 8, 16);
game.spawnXY("bronze-coin", 24, 16);
game.spawnXY("bronze-coin", 40, 16);
game.spawnXY("bronze-coin", 56, 16);
game.spawnXY("bronze-coin", 72, 16);
game.spawnXY("bronze-coin", 8, 24);
game.spawnXY("bronze-coin", 16, 24);
game.spawnXY("bronze-coin", 24, 24);
game.spawnXY("bronze-coin", 32, 24);
game.spawnXY("bronze-coin", 40, 24);
game.spawnXY("bronze-coin", 48, 24);
game.spawnXY("bronze-coin", 56, 24);
game.spawnXY("bronze-coin", 64, 24);
game.spawnXY("bronze-coin", 72, 24);
game.spawnXY("bronze-coin", 24, 32);
game.spawnXY("bronze-coin", 56, 32);
game.spawnXY("bronze-coin", 8, 40);
game.spawnXY("bronze-coin", 16, 40);
game.spawnXY("bronze-coin", 24, 40);
game.spawnXY("bronze-coin", 32, 40);
game.spawnXY("bronze-coin", 40, 40);
game.spawnXY("bronze-coin", 48, 40);
game.spawnXY("bronze-coin", 56, 40);
game.spawnXY("bronze-coin", 64, 40);
game.spawnXY("bronze-coin", 72, 40);
game.spawnXY("bronze-coin", 8, 48);
game.spawnXY("bronze-coin", 24, 48);
game.spawnXY("bronze-coin", 40, 48);
game.spawnXY("bronze-coin", 56, 48);
game.spawnXY("bronze-coin", 72, 48);
game.spawnXY("bronze-coin", 8, 56);
game.spawnXY("bronze-coin", 16, 56);
game.spawnXY("bronze-coin", 24, 56);
game.spawnXY("bronze-coin", 32, 56);
game.spawnXY("bronze-coin", 48, 56);
game.spawnXY("bronze-coin", 56, 56);
game.spawnXY("bronze-coin", 64, 56);
game.spawnXY("bronze-coin", 72, 56);
game.spawnXY("mushroom", 40, 8);
game.spawnXY("mushroom", 8, 32);
game.spawnXY("mushroom", 72, 32);
game.spawnXY("mushroom", 40, 56);
game.score = 1000;
ui.track(game, "time");
ui.track(game, "score");

game.addCollectGoal(10);
game.addSurviveGoal();
var player = game.spawnPlayerXY("knight", 8, 8);
player.maxSpeed = 32;
function onCollect(event) {
    var player = event.target;
    var item = event.other;
    if (item.type == "bronze-coin") {
        game.score += 1;
    }
    if (item.type == "mushroom") {
        game.score += 5;
    }
}
player.on("collect", onCollect);

var munchkinSpawner = game.spawnXY("generator", 40, 32);
munchkinSpawner.spawnType = "scout";
munchkinSpawner.spawnDelay = 60;
function onSpawn(event) {
    var unit = event.target;
    unit.maxSpeed = 8;
    unit.attackDamage >= player.maxHealth;
}
game.setActionFor("scout", "spawn", onSpawn);
function checkTimeScore() {
    game.score -= 0.5;
    if (game.score < 0) {
        game.score = 0;
    }
}
while (true) {
    checkTimeScore();
}  

```

---

<div class="post-metadata">

**Author:** ![Alfonso\_Carrejo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/alfonso_carrejo/32/10513_2.png) [@Alfonso\_Carrejo](https://discourse.codecombat.com/u/Alfonso_Carrejo)\
**Post date:** [August 13, 2019, 6:04pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/6 "2019-08-13T18:04:40Z")

</div>

i am having the same problem ,it wont one hit the hero

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [August 15, 2019, 11:02am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/7 "2019-08-15T11:02:49Z")

</div>

If you have a problem with you code please post it and give more information about your problem.  
Thanks

---

<div class="post-metadata">

**Author:** ![Alfonso\_Carrejo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/alfonso_carrejo/32/10513_2.png) [@Alfonso\_Carrejo](https://discourse.codecombat.com/u/Alfonso_Carrejo)\
**Post date:** [August 15, 2019, 6:36pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/8 "2019-08-15T18:36:24Z")

</div>

there you go good chap

```python

game.score = 1000;
ui.track(game, "time");
ui.track(game, "score");
// Lets simplify the game while we don't have power-ups.
game.addCollectGoal(10);
game.addSurviveGoal();

var player = game.spawnPlayerXY("knight", 8, 8);
player.maxSpeed = 32;

function onCollect(event) {
    var player = event.target;
    var item = event.other;
    if (item.type == "bronze-coin") {
        game.score += 1;
    }
    if (item.type == "mushroom") {
        game.score += 5;
    }
}

player.on("collect", onCollect);

// Spawn a monster "generator" in the center:
game.spawnXY("generator",40, 30);
// Set the generator spawnType to “scout”.
    var spawnType="scout";
// Set the generator spawnDelay to 6 (or greater).
    var spawnDelay=6;

// This function configures new spawned scouts.
function onSpawn(event) {
    var unit = event.target;
    unit.maxSpeed = 8;
    // Set the unit's attackDamage to a value that
    // is greater than or equal to the player's maxHealth.
    unit.attackDamage >= (player.maxHealth);
}

// Set the handler for "scout"s' "spawn" event to onSpawn
game.setActionFor("scout", "spawn", onSpawn);

function checkTimeScore() {
    game.score -= 0.5;
    if (game.score < 0) {
        game.score = 0;
    }
}

while (true) {
    checkTimeScore();
}
// Win the game.

```

---

<div class="post-metadata">

**Author:** ![karla](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/karla/32/34206_2.png) [@karla](https://discourse.codecombat.com/u/karla)\
**Post date:** [April 25, 2023, 1:04am UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/9 "2023-04-25T01:04:41Z")

</div>

i have the same problem and it wont seem to let me pass the level, it wont “one-hit” me.

---

<div class="post-metadata">

**Author:** ![Charles\_Ryan\_Guba](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/charles_ryan_guba/32/35065_2.png) [@Charles\_Ryan\_Guba](https://discourse.codecombat.com/u/Charles_Ryan_Guba)\
**Post date:** [October 20, 2023, 3:36pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/10 "2023-10-20T15:36:54Z")

</div>

`munchkinSpawner.spawnDelay = 60;`

change this to “= 6”

---

<div class="post-metadata">

**Author:** ![ChickenMaster](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chickenmaster/32/35104_2.png) [@ChickenMaster](https://discourse.codecombat.com/u/ChickenMaster)\
**Post date:** [October 23, 2023, 5:31pm UTC](https://discourse.codecombat.com/t/game-dev-2-game-of-coins-step-3/16737/11 "2023-10-23T17:31:04Z")

</div>

Welcome to the discourse @Charles_Ryan_Guba ! You should check this topic out to help get yourself oriented!

> [@Welcome to CodeCombat Discourse Forums!](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601):
>
> Welcome! New users, welcome to codecombat discourse! As you know, this place is where you can ask for help, get hints on levels, share experiences that you had while playing codecombat, reporting bugs, etc.! Feel free to enjoy your time here, but here’s a few things you should know before going ahead. Trust levels If you click on my profile picture, you should see a list of badges and in the first one, it should say, leader. That’s trust level 4. What exactly is a trust level? A trust level c…
