Page 1 of 1

Can you make a powerup hurt you?

Posted: Tue Oct 19, 2021 7:48 am
by UbuntuJackson
Hello, I had this level idea about a forest with tanooki leaves falling from the sky. I imagined there being red leaves that hurt you, brown leaves that do nothing, and green leaves that gives you it's normal powers. I just don't know how to go about making this. Has anyone tried making something similar to this? I know I could just make an enemy look like the leaf, but then I would still not have the falling animation.
(I am not sure if this is the right place to ask this, tell me if I am doing something wrong.)

Re: Can you make a powerup hurt you?

Posted: Wed Oct 20, 2021 7:39 am
by deice
the basic idea is quite simple to implement. it simply entails creating a custom npc that hurts you and then (i assume to mimic powerup behavior) also kills itself when it does so. the main problem here is implementing the tanooki leaf movement. since it's a legacy NPC, there's no ready-made lua script with it's AI, but luckily since the SMBX source code is now public, it's possible to simply view exactly how it's physics work and attempt to recreate it based on that.

alternatively, you could just make it so that leaves are by default invisible and draw over the ones you actually want to be visible with the normal sprite, then have an (effectively) invisible, friendly tanooki leaf that you manually set never to despawn (field despawnTimer) and just have your custom NPC follow it's movements with a specifed positional offset based on it's initial spawn point.

i'm aware that both of these solutions seem a bit daunting, but they're the only ones that come to mind for me. someone else might have a better idea.

Re: Can you make a powerup hurt you?

Posted: Wed Oct 20, 2021 7:46 am
by Marioman2007
Well, the problem was solved on the codehaus discord.
Just letting the people know.