Hi - I have what would be considered a newbie question I believe. I am writing code for a game that spawns various power ups using a module I wrote. Within my module code, there are functions that takes a number of options, such as the type of power up, the x and y coordinates, the respawn delay, and a few other parameters.
My question is - is it better to have one function that has a bunch of conditions in it to check for the power up type, or should I have a separate function for each power up.
For example:
function M.powerUp(ptype,x,y,respawn) if ptype == "attack" then --do something elseif ptype == "shield" then --do something else --do something end end
OR:
function M.attackPowerUp(x,y,respawn) -- do something end
Just trying to be as memory efficient as possible when spawning a bunch of items at one time for a level.
Thanks for any feedback!