Hi,
As a response to
thispost...
Lots of things need to be improved, in terms of coding style, using tricks you can reuse next.
About 'battle.lua'
I won't discuss how you implemented it, indeed you might agree the code inside
battle:update() in quite redundant...
Why not store all the possible actions inside a local table,indexing them with their proper name, and pairing them with a cost representing the attack value ?
Code: Select all
local allAttacks = { ['shout'] = 35, ['flutter'] = 20, ['kick'] = 25,...}
function battle:update(dt)
...
for attackName,cost in ipairs(allAttacks) do
user.attack[n] = (user.attackname[n]==attackName and cost)
ennemy.attack[p] = (ennemy.attackname[p]==attackName and cost)
end
...
end
About item.lua
I am pretty sure that your items list will grow... To easily loop through the item collection (for updating, or any purpose,...) maybe you might to consider using the same technique you used to iterate through your list of pokemon species ( record each new initiated from the "item" class in a local register)
About player.lua
Actually, why not making this a regular class ? I was expecting that, but you may have your own reasons. Just an idea.
About pokemon.lua
I do know if you have experience some running speed issues, but if so, you might want to consider avoiding making useless checks each loop inside your functions.
- Inside BasePoke:draw(), why checking
each loop if pics exists ? Maybe check this
once, on game start.
- Still inside BasePoke:draw(), when nesting love.graphics.newImage with love.graphics.draw, you
create a new image every frame...This is kinda ugly...Just create all images you need on game start,assert them to variables then pass them to love.graphics.draw.
- Inside BasePoke:update(), the way you set levels is...redundant. Convert the string lvel to a number, that should do the same:
Think that should be enough...