Computer Science Canada

Need Collision help

Author:  Paper*Mate [ Fri May 20, 2005 11:31 am ]
Post subject:  Need Collision help

My name is bill....i have troubles with applying collsions to my program. i found a tutorial on how to do it but i am confused. Please help me or give me advice on how to apply this to my program :

%COLLSION
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



NOW HERE IS MY PROGRAM:

var x, x2, y, y2 : int := 200
var input : array char of boolean
setscreen ("offscreenonly")
loop
colorback (black)
cls
drawfillbox (50, 110, 40, 280, white)
drawfillbox (590, 110, 600, 280, white)
drawfillbox (490, 0, 500, 25, white)
drawfillbox (490, 375, 500, maxy, white)
drawfillbox (125, 375, 135, maxy, white)
drawfillbox (125, 0, 135, 25, white)
drawfilloval (320, 200, 50, 50, white)
drawfilloval (450, 200, 7, 7, brightblue)
drawfilloval (x, y, 7, 7, brightred)
View.Update
Input.KeyDown (input)
if input (KEY_UP_ARROW) then
y := y + 5
elsif input (KEY_DOWN_ARROW) then
y := y - 5
elsif input (KEY_LEFT_ARROW) then
x := x - 5
elsif input (KEY_RIGHT_ARROW) then
x := x + 5
elsif input (KEY_CTRL) then
%colour (0)
%locate(1, 1)
%put x
for s : x .. maxx
if s > x + 20 then
drawline (s - 11, y, s + 1, y, black)
drawline (s - 10, y, s, y, 12)
View.Update
delay (2)
end if
end for
end if
delay (30)
end loop

Author:  MysticVegeta [ Sat May 21, 2005 10:39 am ]
Post subject: 

uh..
1) There are atleast 5 topics "xactly" like this.
2) there are tutorials in the turing section on collisions, check out tony's and Cervantes'
3) Check the Math.Distance syntax and how to use it in the F10 lib.

-Mystic

Author:  Paper*Mate [ Mon May 23, 2005 2:14 pm ]
Post subject:  thanks

thnaks man


: