# Multiple sprite placement for platformer

**URL:** <https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092>\
**Category:** Arcade\
**Created:** [January 20, 2020, 8:23pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092 "2020-01-20T20:23:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellyg54](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kellyg54/32/540_2.png) [@kellyg54](https://forum.makecode.com/u/kellyg54)\
**Post date:** [January 20, 2020, 8:23pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092/1 "2020-01-20T20:23:05Z")

</div>

Hi folks! I’ve trawled through this forum but can’t seem to find the answer I am looking for.  
Prior to the upgrade I found it really easy placing multiple “food” spites on specific tiles, however, I cant seem to figure out how to do this now. I can set the food sprite to appear at random, but I don’t know how set multiple food sprites to appear at specific points in the platformer game I am building.

I am sure there is a simple way around this, but I just can’t figure it out. I’m doing it with block coding and introducing makecode arcade to my under 16 coding group on Wednesday and I know this issue might come up.

Any advice would be greatly appreciated!

p.s I’ve only just started teaching myself to code to I am a proper noob.

---

<div class="post-metadata">

**Author:** ![kjw](https://avatars.discourse-cdn.com/v4/letter/k/e79b87/32.png) [@kjw](https://forum.makecode.com/u/kjw)\
**Post date:** [January 21, 2020, 1:02pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092/2 "2020-01-21T13:02:44Z")

</div>

The magic ingredients are `array of all XX locations` (that used to be called `tiles` rather than `locations`) and borrowing the sprite’s `x`/`y` value block to use on the `value` when you iterate over the aforementioned array with a `for element` block. The second part of that is not at all obvious to a `Blocks` programmer.

Example in [https://makecode.com/\_3FcKyyK8UgDj](https://makecode.com/_3FcKyyK8UgDj)

![arcade-No-Soup-For-You-v1-screenshot-code](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/efcce45db4b13e7ad1106050be9e338c8e5377b1.png)

I’m placing the sprites in the soupList array there in case I want to change them later in the code. You don’t need the array if you don’t need to refer back to the individual sprites.

![arcade-No-Soup-For-You-v1-screenshot-simoutput1](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/1b0973e8ad7216cdfcdab5e9dd4620a66c91b0ce.png)

---

<div class="post-metadata">

**Author:** ![kellyg54](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kellyg54/32/540_2.png) [@kellyg54](https://forum.makecode.com/u/kellyg54)\
**Post date:** [January 21, 2020, 4:40pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092/3 "2020-01-21T16:40:26Z")

</div>

Thank you so much! I was sure I needed the array for location block but just couldnt figure out how to make it work. That’s perfect. I appreciate the time you’ve taken to answer me!

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [January 21, 2020, 7:00pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092/4 "2020-01-21T19:00:35Z")

</div>

Great response; to add on a bit, if you want to ‘hide’ the places you put the sprites at, you change the tile back to blend in with the background after placing it:

> **[No Soup For You v1.01](https://arcade.makecode.com/25614-67632-76833-01814)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

 ![arcade-screenshot (6)](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/1X/739aaae7134a32281855a017ee9265d454231072.png)

The code in that snippet behaves the same as the snippet above besides changing the tile back, but I did switch a few things to give alternative approaches:

- instead of using each location’s `x` and `y` positions, I used the `place {sprite} on top of {location}` block – this does the exact same thing as `set {sprite} position to...`, but should be a bit easier to read
- instead of building up an array, you can always use the `array of sprites of kind` block to get all the sprites in the game of a given type that currently exist - this can help a lot in cases where certain sprites may be destroyed / added over time, as you won’t have to remember to maintain the list everywhere you go 🙂

---

<div class="post-metadata">

**Author:** ![kellyg54](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kellyg54/32/540_2.png) [@kellyg54](https://forum.makecode.com/u/kellyg54)\
**Post date:** [January 21, 2020, 8:54pm UTC](https://forum.makecode.com/t/multiple-sprite-placement-for-platformer/1092/5 "2020-01-21T20:54:27Z")

</div>

AH! That’s really helpful, thank you. I hadn’t realised I could change the tile to blend in with the rest, I’ll definitely do that. That also solves a new issue I was having with destroying the food sprite after the player sprite overlapped it. Thanks a million!
