Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [Tutorial] Collision Detection
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
FwuffyTheBunny




PostPosted: Wed Apr 09, 2003 10:11 am   Post subject: (No subject)

Hey man, i like the bouncing ball program, ill probly use sum of it to help me in making my projects in school, so all in all thanks
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Fri Apr 25, 2003 11:04 pm   Post subject: (No subject)

here's is what i used in my custom created GUI to detect if mouse is over buttons or not

code:
function mouseover (x, y, x1, y1, x2, y2 : int) : boolean
    if x >= x1 and x <= x2 then
        if y >= y1 and y <= y2 then
            result true
        end if
    end if
    result false
end mouseover

and this is how it is used
code:
var mousex, mousey, mouseb : int

function mouseover (x, y, x1, y1, x2, y2 : int) : boolean
    if x >= x1 and x <= x2 then
        if y >= y1 and y <= y2 then
            result true
        end if
    end if
    result false
end mouseover
loop
    mousewhere (mousex, mousey, mouseb)
    if mouseover (mousex, mousey, 15, 320, 115, 340) then
        drawfillbox (15, 320, 115, 340, 9)
    else
        drawfillbox (15, 320, 115, 340, 12)
    end if
end loop
hello




PostPosted: Sun May 11, 2003 7:35 pm   Post subject: thx

thx for helping with the collision detection and i will show my finished version of the game
thx again
Pickles




PostPosted: Fri May 07, 2004 9:11 pm   Post subject: ..

I dont really understand it which is pretty sad because i should, is distance the point between the radius and what your looking for it to hit, and if distance is less than radius then that means that its hit.. ? Sorry if it sounds like a stupid question, i just cant seem to wrap my head around the concept
Viper




PostPosted: Sun Nov 21, 2004 9:25 pm   Post subject: (No subject)

i find my self alwyas using the mousewhere is that jus b/c it the quickest 2 do or jus b/c im a newb would using keys be better or jus stick with mouse thing
w00t




PostPosted: Wed Dec 01, 2004 8:17 am   Post subject: (No subject)

Hey, If figured this would be the place to be..

[mod:13299fcbab]No it isn't. Questions are best answered when asked in Turing Help. While I'm here, "fullscreen" only works in Turing 3.x, whereas View.Update only works in 4.0. That'd explain the flickering part.[/mod:13299fcbab]
Andy




PostPosted: Wed Dec 01, 2004 4:03 pm   Post subject: (No subject)

u guys do realize that this topic is almost two years old right?
w00t




PostPosted: Wed Dec 01, 2004 6:01 pm   Post subject: (No subject)

I'm using 3.2 Sad
Sponsor
Sponsor
Sponsor
sponsor
hq78




PostPosted: Wed Jan 05, 2005 5:10 pm   Post subject: (No subject)

how do you do the collision detection with a box? or like a 20 X 20 pixel picture with another 20 X 20 pixel picture?
zylum




PostPosted: Wed Jan 05, 2005 5:57 pm   Post subject: (No subject)

check whether the horizontal distance between them is less than or equal to the sum of half of their lengths and the verticle distance is less than of equal to the sum of half of their heights. these distances would ofcourse be measured from the center of one box to the center of the other
diablo




PostPosted: Mon Jan 17, 2005 1:15 pm   Post subject: collision detection

i read the tutorials and i still have a question:
i am making a game and my character uses large bullets
(about 15x15 pixels each), but i cant seem to get the bullets to kill the enemy when they hit. they just seem to pass thru each other.
can any1 help?
Dan




PostPosted: Fri Jan 21, 2005 5:18 pm   Post subject: Re: collision detection

diablo wrote:
i read the tutorials and i still have a question:
i am making a game and my character uses large bullets
(about 15x15 pixels each), but i cant seem to get the bullets to kill the enemy when they hit. they just seem to pass thru each other.
can any1 help?


Hard to help with somting like that with out seeing your code at all, post your question in turing help section with the code.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Paper*Mate




PostPosted: Sun Jun 05, 2005 12:28 pm   Post subject: (No subject)

so how would fix that the bullet doesnt go through the obsticles... heres my code

setscreen ("offscreenonly")
var x, y : int
var x3, x2, y3, y2 : int := 200
var shot : boolean := false
var bulletx, bullety : int := 0
x := 100
y := 100
var chars : array char of boolean

loop
drawfillbox (50, 110, 40, 280, black)
drawfillbox (590, 110, 600, 280, black)
drawfillbox (490, 0, 500, 25, black)
drawfillbox (490, 375, 500, maxy, black)
drawfillbox (125, 375, 135, maxy, black)
drawfillbox (125, 0, 135, 25, black)
drawfilloval (320, 190, 50, 50, black)
drawfillbox (maxx, maxy, 637, 0, black)
drawfillbox (0, 0, maxx, 2, black)
drawfillbox (0, 0, 2, maxy, black)
drawfillbox (0, 397, maxx, maxy, black)
drawfilloval (x, y, 6, 6, 12)
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
if whatdotcolor (x, y + 9) = 0
then
y := y + 5
end if
end if
if chars (KEY_RIGHT_ARROW) then
if whatdotcolor (x + 9, y) = 0 then
x := x + 5
end if
end if
if chars (KEY_LEFT_ARROW) then
if whatdotcolor (x - 9, y) = 0 then
x := x - 5
end if
end if
if chars (KEY_DOWN_ARROW) then
if whatdotcolor (x, y - 9) = 0 then
y := y - 5
end if
end if
if chars (KEY_CTRL) and shot = false then

bulletx := x
bullety := y
shot := true
end if
if bulletx < maxx and shot then
bulletx += 10
drawfilloval (bulletx, bullety, 2, 2, brightred)
elsif bulletx >= maxx then
shot := false
end if
View.Update
delay (10)
cls
end loop


reply quick
[Gandalf]




PostPosted: Sun Jun 05, 2005 12:43 pm   Post subject: (No subject)

heck, I know this is proabbyl an assignment and I'm not supposed to help you. I'm also sure that you should be listening to Dan and posting this is the Help sections. I'm also sure that you shouldn't post things multiple times to get help. But what the hey...

What you need is a whatdotcolour check for the bullet's x and y cordinates as well as the coordinates of you (big dot).

*edit* use [ code] tags next time when posting code.
Paper*Mate




PostPosted: Sun Jun 05, 2005 1:06 pm   Post subject: (No subject)

im sorry to bug u again... but can u put up the actual code cause i dont understand what u r trying to tell me... its just that im a newbie at writting codes
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 34 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: