
-----------------------------------
Luffy
Mon May 24, 2004 3:01 pm

Shooting the radius of a circle
-----------------------------------
Ok well I'm trying to figure out how do I shoot a line and when it hits the radius of a circle, it makes the circle disappear. Also I read the tutorial for collision but I don't really get it...and I'm trying to make it as well for if the rock hits my ship then it disappears. Heres my coding below...

Use the arrow keys to move around and push CTRL to shoot.


setscreen ("graphic: 500,500")
var move : array char of boolean
var change, change2 : int := 0
var fire : int := 0
var rock : int := 0
var fall : int := 1

procedure rockfall
    randint (rock, 1, 1)
    if rock = 1 then
        fall := fall - 1
        drawfilloval (10, 400 + fall, 10, 10, brown)
    end if
end rockfall

procedure movement
    Input.KeyDown (move)
    if move (KEY_RIGHT_ARROW) then
        change := change + 1
        if change = maxx - 20 then
            change := change - 1
        end if
    end if
    if move (KEY_LEFT_ARROW) then
        change := change - 1
        if change = 0 then
            change := change + 1
        end if
    end if
    if move (KEY_UP_ARROW) then
        change2 := change2 + 1
        if change2 = maxy - 20 then
            change2 := change2 - 1
        end if
    end if
    if move (KEY_DOWN_ARROW) then
        change2 := change2 - 1
        if change2 = 0 then
            change2 := change2 + 1
        end if
    end if
    if move (KEY_CTRL) then
        delay (10)
        fire := fire + 1
        drawline (10 + change, change + (change2 + fire), 10 + change, 10 + change2, red)
        if fire = rock then
            cls
        end if
    end if
    drawfilloval (10 + change, 10 + change2, 10, 10, blue)
end movement

loop
    View.Update
    cls
    setscreen ("offscreenonly")
    movement
    rockfall
end loop


-----------------------------------
Tony
Mon May 24, 2004 3:21 pm


-----------------------------------
the the line/circle collision - you can ether check if the distance between the line and the center of the circle is 