Issues with platformer game enemies

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?

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

Pseudocode:

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

Actual Project:

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.

Could you send a link to the game?

Yep, here it is

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.

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.

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. :frowning_face:

sorry

@discobot quote

:left_speech_bubble: Why worry about things you can’t control when you can keep yourself busy controlling the things that depend on you?

2 Likes

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?

is this post dead?

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).

no, this post is not a ghost

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).

3 Likes

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.

1 Like

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

1 Like

spot the difference

download
image

1 Like