Pokemon

Show off your games, demos and other (playable) creations.
Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Pokemon

Ok so what I decided to make was a very simple version of the Pokemon battle system. There's no AI at the moment, and there is certainly a lot to be implemented, but I think it's a good start. Enjoy!
And excuse inappropriate names.
Last edited by jradich on Fri May 11, 2012 11:05 am, edited 1 time in total.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!

Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

Re: Pokemon

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


Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Re: Pokemon

Roland_Yonaba wrote: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

Thanks
Changed it.
love pokemon.love
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!

rokit boy
Party member
Posts: 198
Joined: Wed Jan 18, 2012 7:40 pm

Re: Pokemon

Roland_Yonaba wrote: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

Thanks
Changed it.
love pokemon.love
u wot m8

Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Re: Pokemon

rokit boy wrote: addthat to SYS post.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!

misstr87
Prole
Posts: 1
Joined: Mon May 14, 2012 11:46 am

Re: Pokemon

Some good basic advice there for beginners.
Thanks.

And hope the pokemon project continues

Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Re: Pokemon

love pokemon.zip
New Update. Pictures are now possible, and there are multiple attacks.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!

Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

Re: Pokemon

I haven't run it yet, I just took a look at the code. Looks nicer than before.

Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Re: Pokemon

Roland_Yonaba wrote:I haven't run it yet, I just took a look at the code. Looks nicer than before.
Thanks.
Oh and also, making pokemon is incredibly easy. Just write:

Code: Select all

YourPoke=BasePoke:new(hp,name,user,enemy,level,attackname1,attackname2,pic)

And call "YourPoke:fight()" and "YourPoke:draw()" in the proper functions. Remember, though, there are only two attacks, though new attacks are easy, too.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!

Party member
Posts: 100
Joined: Mon Dec 12, 2011 8:44 pm

Re: Pokemon

love pokemon.love