Computer Science Canada

The Unofficial Cannon Ball Game Thread!!

Author:  hossack [ Fri Feb 20, 2009 2:22 pm ]
Post subject:  The Unofficial Cannon Ball Game Thread!!

Post Up Your Cannonball Games!

Author:  Gackt [ Sat Feb 21, 2009 12:24 am ]
Post subject:  Re: The Unofficial Cannon Ball Game Thread!!

Heres mine

Author:  darkangel [ Sat Feb 21, 2009 3:32 pm ]
Post subject:  Re: The Unofficial Cannon Ball Game Thread!!

This should be the math you should be using:

code:

type projectile :
    record
        x, y : real
        vx, vy : real
        angle : real
    end record
var ball : projectile
var goal : int
proc INIT (var p : projectile)
    p.x := 10
    p.y := 10
    p.vx := 0
    p.vy := 0

    goal := Rand.Int (maxx div 3, maxx - 40)
end INIT

loop

    INIT (ball)
    Draw.Line (goal - 50, 5, goal + 50, 5, brightred)
    put "Enter power, then angle\n(ex.5 45)"
    get ball.vx, ball.angle
    cls
    ball.vy += sind (ball.angle) * ball.vx

    loop
        exit when ball.y < 0

        ball.y += ball.vy
        ball.vy -= .1
        ball.x += ball.vx

        Draw.Oval (round (ball.x), round (ball.y), 2, 2, black)
        Draw.Line (goal - 50, 5, goal + 50, 5, brightred)
    end loop

    if ball.x > goal - 50 and ball.x < goal + 50 then
        put "Well Done"
    else
        put "Sorry Missed"
    end if
    Input.Pause
end loop


thou I must admit, graphics is not my speciality.


: