
-----------------------------------
Poutine King
Tue Apr 20, 2004 10:16 am

How do you check for object collisions?
-----------------------------------
As the topic asks, how do you check for object collisions?  I tired this:

(the x, y, x2, y2 are the positions of two circles)

if x =x2 and y=y2 then
        x:= 0
        y:= 0
        x2:=100
        y2:=100
end if

the ":=0" or ":=100" is so that they go in a prison but the first circle goes there right off the bat.

How do you check for two objects colliding???

-----------------------------------
Delos
Tue Apr 20, 2004 11:20 am


-----------------------------------
[url=http://www.compsci.ca/v2/viewtopic.php?t=3525]
Checking for Collision Detection.  By DanShadow.


That is how.

-----------------------------------
gamer
Tue Apr 20, 2004 6:10 pm


-----------------------------------
thnx...good link

-----------------------------------
Poutine King
Thu Apr 22, 2004 10:09 am


-----------------------------------
Uhh,  what about characters??  I can make boundries and walls work but how does it work with another moving odject?

-----------------------------------
Paul
Fri Apr 23, 2004 8:55 pm


-----------------------------------
you could use whatdotcolor and check for the edge of one object, or u could just use coordinates and compare the 2 different positions.

-----------------------------------
Poutine King
Thu Apr 29, 2004 10:23 am


-----------------------------------
Actually the walls don't work??? :x  Oi!  They should, I used whatdotcolor to check if the co-ordinates of the character met those of the walls.  But it doesn't work on the corners???  Can you guys give me an example so I can see what you mean.  I'm a visual learner ya know.

-----------------------------------
Paul
Thu Apr 29, 2004 3:22 pm


-----------------------------------
huh? Idk if this helps u, its just a ball u can move with ur arrow keys, and whatdotcolor collision on the corners work... is this what u mean?

setscreen ("offscreenonly") 
var x, y : int 
x := 100 
y := 100 

var chars : array char of boolean 

loop 
    drawfillbox (0, 0, maxx, maxy, black) 
    drawfillbox (10, 10, maxx - 10, maxy - 10, 0) 
drawfillbox (maxx div 2, maxy div 2, maxx div 2 +150, maxy div 2 +50, black)
    Input.KeyDown (chars) 

    if chars (KEY_UP_ARROW) then 
        if whatdotcolor (x, y + 13) = 0 
                then 
            y := y + 5 
        end if 
    end if 
    if chars (KEY_RIGHT_ARROW) then 
        if whatdotcolor (x + 13 , y) = 0 then 
            x := x + 5 
        end if 
    end if 
    if chars (KEY_LEFT_ARROW) then 
        if whatdotcolor (x - 13, y) = 0 then 
            x := x - 5 
        end if 
    end if 
    if chars (KEY_DOWN_ARROW) then 
        if whatdotcolor (x, y - 13) = 0 then 
            y := y - 5 
        end if 
    end if 

    drawfilloval (x, y, 10, 10, 12) 
    View.Update 
    delay (10) 
    cls 
    
end loop 


-----------------------------------
Poutine King
Fri Apr 30, 2004 8:17 am


-----------------------------------
YES!  Thank you so much, now it works!  Bless your soul sonny.
