Pokemon
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.
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
- Location: Ouagadougou (Burkina Faso)
- 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 ?
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:
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')
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
Re: Pokemon
ThanksRoland_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 ?
And that's it. Then you should be able to use Twattle:draw(), Vagikarp:levelup(), etc...the same way than before.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')
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
Changed it.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
Re: Pokemon
addthat to SYS post.jradich wrote:ThanksRoland_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 ?
And that's it. Then you should be able to use Twattle:draw(), Vagikarp:levelup(), etc...the same way than before.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')
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
Changed it.
u wot m8
Re: Pokemon
Already did.rokit boy wrote: addthat to SYS post.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
Re: Pokemon
Some good basic advice there for beginners.
Thanks.
And hope the pokemon project continues
Thanks.
And hope the pokemon project continues
Re: Pokemon
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
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Pokemon
I haven't run it yet, I just took a look at the code. Looks nicer than before.
Re: Pokemon
Thanks.Roland_Yonaba wrote:I haven't run it yet, I just took a look at the code. Looks nicer than before.
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!
Re: Pokemon
Shameless bump, because of progress.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
Who is online
Users browsing this forum: No registered users and 5 guests