# How can I have different enemies in different places on the same sprite? Like a group of the same sprite

**URL:** <https://forum.makecode.com/t/how-can-i-have-different-enemies-in-different-places-on-the-same-sprite-like-a-group-of-the-same-sprite/36162>\
**Category:** Help\
**Created:** [April 27, 2025, 3:58am UTC](https://forum.makecode.com/t/how-can-i-have-different-enemies-in-different-places-on-the-same-sprite-like-a-group-of-the-same-sprite/36162 "2025-04-27T03:58:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anacael](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/anacael/32/21849_2.png) [@Anacael](https://forum.makecode.com/u/Anacael)\
**Post date:** [April 27, 2025, 3:58am UTC](https://forum.makecode.com/t/how-can-i-have-different-enemies-in-different-places-on-the-same-sprite-like-a-group-of-the-same-sprite/36162/1 "2025-04-27T03:58:05Z")

</div>

Hi, here is the game: [https://arcade.makecode.com/S35232-16326-05275-76354](https://arcade.makecode.com/S35232-16326-05275-76354)  
I don’t want to copy and paste the same enemy features a thousand times with a different sprite name. So I was wondering how to create a sort of group that would function as a single shared sprite, but where I could place different sprites in different locations on the map.

---

<div class="post-metadata">

**Author:** ![agnotario](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/agnotario/32/21820_2.png) [@agnotario](https://forum.makecode.com/u/agnotario)\
**Post date:** [April 27, 2025, 3:15pm UTC](https://forum.makecode.com/t/how-can-i-have-different-enemies-in-different-places-on-the-same-sprite-like-a-group-of-the-same-sprite/36162/2 "2025-04-27T15:15:16Z")

</div>

![Captura de pantalla 2025-04-27 a las 11.00.42](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/d/1d7c9a4660e560dface9d674f253cbd0f4808fbc.png)  
This function, called Enemigos, spawns enemy sprites at predefined map locations. Here’s a step-by-step explanation:

1. It loops through **each location** from the array of all tilemap locations of a specific tile type (the yellow square).
2. For each location:

- It **creates a new sprite** (an enemy with a skull image) of kind **Enemy**.
- It **places** the enemy sprite exactly **on top of the location** (tile) that was selected.
- It also **sets the tile** at that location to another tile (shown in green), possibly to mark the spot as used or to change its appearance.

This is typically used to automatically populate a map with enemies based on the level design, making it easy to control where enemies appear without manually placing them one by one.

Hope this helps or inspires you!!

---

<div class="post-metadata">

**Author:** ![Anacael](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/anacael/32/21849_2.png) [@Anacael](https://forum.makecode.com/u/Anacael)\
**Post date:** [April 27, 2025, 7:47pm UTC](https://forum.makecode.com/t/how-can-i-have-different-enemies-in-different-places-on-the-same-sprite-like-a-group-of-the-same-sprite/36162/3 "2025-04-27T19:47:30Z")

</div>

Thanks for the help, I’ll try it.
