Skip to main content
Tweeted twitter.com/StackGameDev/status/862974548085538817
removed blacklisted tag; removed irrelevant tag; clarified title; minor grammar and punctuation.
Source Link
Gnemlock
  • 5.3k
  • 5
  • 30
  • 60

Proper OO game engine design: how What is the correct object-orientated approach to parcel responsibilitiesclass design in game development?

(note - I don't have the reputation to create new tags, so mod action may be needed to re-tag)

I'm in the midst of developing a 2D sprite-based game for Windows 7 Phone, using XNA. The training and tutorials available for it are pretty darn good IMOhelpful, but the problem I face is that each of them approaches their class design differently, and the code is not particularly well-factored. As a result, it has been difficult for me to gain a good understanding of which responsibilities I should give to a particular class.

For example:

, I could have a base sprite class BaseSprite, that knows how to draw itself, check for collisions, etc. I could then have an AnimatedSprite class that would know how to navigate its sprite sheet, an ExplodingSprite class, and so on. This technique is demonstrated in the Space Invaders example in the Windows 7 Phone Jumpstart Session 2 materials.

Alternatively, I could instead place the bulk of rendering and running the game responsibility onin a GameScreen class; that class and its derived classes behave more like forms or web pages in terms of their responsibilities. Sprite classes are more simple containers with much less logic.

This is the technique used in the Windows 7 Phone Training Kit's Alien Sprite game and other game state manager examples.

So, how do you approachWhat is the correct object-orientated approach to class design for your gamesin game development?

Proper OO game engine design: how to parcel responsibilities

(note - I don't have the reputation to create new tags, so mod action may be needed to re-tag)

I'm in the midst of developing a 2D sprite-based game for Windows 7 Phone using XNA. The training and tutorials available for it are pretty darn good IMO, but the problem I face is that each of them approaches their class design differently, and the code is not particularly well-factored. As a result, it has been difficult for me to gain a good understanding of which responsibilities I should give to a particular class.

For example:

I could have a base sprite class BaseSprite, that knows how to draw itself, check for collisions, etc. I could then have an AnimatedSprite class that would know how to navigate its sprite sheet, an ExplodingSprite class, and so on. This technique is demonstrated in the Space Invaders example in the Windows 7 Phone Jumpstart Session 2 materials.

Alternatively, I could instead place the bulk of rendering and running the game responsibility on a GameScreen class; that class and its derived classes behave more like forms or web pages in terms of their responsibilities. Sprite classes are more simple containers with much less logic.

This is the technique used in the Windows 7 Phone Training Kit's Alien Sprite game and other game state manager examples.

So, how do you approach the class design for your games?

What is the correct object-orientated approach to class design in game development?

I'm in the midst of developing a 2D sprite-based game for Windows 7 Phone, using XNA. The training and tutorials available for it are pretty helpful, but the problem I face is that each of them approaches their class design differently, and the code is not particularly well-factored. As a result, it has been difficult for me to gain a good understanding of which responsibilities I should give to a particular class.

For example, I could have a base sprite class BaseSprite that knows how to draw itself, check for collisions, etc. I could then have an AnimatedSprite class that would know how to navigate its sprite sheet, an ExplodingSprite class, and so on. This technique is demonstrated in the Space Invaders example in the Windows 7 Phone Jumpstart Session 2 materials.

Alternatively, I could instead place the bulk of rendering and running the game responsibility in a GameScreen class; that class and its derived classes behave more like forms or web pages in terms of their responsibilities. Sprite classes are more simple containers with much less logic.

This is the technique used in the Windows 7 Phone Training Kit's Alien Sprite game and other game state manager examples.

What is the correct object-orientated approach to class design in game development?

edited tags
Link
Cubed2D
  • 2.1k
  • 18
  • 19
edited tags
Link
Michael Klement
  • 3.9k
  • 4
  • 28
  • 23
Source Link
Josh E
  • 537
  • 5
  • 10
Loading