|
-
April 16th, 2010, 07:35 AM
#14
Re: I want to optimize my code
 Originally Posted by monarch_dodra
Copy paste typo, sorry.
The basic idea is to define a default behavior in the parent class (in this case body), and create a specific behavior in the derived class, if the behavior is different from the default.
In your example, I would put the "walk around randomly" implementation in "body". I would redefine it for man (since it has user interaction). Zomby and Badger would not redefine it, since the default is fine. HunterZombie would redefine it, since it walks twice as fast (or you can define a speed variable...)
so for zombie "move" should go in "body"
and by redefine man i am not too sure what you mean, sorry "/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|