delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/09/04:01:37

From: " [iC]" <jan AT narvik DOT crosswinds DOT net>
Newsgroups: alt.games.programming,comp.os.msdos.djgpp
Subject: Collision Detection
Date: Thu, 9 Apr 1998 09:46:59 +0200
Organization: Telenor Online Public Access
Lines: 35
Message-ID: <6ghudj$krl$1@o.online.no>
NNTP-Posting-Host: ti36a01-0041.dialup.online.no
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm writing a game ( 2d top down) which has a linked list of
objects(structs), to check whetever objects collide I run a loop like this :

Object *pntr = &First_Object;

while(pntr->next) { // pntr->next = next object in linked list

    pntr= pntr->next;

    Object *pntr2 = pntr;

    while(pntr2->next) {

        pntr2 = pntr2->next;

        if (check_bund(pntr, pntr2)) { // Boundingbox checks if pntr and
pntr2 collide

            pntr->touch(pntr, pntr2);    // Does touch function
            pntr2->touch(pntr2, pntr);
        }

    }

-snip-
handel som other stuff
-snip
}

this works but is so damn slooooow....
Has anyone else got a better idea on how to do this ?




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019