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

Username:   Password: 
 RegisterRegister   
 The Unofficial Cannon Ball Game Thread!!
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
hossack




PostPosted: Fri Feb 20, 2009 2:22 pm   Post subject: The Unofficial Cannon Ball Game Thread!!

Post Up Your Cannonball Games!


Cannonball Game.zip
 Description:

Download
 Filename:  Cannonball Game.zip
 Filesize:  10.25 KB
 Downloaded:  317 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Gackt




PostPosted: Sat Feb 21, 2009 12:24 am   Post subject: Re: The Unofficial Cannon Ball Game Thread!!

Heres mine


Cannon Ball Game.zip
 Description:

Download
 Filename:  Cannon Ball Game.zip
 Filesize:  17.96 KB
 Downloaded:  236 Time(s)

darkangel




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: