Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411512 Posts in 69376 Topics- by 58430 Members - Latest Member: Jesse Webb

April 26, 2024, 10:06:40 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Relation between game objects<->sprites, "is a" or "has a"?
Pages: 1 [2]
Print
Author Topic: Relation between game objects<->sprites, "is a" or "has a"?  (Read 4761 times)
Hajo
Level 5
*****

Dream Mechanic


View Profile
« Reply #20 on: January 09, 2009, 03:25:37 AM »

An object might also have a list of sprites, or might change the visual appearance during its lifetime.

Both cases go well with a "has a" relation.

"Is a" should be restricted to things that just narrow down the functionality or domain of the parent class/object. Which is not the case for a sprite and an game object. Quite often, even in that case, you'll find "is a" relations to be very strict and inflexible, making changes difficult in later stages of the project. Delegation is a pattern that can help there.

So "has a" for sure IMO for the sprite <-> object case.

Logged

Per aspera ad astra
Michelle Disraeli
Level 0
**


View Profile
« Reply #21 on: January 09, 2009, 05:55:07 AM »

An object might also have a list of sprites, or might change the visual appearance during its lifetime.
I'm actually thinking that perhaps it is more important that an object might not be a sprite - there are many great uses for invisible objects in a game world.

This hence automatically forces a has-a relationship, rather than an is-a (and all you need do is have either null checks, or a stub display class)
Logged
Gary the Llama
Level 0
**


World's Angriest Llama!


View Profile
« Reply #22 on: February 04, 2009, 08:05:19 AM »

Sorry to bump an old thread, but I thought it would be better than starting a completely new thread.

Does anyone have an example of the entity/sprite relationship when using the D3DXSprite interface? Right now I believe that my Entity class would not contain a reference to the D3DXSprite interface, since I only need one D3DXSprite object for the whole game. And then I would just have a vector<entity> and loop through that for rendering.

Any example code would be great.
Logged
Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic