Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Help with collision detection
Author Message
jedi-bob

Posted: Mon Jan 19, 2004 10:30 am   Post subject: Help with collision detection

i cant get the oval collision detection working, i will post the code, if i could get some help that would be great. I copied the oval collision detection code into my program, but it get errors. I am using Turing 4.0.4c

var chars : array char of boolean
var A1,B1,A2,B2: int
A1:=50
A2:=10
B1:=50
B2:=10

loop
drawfilloval(A1,B1,A2,B2,7)
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
cls
A1:=A1+15

elsif chars (KEY_LEFT_ARROW) then
cls
A1:=A1-15

elsif chars (KEY_DOWN_ARROW) then
cls
B1:=B1-15

elsif chars (KEY_UP_ARROW) then
cls
B1:=B1+15

end if
delay(100)
drawfilloval(200,200,50,50,yellow)
drawfilloval(200,200,10,10,black)

var distance := ((A2-A1)*(A2-A1) + (B2-B1)*(B2-B1))**0.5
%you take the square of differences of X coordinates and add
%a square of differences of Y coordinates then take a square
%root of the sum
%%%%%%
%I did (x)*(x) instead of x**2 because exponents is a function
%and it takes up more resourses then *, thus its faster
%Also **0.5 is the same as sqrt() - learn your math guys

then
collision = true
end if
end loop

Mod Edit: Moved it to the right forum, don't post in tutorial next time when you have a question.

Thuged_Out_G

Posted: Mon Jan 19, 2004 3:20 pm   Post subject: (No subject)

you could use whatdotcolor for your collision detection....but if you dont do it correct(according to dodge), he'll get mad
jedi-bob

Posted: Mon Jan 19, 2004 3:28 pm   Post subject: (No subject)

i don't quite understand. Maybe you could copy my code above, correct it, and repost it. I am very new to turing, so don't think i am retarded.
Tony

Posted: Mon Jan 19, 2004 5:17 pm   Post subject: (No subject)

you can't expect to paste some base code at the end of your program and expect things to work

see the collision = true line? thats where you place the code that does whatever after collision occurts.

replace that with put "collision occured" to see if the code works
Tony's programming blog. DWITE - a programming contest.
jedi-bob

Posted: Tue Jan 20, 2004 9:53 am   Post subject: (No subject)

thanks, sorry for me being a dumbass
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: