
-----------------------------------
DanShadow
Fri Feb 06, 2004 2:31 pm

[tutorial] Basic Collision Detection
-----------------------------------
Collision detection is done through a large amount of ways...arrays, whatdotcolor,lines,and other assorted things. Ill try to explain a couple of these just so some of the newer people can do stuff with it or something.
The Bouncing Ball

%Program: The Bouncing Ball
%Description: This program draws a 
%--ball that bounces of the top,bottom
%--and sides of the program screen.
var ballx,bally,xmod,ymod:int:=200
xmod:=1
ymod:=1
loop
setscreen("offscreenonly")
View.Update
Draw.FillBox(0,0,maxx,maxy,0)
Draw.FillOval(ballx,bally,10,10,12)
ballx+=xmod
bally+=ymod
if ballx+10>=maxx then 
xmod:=-1
elsif ballx-10=maxy then
ymod:=-1
elsif bally-10=maxx or whatdotcolor(ballx+11,bally)=255 then 
xmod:=-1
elsif ballx-10=maxy or whatdotcolor(ballx,bally+11)=255  then
ymod:=-1
elsif bally-10= maxx then
        xmod := -xmod
    elsif ballx = maxy then
        ymod := -ymod
    elsif bally 