
-----------------------------------
w00t
Wed Dec 01, 2004 8:32 am

Collision Issues [ Already Read the Turtorial ]
-----------------------------------
Hey, If figured this would be the place to be.. 

Heres one of my "bouncing balls" programs, but aside from the massive seizure you may have from it , the collision isn't working properly as well.... This is how i originally made and now i want to make it start in a random spot but it won't work completly unless i can get the collision down
I've already read the turtorial it just didn't make sense,,, I dont know what to say.. but any help would be appreciated 

Thanks, 
w00t w00t 


%- By: w00t 
%- September 24th 2004 
%- Bouncing Balls 


var icolor, y, k, i : int := 0 
var xcoor, xcoor2, xcoor3 : int := 600 
var ycoor, ycoor2, ycoor3 : int := 60 
var xother, xother2, xother3 : int := 1 
var yother, yother2, yother3 : int := 1 
var window := Window.Open ("fullscreen,nocursor,noecho") 



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Bottom Border % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
y := 0 

%% BOXES %% 

for x : 10 .. 800 by 80 
drawfillbox (x, y + 39, x + 40, y + 1, black) 
end for 

%% Circles %% 

for x : 31 .. 800 by 80 
drawfilloval (x + 40, y + 20, 20, 20, red) 
end for 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Top Border % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
y := 300 

%% BOXES %% 

for x : 10 .. 800 by 80 
drawfillbox (x - 10, y + 260, x + 30, y + 300, black) 
end for 

%% Circles %% 

for x : 31 .. 800 by 80 
drawfilloval (x - 10 + 40, y + 280, 20, 20, red) 
end for 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Left Side Border % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
y := 0 

%% Circles %% 

for x : 10 .. 550 by 80 
drawfilloval (20, x + 50, 20, 20, red) 
end for 

%% Boxes %% 

for x : 10 .. 550 by 80 
drawfillbox (1, x - 10, y + 40, x + 30, black) 
end for 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
% Right Side Border % 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

y := 0 

%% Circles %% 

for x : 10 .. 550 by 80 
drawfilloval (790, x + 90, 20, 20, red) 
end for 

%% Boxes %% 

for x : 40 .. 550 by 80 
drawfillbox ( 810, x + 40, y + 770, x, black) 
end for 

%%%%%%%%%%%%%%%%%%% 
% Moving Objects % 
%%%%%%%%%%%%%%%%%%% 
loop 

%% Circle 1 %% 

ycoor := ycoor + yother 
Draw.FillOval (xcoor, ycoor, 20, 20, red) 
delay (1) 
Draw.FillOval (xcoor, ycoor, 20, 20, white) 
if xcoor = 55 or xcoor = 750 then 
xother := xother * - 1 
end if 
if ycoor = 60 or ycoor = 540 then 
yother := yother * - 1 
end if 

%% Circle 2 %% 

xcoor2 := xcoor2 - xother2 
ycoor2 := ycoor2 + yother2 
Draw.FillOval (xcoor2, ycoor2, 20, 20, blue) 
delay (1) 
Draw.FillOval (xcoor2, ycoor2, 20, 20, white) 
if xcoor2 = 55 or xcoor2 = 750 then 
xother2 := xother2 * - 1 
end if 
if ycoor2 = 60 or ycoor2 = 540 then 
yother2 := yother2 * - 1 
end if 

%% Circle 3 %% 

xcoor3 := xcoor3 - xother3 
Draw.FillOval (xcoor3, ycoor3, 20, 20, red) 
delay (1) 
Draw.FillOval (xcoor3, ycoor3, 20, 20, white) 
if xcoor3 = 55 or xcoor3 = 750 then 
xother3 := xother3 * - 1 
end if 
if ycoor3 = 60 or ycoor3 = 540 then 
yother3 := yother3 * - 1 
end if 

%% Collision %% 

exit when ycoor3 = ycoor2 
end loop 

Music.PlayFile ("D:\track1.wma")

-----------------------------------
Delos
Wed Dec 01, 2004 12:10 pm


-----------------------------------
1)
Please use [code] tags.

2)
Please omit any code that requires us to have files that we obviously don't have for you proggie to run (Music.PlayFile ("D:\track1.wma")???)

3)
You have setup your screen borders (in your collision detection) to be 750 and 540.  Your run screen is only 640x400.  Do the maths.

4)
Sadly, in this instance, you'll want to use whatdotcolour() collision detection.  I'm guessing from your thread title that you know what this is.  Since you've got circles as well, a bit of circular collision detection won't hurt either (incorporating the whatdotcolour() of course).  And since you know what that is, having read the tutorial, go forth and fix!

5)
Please use [code] tags.

-----------------------------------
Viper
Thu Dec 02, 2004 2:20 pm


-----------------------------------
just use location in if statements 
eg 

if ball1x=ball2x and ball1y=ball2y then
put "they hit"
end if
