Sword weapon?

Hello, I’m creating a platformer and want to the player’s default weapon to be a sword (they can get powerups that enable shooting powers but if they lose the powerup, back to a sword). The previously I had programmed it like so:

The problem was that this way, the character’s direction was facing right by default and they could only attack to the left (with both sword or shooting fireballs) while holding the left key and moving left. Just not great gameplay feel.

I fixed this issue so the player can now freely move left or right and the attack (both sword and shooting fireball) will go in the direction the play is facing. But, now I can’t program the sword to work the way I want it to.

Here is the game now: https://makecode.com/_TYu5H3e3MMva

The sword is a projectile and it looks good while the player is moving left or right, but if they are standing still and use the sword it is too far away from the player. How can I fix this?

I was originally trying to use this method I found on the forum (https://arcade.makecode.com/95725-52201-47702-82935) but it doesn’t work because once an enemy is destroyed with the sword, the sword goes away forever.

How can I get this effect to work for a handheld type weapon? Another complication seems to be that I need to flip the image of the sword depending on the direction of the player.

Great looking game by the way. Keep working on it!

Maybe try animating the sword next. Don’t just draw the sword in different positions though as that can look clunky. Give yourself a big swooping arc like the sword is blurred to give the impression of a quick swing.

1 Like