
-----------------------------------
be natural*
Sun Jun 08, 2003 7:33 pm

collision for lots of circles
-----------------------------------
I'm trying to make collision detection work for my game..
there are a lot of circles up on the screen and i'm shooting a circle from a point. when the circle collide any of the circles it will stop & if they have the same colour, they'll disappear.
I've tried making two circles disappear when they collide, but should i use an array for the centres of each circle if i want to use circle collision?

-----------------------------------
Andy
Sun Jun 08, 2003 7:38 pm


-----------------------------------
you should, but you could also just use whatdotcolor

-----------------------------------
be natural*
Sun Jun 08, 2003 7:43 pm


-----------------------------------
what's whatdotcolor?
and can u explain how to use it?

thx :)

-----------------------------------
Andy
Sun Jun 08, 2003 7:48 pm


-----------------------------------
whatdotcolor checks the color of one pixel

whatdotclor(x,y)

it returns the color of the pixel in integer format
if you are shooting a projectile and the targets you are shooting are simply circles drawn by turing, you can just say

if whatdotcolor(projectilex, projectiley)=circleclr then
%do whatever you want to do here
end if

but using pythagorus is so much easier

for i:1..circlenum
if (circlex-projectilex)**2+(cicley-projectiley)**2>circleradius then
%do your thing here after
end if
end for

if you have turing 4.01 or better, just type in the command and press F9

-----------------------------------
be natural*
Mon Jun 09, 2003 8:40 am


-----------------------------------
i've tried to make circle collision but it doesn't really work...

can anybody tell me what should i fix in my code?
also, how can i identify the circles that are already disappeared so that the circle that is being shoot can pass through? 

i've attached the code below.


setscreen ("graphics:400;600")

var iColor : int
var iX : int := 31
var iY : int := 520
var iShootX : int := 200
var iShootY : int := 91
var rD : array 1 .. 33 of real
var chars : array char of boolean
var b:int

var iMap1x : array 1 .. 33 of int
var iMap1y : array 1 .. 33 of int

for z : 1 .. 33
    iMap1x (z) := iX * z
    if (z >= 13) and (z = 24) and (z = 13) and (y = 24) and (y 