# Issues with platformer game enemies

**URL:** https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597
**Category:** Help
**Created:** [January 26, 2023, 1:15am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597 "2023-01-26T01:15:35Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [January 26, 2023, 1:15am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/1 "2023-01-26T01:15:35Z")

</div>

I’m making a platformer game with different enemies in it, and I’m having an issue with the enemies. I’m asking, is it possible to have an enemy turn the other way when getting to the end of a platform instead of just falling off the edge?

---

<div class="post-metadata">

### Author: ![personalnote](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/personalnote/32/31359_2.png) [@personalnote](https://forum.makecode.com/u/personalnote)
#### Post date: [January 26, 2023, 6:10pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/2 "2023-01-26T18:10:54Z")

</div>

yes. search goomba on the forums and you will find your answer.

---

<div class="post-metadata">

### Author: ![JorginLegal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jorginlegal/32/7262_2.png) [@JorginLegal](https://forum.makecode.com/u/JorginLegal)
#### Post date: [January 26, 2023, 6:11pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/3 "2023-01-26T18:11:52Z")

</div>

Pseudocode:

```auto
On game update:
    if ( Tile below [Sprite] = Trasparency ):
        mySprite.vx = mySprite.vx * -1

```

Actual Project:

> **[enemy don't fall off](https://arcade.makecode.com/S15720-63089-83893-19500)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [January 26, 2023, 7:05pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/5 "2023-01-26T19:05:26Z")

</div>

I just now tried it, and it doesn’t seem to work. I don’t know what’s wrong, as i did everything the code is telling me to do.

---

<div class="post-metadata">

### Author: ![JorginLegal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jorginlegal/32/7262_2.png) [@JorginLegal](https://forum.makecode.com/u/JorginLegal)
#### Post date: [January 26, 2023, 7:52pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/6 "2023-01-26T19:52:54Z")

</div>

Could you send a link to the game?

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [January 26, 2023, 10:10pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/7 "2023-01-26T22:10:44Z")

</div>

Yep, here it is

> **[coneguy platformer test](https://arcade.makecode.com/S79978-29382-73954-76530)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![JorginLegal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jorginlegal/32/7262_2.png) [@JorginLegal](https://forum.makecode.com/u/JorginLegal)
#### Post date: [January 27, 2023, 12:53am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/8 "2023-01-27T00:53:23Z")

</div>

It seems that the on game update function is… _entirely non-functional?_  
I genuinely have no idea what’s causing this, hoping someone else can find out what’s going on here.

---

<div class="post-metadata">

### Author: ![NobodyNomad](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nobodynomad/32/10821_2.png) [@NobodyNomad](https://forum.makecode.com/u/NobodyNomad)
#### Post date: [January 27, 2023, 5:10pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/9 "2023-01-27T17:10:30Z")

</div>

look in the on game update and select a block that specifies a time like “on game update every 500 milliseconds”. I’m not certain that this will fix this particular problem but it might help and prevent some future problems.

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [January 27, 2023, 6:38pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/10 "2023-01-27T18:38:49Z")

</div>

It…uh…didn’t seem to work.  
I put it into the block you specified, first with 500 ms, and then 1 ms. Neither worked.  
I don’t know what to do. ☹

---

<div class="post-metadata">

### Author: ![NobodyNomad](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nobodynomad/32/10821_2.png) [@NobodyNomad](https://forum.makecode.com/u/NobodyNomad)
#### Post date: [January 30, 2023, 5:35pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/11 "2023-01-30T17:35:52Z")

</div>

sorry

---

<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: [February 1, 2023, 5:41am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/12 "2023-02-01T05:41:20Z")

</div>

@discobot quote

---

<div class="post-metadata">

### Author: ![discobot](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/discobot/32/1_2.png) [@discobot](https://forum.makecode.com/u/discobot)
#### Post date: [February 1, 2023, 5:41am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/13 "2023-02-01T05:41:22Z")

</div>

> 🗨 _Why worry about things you can’t control when you can keep yourself busy controlling the things that depend on you?_ —

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [February 2, 2023, 5:28pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/15 "2023-02-02T17:28:31Z")

</div>

Update: I have resolved the issue, but I have found another problem.  
The problem was with one of the extensions I had (arcade-storytelling). I had the character say something before the game actually started, and apparently that pauses the function of the “on game update” block until the character is done speaking. So that part works.  
The NEW issue is that those rules of turning around at a ledge only applies to ONE of the enemies, and the others keep defying gravity and walking on air. How do I make those rules apply to all of the enemies?

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [February 6, 2023, 6:47pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/16 "2023-02-06T18:47:48Z")

</div>

is this post dead?

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [February 6, 2023, 8:15pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/17 "2023-02-06T20:15:15Z")

</div>

Can you send a link to the game with the new issue. I need to see your implementation to see what’s the problem (although I can already probably guess a possible cause).

---

<div class="post-metadata">

### Author: ![NobodyNomad](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/nobodynomad/32/10821_2.png) [@NobodyNomad](https://forum.makecode.com/u/NobodyNomad)
#### Post date: [February 6, 2023, 9:27pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/18 "2023-02-06T21:27:17Z")

</div>

no, this post is not a ghost

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [February 7, 2023, 9:05pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/19 "2023-02-07T21:05:17Z")

</div>

Here’s the updated game with the new issue.  
I made the game look better with the riknoll//grafxkid-tiles extension, i gave the character a double-jump ability, and created a new powerup (the weird bat thing sitting on the first bridge).  
I’ve also added a couple of other enemies to demonstrate the problem (and a new one that works).

> **[coneguy platformer test](https://arcade.makecode.com/S79978-29382-73954-76530)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![JorginLegal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jorginlegal/32/7262_2.png) [@JorginLegal](https://forum.makecode.com/u/JorginLegal)
#### Post date: [February 21, 2023, 10:53pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/20 "2023-02-21T22:53:37Z")

</div>

This is most likely because all the enemies use the same variable.

While this may work at first, one will eventually face problems (such as this one) if they keep it like that, since many operations only work on the most recently spawned instance of a sprite.

The solution is to keep all the enemies in an array of sprites, then running the code for each element in the array separately.

---

<div class="post-metadata">

### Author: ![TheConeGuy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theconeguy/32/13840_2.png) [@TheConeGuy](https://forum.makecode.com/u/TheConeGuy)
#### Post date: [February 21, 2023, 11:02pm UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/21 "2023-02-21T23:02:55Z")

</div>

How could I do that? I’m not exactly sure how arrays work in Makecode Arcade 😅

---

<div class="post-metadata">

### Author: ![goldtopaz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/goldtopaz/32/28622_2.png) [@goldtopaz](https://forum.makecode.com/u/goldtopaz)
#### Post date: [July 18, 2023, 2:54am UTC](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597/22 "2023-07-18T02:54:36Z")

</div>

spot the difference

![download](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/4/4120b3e646a5460451b497d52c821d48c46d089a.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/7557f43d8afd53d9c995d3368b17045460207226.png)

[Next page](https://forum.makecode.com/t/issues-with-platformer-game-enemies/17597.md?page=2)
