This is definitely not a good start.
I looked at it, and found many code repetitions. That is not how classes work.
Besides, you are using a fairly simple class system.Then take full advantage of it.
Note that yours classes (Twattle and Vagikarp) have exactly the same methods, but you repeated them. I expect when you'll next have to add new species, you will rewrite down the same stuff, and it will result in a extremely long source code.
Why not move all methods (draw, fight, level up, faint) into the basePoke class ? And then instanciate Vagikarp and Twattle ?
Code: Select all
class "BasePoke" {
hp=100, name="Base",user=true,enemy=false,level=1,attacking=false,attackname='fap'
}
function BasePoke:__init(hp,name,user,enemy,level,attacking,attackname)--Sets how you would name a custom pokemon
--etc
end
function BasePoke:draw()
--etc
end
function BasePoke:fight()
--etc
end
function BasePoke:levelup()
--etc
end
function BasePoke:faint()
--etc
end
Vagikarp=BasePoke:new(100,"Vagikarp",true,false,1,false,'fap')
Twattle=BasePoke:new(100,"Twattle",false,true,1,false,'fap')
And that's it. Then you should be able to use Twattle:draw(), Vagikarp:levelup(), etc...the same way than before.
Don't forget to consider that inside methods, you can call other methods, just use self.
Example:
Code: Select all
function BasePoke:fight()
if fight==true then
--etc etc
end
self:levelup()
--etc etc
end