# Enemy spawning in wall

**URL:** <https://forum.makecode.com/t/enemy-spawning-in-wall/18307>\
**Category:** Help\
**Created:** [March 6, 2023, 5:54pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307 "2023-03-06T17:54:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SkillMapster430](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/skillmapster430/32/10497_2.png) [@SkillMapster430](https://forum.makecode.com/u/SkillMapster430)\
**Post date:** [March 6, 2023, 5:54pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/1 "2023-03-06T17:54:37Z")

</div>

I’m making an island survival simulator game, and I made it so fish spawn randomly around the map.  
However, sometimes the fish spawn in the walls(check game for tiles with walls)  
I don’t want my fish to be in the walls(makes it impossible for the player to kill)

Here’s the code:

> **[Island Survival](https://arcade.makecode.com/32691-69836-71377-87438)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![SkillMapster430](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/skillmapster430/32/10497_2.png) [@SkillMapster430](https://forum.makecode.com/u/SkillMapster430)\
**Post date:** [March 6, 2023, 7:13pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/2 "2023-03-06T19:13:56Z")

</div>

Nvm, i fixed it  
now I have a question,  
how can i have different variety of fish  
when my fish spawn, sometimes they have different images  
I will post the updated code

---

<div class="post-metadata">

**Author:** ![PixelDoodle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/pixeldoodle/32/24129_2.png) [@PixelDoodle](https://forum.makecode.com/u/PixelDoodle)\
**Post date:** [March 6, 2023, 7:42pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/3 "2023-03-06T19:42:21Z")

</div>

You Can Put Them In An Array Like This:

```auto
let FishImages = [
    img``,
    img``,
]
game.onUpdateInterval(2000, function(){
    let Fish = sprites.create(FishImages[randint(0,1)], SpriteKind.Enemy)
})

```

You basically just put them in an Array!

---

<div class="post-metadata">

**Author:** ![Dodec](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dodec/32/20281_2.png) [@Dodec](https://forum.makecode.com/u/Dodec)\
**Post date:** [March 6, 2023, 7:42pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/4 "2023-03-06T19:42:47Z")

</div>

Try making it where if it overlaps with the sand it despawns

---

<div class="post-metadata">

**Author:** ![Dodec](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/dodec/32/20281_2.png) [@Dodec](https://forum.makecode.com/u/Dodec)\
**Post date:** [March 6, 2023, 9:21pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/5 "2023-03-06T21:21:09Z")

</div>

> **[Island Survival](https://arcade.makecode.com/S50514-65191-70783-95822)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

here you go

---

<div class="post-metadata">

**Author:** ![SkillMapster430](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/skillmapster430/32/10497_2.png) [@SkillMapster430](https://forum.makecode.com/u/SkillMapster430)\
**Post date:** [March 7, 2023, 5:23pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/6 "2023-03-07T17:23:16Z")

</div>

Here is the updated code:

> **[Island Survival](https://arcade.makecode.com/49814-25208-80323-18545)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

it adds a shark miniboss and a octopus boss  
this adventure is only just the beginning…

P.S. (at score 25, the boss spawns.)

---

<div class="post-metadata">

**Author:** ![SOCKMONSTER12](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sockmonster12/32/7584_2.png) [@SOCKMONSTER12](https://forum.makecode.com/u/SOCKMONSTER12)\
**Post date:** [March 7, 2023, 5:24pm UTC](https://forum.makecode.com/t/enemy-spawning-in-wall/18307/7 "2023-03-07T17:24:35Z")

</div>

Here you go I added you solution if you don’t understand something specifically tell me what and I’ll try to help😁.

> **[Island Survival](https://arcade.makecode.com/S14006-20186-77536-42908)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.
