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

Game Development

 
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 
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 
In answer to your specific question, the only way you can do what you are asking is to have some sort of collection containing all of the objects you want to check for collision - so the simplest would be an array of dsSpaceEntity that you iterate over.

VB
For i = 0 to sizeOfArray
   For j = i to sizeofArray
        if Hascollided(Array(i), Array(j)) Then
              doStuff(i,j)
        End If
   Next
Next


But as you say, with a large number in the array this will take time.

Using a more complex structure might help.

One of the simplest things you can do is eliminate the need to test for collisions as soon as possible. If each object has a left, right, top, bottom property then if the Top of one is lower than the bottom of another, no more testing is required. Do these tests first so you don't do anything more complex unless you have to (for example I have objects with complex shapes, so checking collisions is very time consuming - but I first check for a small number of large rectangles, only looking at the detail level after eliminating as may as possible by other tests.

You can also use a radius and center point for each object - and simply calculate the distance between the center points - eliminating further checking if this distance > sum of radii

Assuming that MOST collision tests are negative, it is worthwhile doing many tests, eliminating as many as possible as early as possible - e.g. test the top vs bottom, then left vs right, then distance apart - if the two objects fail all three tests there's a fair chance they've collided - so do any further tests (depending on your shape's complexity)

And hey, why not post some of your games for us to play comment on the codeSmile | :)
MVVM# - See how I did MVVM my way
___________________________________________
Man, you're a god. - walterhevedeich 26/05/2011

.\\axxx
(That's an 'M')

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 
QuestionMy first released game Pin
Thomas.D Williams21-Jul-11 5:18
Thomas.D Williams21-Jul-11 5:18 
AnswerRe: My first released game Pin
Richard MacCutchan28-Jul-11 3:41
mveRichard MacCutchan28-Jul-11 3:41 
GeneralRe: My first released game Pin
Thomas.D Williams28-Jul-11 6:06
Thomas.D Williams28-Jul-11 6:06 
GeneralRe: My first released game PinPopular
Richard MacCutchan28-Jul-11 6:10
mveRichard MacCutchan28-Jul-11 6:10 

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.