Click here to Skip to main content
16,021,285 members
Home / Discussions / Game Development
   

Game Development

 
AnswerRe: game Pin
Andrea198211-Jan-12 2:14
Andrea198211-Jan-12 2:14 
QuestionText drawing in embedded system Pin
A_Fa8-Nov-11 4:11
A_Fa8-Nov-11 4:11 
Questionyour publication in magazine ! Pin
SoftwareWarsaw7-Nov-11 3:05
SoftwareWarsaw7-Nov-11 3:05 
RantRe: your publication in magazine ! PinPopular
Smithers-Jones8-Nov-11 4:34
Smithers-Jones8-Nov-11 4:34 
QuestionMultiplayer Poker Pin
Hanzaplast5-Nov-11 2:13
Hanzaplast5-Nov-11 2:13 
AnswerRe: Multiplayer Poker Pin
AspDotNetDev5-Nov-11 10:48
protectorAspDotNetDev5-Nov-11 10:48 
AnswerRe: Multiplayer Poker Pin
Alisaunder6-Jan-12 2:54
Alisaunder6-Jan-12 2:54 
Question'Self-aware' classes? Pin
Purge1t30-Oct-11 18:54
Purge1t30-Oct-11 18:54 
Hi guys... long time reader first time poster. Please be gentle.

I avidly create games in VB.net. Being a hobby programmer I give my games away for free. Since I'm a hobbiest without formal training I do try and educate myself on proper programming principles and follow them when programming such as OOP. There are however some things I have obviously missed being self-taught that perhaps I would know if I were formally educated.

Once such issue that has really been my bane is how different classes (from now on referred to as objects) 'know' about each other WITHOUT programming specific interaction (stay with me here... please...)

Okay imagine this, you have a space game and the following objects

clsShip
clsMissile
clsAsteroid
clsSpaceJunk

Now each one of these objects has a Health, X,Y and Z private members and properties that are all inherited from clsSpaceEntity for argument sake. Now one way of programming collision between them would be to code out the following logic in the main game loop

for each ship in a list of ships
check each clsMissile in a list to see if it collides with it and if so, reduce health
check each clsAsteroidin a list to see if it collides with it and if so, reduce health
check each clsSpaceJunka list to see if it collides with it and if so, reduce health
... and so on and so on for every object
next

ect ect ect...

Now this might seam okay if your talking about the simple example above but some of my games have tens or even HUNDREDS of objects that interact in this basic way.

Now my question to the experienced programmers out there.

Is there a way in OOP to do the following...

for each thing that inherits from clsSpaceEntity
check against every other object that inherits this type (except itself) and if they collide then reduce health
next

?


This sort of ability for a type of objects/class or whatever to be 'aware' of another and how they are the same/different and interact would save me tonnes and tonnes and TONNES of coding.



Any assistance/help or feedback on this would be very appreciated. Thank you for your time, sorry for the long read.
AnswerRe: 'Self-aware' classes? Pin
CDP180231-Oct-11 9:21
CDP180231-Oct-11 9:21 
GeneralRe: 'Self-aware' classes? Pin
Purge1t31-Oct-11 14:26
Purge1t31-Oct-11 14:26 
GeneralRe: 'Self-aware' classes? Pin
CDP180231-Oct-11 15:39
CDP180231-Oct-11 15:39 
AnswerRe: 'Self-aware' classes? Pin
_Maxxx_31-Oct-11 18:33
professional_Maxxx_31-Oct-11 18:33 
Questionmodel, shade, looksRealistic OpenGL Pin
appollosputnik25-Oct-11 3:34
appollosputnik25-Oct-11 3:34 
AnswerRe: model, shade, looksRealistic OpenGL Pin
CDP180225-Oct-11 5:10
CDP180225-Oct-11 5:10 
QuestionHow to set pixelz using XNA and C# Pin
CDP180213-Oct-11 21:57
CDP180213-Oct-11 21:57 
AnswerRe: How to set pixelz using XNA and C# Pin
rj4524-Oct-11 11:54
rj4524-Oct-11 11:54 
GeneralRe: How to set pixelz using XNA and C# Pin
CDP180225-Oct-11 2:02
CDP180225-Oct-11 2:02 
Questioni need your help Pin
gif202014-Sep-11 1:39
gif202014-Sep-11 1:39 
AnswerRe: i need your help Pin
Pete O'Hanlon14-Sep-11 2:13
mvePete O'Hanlon14-Sep-11 2:13 
GeneralRe: i need your help Pin
gif202014-Sep-11 6:10
gif202014-Sep-11 6:10 
GeneralRe: i need your help Pin
Pete O'Hanlon14-Sep-11 6:47
mvePete O'Hanlon14-Sep-11 6:47 
GeneralRe: i need your help Pin
gif202014-Sep-11 8:33
gif202014-Sep-11 8:33 
AnswerRe: i need your help Pin
Mahdi Nejadsahebi25-Sep-11 1:01
Mahdi Nejadsahebi25-Sep-11 1:01 
AnswerRe: i need your help Pin
Paul Conrad25-Oct-11 6:01
professionalPaul Conrad25-Oct-11 6:01 
AnswerRe: i need your help Pin
Peter Hawke28-Dec-11 13:03
Peter Hawke28-Dec-11 13:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.