Jump to content
  • Advertisement
Sign in to follow this  
exylex

[.net] Inheritance or Layering sprite class

This topic is 3999 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been reading/watching 2 different tutorials about c# game programming. After reading thru the first book i made a little mini game that had a class called gameObject for handling game object that inherit from my sprite class for the visual part. However, i've been watching thrue another tutorial now that states: Inheritance = "is a" Layering = "has a" And shows that the mouse object (wich i see as no bigger different from an gameobject, static tho) should layered the sprite class. Now im a bit confused, should i Inheritance the sprite class or create an instance of it for my gameObject class?, whats the different?. (im newbie)

Share this post


Link to post
Share on other sites
Advertisement
The difference will become more clear as you gain experience. Program design is difficult and a bit more of a 'feel' than just writing syntax...

You should not use inheritance. It is useful to have game objects without a visual representation (for dedicated servers) or with malleable representations (changing from sprites to models; allowing skinning) and inheritance prevents that. Even 'layering' (composition is the usual term used) prevents that to a degree.

The common pattern for these sort of things is called Model-View-Controller, and some research should provide oodles of info for you better than my ramblings.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!