# How to make clones move left and right

**URL:** <https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645>\
**Category:** Help\
**Tags:** game\
**Created:** [November 11, 2024, 11:48pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645 "2024-11-11T23:48:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [November 11, 2024, 11:48pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/1 "2024-11-11T23:48:55Z")

</div>

basically I am making a terraria remake and I want to have opponents and the first one being slimes. but I cant get them to consistently go left to right after another clone spawns

---

<div class="post-metadata">

**Author:** ![Mega0star01](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mega0star01/32/14784_2.png) [@Mega0star01](https://forum.makecode.com/u/Mega0star01)\
**Post date:** [November 12, 2024, 3:36pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/2 "2024-11-12T15:36:19Z")

</div>

please, send the link to the game, so we can check it & help you.

---

<div class="post-metadata">

**Author:** ![platformermaster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/platformermaster/32/16102_2.png) [@platformermaster](https://forum.makecode.com/u/platformermaster)\
**Post date:** [November 12, 2024, 3:36pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/3 "2024-11-12T15:36:52Z")

</div>

explain further and i can help!  
maybe even a link

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [November 12, 2024, 7:03pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/4 "2024-11-12T19:03:46Z")

</div>

You should use the Sprite Utility extention → [https://github.com/jwunderl/arcade-sprite-util](https://github.com/jwunderl/arcade-sprite-util)  
This extension makes it easy for “clones” of a given sprite to operate autonomously from the variable they were originally set. (Without the use of slimeSprite) You can use the “on sprite update” block to run code inside it for a sprite over an interval. This might be confusing so here is an example → [https://arcade.makecode.com/S04085-55422-76309-15306](https://arcade.makecode.com/S04085-55422-76309-15306). (Press B to summon slimes) (You can summon as many as you want)

If this is not what you are talking about feel free to elaborate.

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [November 12, 2024, 11:51pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/5 "2024-11-12T23:51:51Z")

</div>

Wow this is very helpful thank you! I appreciate this so much! thank you for your help I have never been able to make games with clones.

---

<div class="post-metadata">

**Author:** ![MicroMan7](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/microman7/32/18103_2.png) [@MicroMan7](https://forum.makecode.com/u/MicroMan7)\
**Post date:** [November 13, 2024, 2:59pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/6 "2024-11-13T14:59:48Z")

</div>

![move](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/a/f/afbabfd0325d02854f1ad0a781bb020d437324df.jpeg)

---

<div class="post-metadata">

**Author:** ![jquinn](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jquinn](https://forum.makecode.com/u/jquinn)\
**Post date:** [November 14, 2024, 5:44pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/7 "2024-11-14T17:44:36Z")

</div>

Does this have an extension directly on Makecode? I would like for my students to be able to use some of these. Great way to get multiple sprites to do the same thing. Thank you!

---

<div class="post-metadata">

**Author:** ![Brohann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brohann/32/17380_2.png) [@Brohann](https://forum.makecode.com/u/Brohann)\
**Post date:** [November 14, 2024, 6:52pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/8 "2024-11-14T18:52:34Z")

</div>

Have your students search the github url in the extensions search bar

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [November 14, 2024, 6:54pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/9 "2024-11-14T18:54:57Z")

</div>

Sort of… You can get an outdated version it in a bundle of extensions labeled “arcade-carnival”.

 ![IMG_0389](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/4/8/486bc968bccd91ba99c2df6bcd33ad65f57ff04f.jpeg)  
This will add the sprite utility toolbox. Due to it being outdated version of the extension it does not have certain blocks like “sprite move to x, y” but the “on sprite update” blocks will be there. Other extensions this bundle will add include “text sprites,” “status bars.” And “carnival.” All makecode approved extensions.

If you are worried about the GitHub link being unsafe, do not worry because the extension was created by @jwunderl, a makecode employee.  
Hope this helps!

---

<div class="post-metadata">

**Author:** ![jquinn](https://avatars.discourse-cdn.com/v4/letter/j/c89c15/32.png) [@jquinn](https://forum.makecode.com/u/jquinn)\
**Post date:** [November 20, 2024, 7:26pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/10 "2024-11-20T19:26:29Z")

</div>

This is perfect! Thank you. This community is great!

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [November 21, 2024, 8:18pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/11 "2024-11-21T20:18:58Z")

</div>

@Bifrosty you seem to know what you are doing with these clones. could you make the slimes have HP bars and you can damage them? Thank you. That is all I need for this.

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [November 22, 2024, 5:02am UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/12 "2024-11-22T05:02:23Z")

</div>

Sure, It’s pretty simple! Here is one way to do it:  
First Create a status bar every time you creat your enemy (slime). Ensure you attach it to your slime with this block (statusbar extension)

 ![IMG_0414](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/b/6b3d8a8667c1b13cd352695f3d10b4c08e335564.jpeg)  
Now make sure you have an attack. I made a little blue circle appear around the play for this but it can be anything.

After you have done this make an overlap for the player’s attack and the enemy. In here you are going to put code that subtracts from the enemy’s health bar. The code should look something like this:

 ![IMG_0415](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/7/8/78d3f887c9498d7fa033606e74411d268d78615b.jpeg)  
Note the changing of the player’s attack to “prop.” A prop sprite has no overlaps and is essentially a way to make the attack not hit the slime more than once. There are different ways to do this—better ones, but this is simple.

The slime can now take damage from your player’s attack, but they can’t die. Add one finial “on sprite update loop” to your slime. Make sure this triggers very fast. I used 10 in my example but anywhere from 5-50 should do. Here you are going to check if your enemy’s health bar is at zero. If it is destroy the sprite. It’s worth noting that this will terminate all “on sprite update loops.” Stoping them from repeating. Your finial loop should look like this.

 ![IMG_0416](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/9/39f9925e41155ae32a48755d5222688e2c769741.jpeg)  
I think that the statusbar extension should be bundled with the sprite utility extension because they work together well. Here is my example → [https://arcade.makecode.com/S86076-81887-13211-42119](https://arcade.makecode.com/S86076-81887-13211-42119) (Attack mapped to A button) (Jump re-maped to up button)  
Hope this helps! If you have any further questions ask me.

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [December 2, 2024, 6:25pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/13 "2024-12-02T18:25:23Z")

</div>

@Bifrosty This has to be the last time I will ask you for help on this (probably) if I have a tile how van I make one clone for each tile their is?

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [December 6, 2024, 4:50pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/14 "2024-12-06T16:50:18Z")

</div>

Sorry for the late reply. Here’s how to do it:  
1.Create a new tile unused anywhere else. I like to draw a little small imperfect picture of what it does and label it with some text like this → (SS for Slime Spawn)

 ![Screenshot 2024-12-06 075035](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/b/bbc2b0308932fa600dc7c328e4e2ebdf213bdec3.png)  
You don’t have to make it look good as nobody will see this tile. Now place this tile anywhere you want your enemy to be.

2.Grab a “for element loop.” This loop executes the code in it for every item in an array.

 ![Screenshot 2024-12-06 075316](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/f/5/f58a04a9b14791cabf81c52db4ec6feb1ceae557.png)  
The “value” part is what that item in the array will be. Put this in a function that is called in your on start block after loading your tile map. You can call the function “populateTiles” Now go to the scene drawer and get an “array of all locations” block.–\>  
 ![Screenshot 2024-12-06 075819](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/2/6/262df8e96ad6a472a6ce4654e653fbf07706ac78.png)

This instantly makes an array for all the locations of any tile without extra code. Put this where your element loop says “list” and change its input from the default blank tile to your tile that you created earlier.

3.Call your cloneEnemy spawn function within the loop. Drag the value part of the element loop and place your enemy top of it. (similarly to what you would do with the “on sprite update loop”)

4.If you did all of that this will put your enemy on the tile but the placeholder tile will still be there. Set the value of the tile to a blank tile or a background wall. Your final function should look something like this. →

 ![Screenshot 2024-12-06 080834](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/0/800c5313a81b82e64906db8ad5c38fe00de4c6bb.png)  
Here is my example link → [https://arcade.makecode.com/S66752-85999-46767-05855](https://arcade.makecode.com/S66752-85999-46767-05855)  
If you need any more help just ask. Also I can’t wait to play your game!

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [December 6, 2024, 4:56pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/15 "2024-12-06T16:56:12Z")

</div>

thank you, this is all I need.

---

<div class="post-metadata">

**Author:** ![CodeOnTheCob](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codeonthecob/32/19306_2.png) [@CodeOnTheCob](https://forum.makecode.com/u/CodeOnTheCob)\
**Post date:** [January 28, 2025, 5:59pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/16 "2025-01-28T17:59:15Z")

</div>

> [@Bifrosty](#):
>
> [https://github.com/jwunderl/arcade-sprite-util](https://github.com/jwunderl/arcade-sprite-util)

(sentence)

---

<div class="post-metadata">

**Author:** ![CodeOnTheCob](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/codeonthecob/32/19306_2.png) [@CodeOnTheCob](https://forum.makecode.com/u/CodeOnTheCob)\
**Post date:** [January 28, 2025, 5:59pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/17 "2025-01-28T17:59:19Z")

</div>

[https://github.com/jwunderl/arcade-sprite-util](https://github.com/jwunderl/arcade-sprite-util)

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [February 10, 2025, 7:01pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/18 "2025-02-10T19:01:18Z")

</div>

@Bifrosty this is really sad, but I am an unexperienced coder and I couldn’t get anyone to help me with this project after I finished the terraria one. so I am kind of posting on this old one that already had some attention. basically my problem is players move by 16 pixels per tile. but they go through walls too. I already tried adding walls but they just walk through them. could you help? here is the project link: [https://makecode.com/\_TYoWVFKok7yY](https://makecode.com/_TYoWVFKok7yY)

---

<div class="post-metadata">

**Author:** ![Bifrosty](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bifrosty/32/24819_2.png) [@Bifrosty](https://forum.makecode.com/u/Bifrosty)\
**Post date:** [February 11, 2025, 2:13am UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/19 "2025-02-11T02:13:00Z")

</div>

What I believe you are trying to do is make grid based movement. Here is an explanation of why it isn’t working →

When you ask a sprite to move say 10 pixels to the right. You are telling it to do all of this in one big step and are basically teleporting the sprite 10 pixels to the right opposed to moving it over there. Because of this your sprite will not account for walls during this, “movement.” (teleportation)

> **Solution 1 (simple)**
>
> You can scrap all the move y or x blocks and rely on the built in tilemap system. Fist make a function called “player move to [col] [row].” Make sure col and row are numerical inputs.
> 
> ![Screenshot 2025-02-10 at 4.47.01 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/6/f/6f28fad7da757b4912c82372af03ff706e7210d7.png)  
> Now we want to check if the tile the player is moving to is a wall or not. We can do this with this block in the scene drawer:  
> ![Screenshot 2025-02-10 at 4.52.48 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/0/c0b9d46c05c659a79e079c377b71bd149a9156df.png)  
> Make sure to add a “not conjunction” so that the player doesn’t move on only walls. Now we just place the player at the specified location with the col and row inputs.  
> ![Screenshot 2025-02-10 at 4.55.43 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/f/cf29880eb6af12841f29d29dc6e5dc9f9e4b8ce5.png)  
> We still have to call the function when the player wants to move though. We do this when the player presses a direction, we get their column and row to find out where they should end up. Add 1 to the coloum to move right and subtract 1 to move left. Do the same with row to move up and down. Looks like this:  
> ![Screenshot 2025-02-10 at 5.01.12 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/f/6/f6f3654cca9ee6173847e2de734e5ea8dab9a3f2.png)  
> This should work in function but the player jerks around when moving and it looks weird so if you want to change its look visually see solution 2
> 
> example → [https://makecode.com/\_fm58KH6PaLfM](https://makecode.com/_fm58KH6PaLfM)

> **Solution 2 (complex but looks better)**
>
> You could move the sprite 10 pixels to right by setting its velocity to 10 and waiting one second before stopping it (velocity in makecode is pixels traveled per second) This would tell the sprite to take much smaller steps in movement rather than taking all 10 pixels at once. This would account for walls. You can scale this any way you want to eg. 100 velocity and stoping after 0.1 seconds, 50 velocity and stoping after 0.2 seconds ect. All of these scenarios would yield the same result but the sprite would move quicker or slower to get there.
> 
> Now we can apply this to make smooth looking grid based movement. Add the “timer” extension to your project, its under the default extensions tab so no special link. To do this we will modify some code from solution 1. First we turn the if statment from solution one into a return function.
> 
> ![Screenshot 2025-02-10 at 4.18.35 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/a/8a63dd6d92966a379a46c0110c011c7c76a0112f.png)  
> If you are not familiar with these they basically give you an output variable when you put something in. Its like a very special variable. This return function will check if the tile is eligible for the player to move to. (not a wall) If you did this right a new block should show up in your functions drawer:  
> ![Screenshot 2025-02-10 at 4.23.53 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/7/874c3fa24ce0bac13a614b5239c84e81fe1f218d.png)  
> We can use this new block as a boolean output. (true or false things in the logic drawer)  
> ![Screenshot 2025-02-10 at 4.28.26 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/9/b95173f58ec81175c5a97b559aee8de25e282525.png)  
> Now we add our smooth movement code. Because we want the player to move 16 pixels we should set their velocity to 16 and wait one second to stop them. But this is too slow so I’m going to do this at 5x speed. 16 x 5 = 80 (velocity) and 1 ÷ 5 = 0.2 (stop time seconds). If we input this we can get some smooth movement. Your code should look something like this:  
> ![Screenshot 2025-02-10 at 4.34.49 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/9/b98bafbbe15b57ba7be5cbc9bad5222ff80231ac.png)  
> Of course we don’t want the player to move again while they are already moving because it might offset them. So we want to disable their movement controls during this period:  
> ![Screenshot 2025-02-10 at 4.37.17 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/e/ce6227b128048e54e432bfc5355e9f8e940dd9b8.png)  
> Repeat this process for each of the four directions and make sure you set “can move” to true at the beginning. Now it should be done, and you have smooth grid movement.  
> Example → [https://makecode.com/\_Pqj72j56EaYD](https://makecode.com/_Pqj72j56EaYD)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Ima.notarobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ima.notarobot/32/26551_2.png) [@Ima.notarobot](https://forum.makecode.com/u/Ima.notarobot)\
**Post date:** [February 11, 2025, 12:56pm UTC](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645/20 "2025-02-11T12:56:56Z")

</div>

WOW! Thank you so much, this is really helpful and motivated me to keep coding now that I have walls. (Never thought I would say that…) thanks!

[Next page](https://forum.makecode.com/t/how-to-make-clones-move-left-and-right/31645.md?page=2)
