Log In  

Cart #feyikimuho-1 | 2024-05-13 | Code ▽ | Embed ▽ | No License


Hello! (Again...) I am working on a 2D platformer, based off of the Nerdy Teachers tutorial. In my previous post, I asked for assistance coding enemies, and you guys really helped! (Thank you jasondelaat!)

I have since ran into more problems. I'm wondering how I could implement multiple enemies, as my code now only has one frog enemy that can be moved around; Is there a way that I can have multiple frogs that piggy-back off of the same code? Or is the only way is to have separate tabs of code for each individual enemy? I'd love to hear your guy's solutions to this problem! Feel free to look under the hood and check out the code for yourself!

Another problem I have encountered is the "run button" as of now, it just increases the speed of the character (shown by the counter above the player) I would like to implement a system similar to most platformers, where the longer you hold down the run button while moving, the faster you go, with a max speed cap. I tried to attempt this earlier, but it was buggy, and you could build up speed by standing still and holding the button. I'm sure you guys can come up with better code than me.

P.S I am looking for a name for the little bird guy you play as, any ideas?

P#148345 2024-05-13 07:40 ( Edited 2024-05-13 07:46)

--declare a table for frogs
frogs={}
--make a new frog at 5,10
add(frogs,{
 x=5,
 y=10,
 speed=17,
 hp=100,
 hat="cap"
})
--usage (in update/draw)
for frog in all(frogs) do
 frog.x+=frog.speed
 --frog logic
end
P#148352 2024-05-13 10:48

[Please log in to post a comment]