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

Username:   Password: 
 RegisterRegister   
 I Need help with angles and parabolas
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Delta




PostPosted: Fri Mar 28, 2003 9:41 am   Post subject: I Need help with angles and parabolas

Say that I have a line at the bottom of the screen that gets the angle of the shot by pressing the arrow keys and fires along a parabola from that angle.(I want to beable to shoot the bullet and have it come back down smoothly, not just on an inverted angle like it does now)
code:

setscreen ("graphics:800;600")
var angle : int := 90
var distance : int := 40
var newx, newy, x, y : int
var input : string (1)
var rAngle : real

var power : int := 10
var ballX, ballY : int := 0
newx := maxx div 2
newy := 110
x := maxx div 2
y := 101

loop
    if hasch then
        getch (input)
        if input = chr (203) and angle < 180 then
            angle := angle + 2
            rAngle := angle * 3.14 / 180
            drawline (x, y, newx, newy, 0)
            newx := round (x + cos (rAngle) * distance)
            newy := round (y + sin (rAngle) * distance)
            drawline (x, y, newx, newy, 12)
        elsif input = chr (205) and angle > 0 then
            angle := angle - 2
            rAngle := angle * 3.14 / 180
            drawline (x, y, newx, newy, 0)
            newx := round (x + cos (rAngle) * distance)
            newy := round (y + sin (rAngle) * distance)
            drawline (x, y, newx, newy, 12)
        elsif input = chr (32) then
            ballX := newx
            ballY := newy
            for decreasing i : power .. 0
                drawfilloval (ballX, ballY, 10, 10, 0)
                newx := round (ballX + cos (rAngle) * distance)
                newy := round (ballY + sin (rAngle) * distance)
                ballX := newx
                ballY := newy
                distance := distance - 1
                drawfilloval (ballX, ballY, 10, 10, 2)
                delay (100)
            end for
            for i : 0 .. power
                drawfilloval (ballX, ballY, 10, 10, 0)
                newx := round (ballX + cos (rAngle) * distance)
                newy := round (ballY + sin (-rAngle) * distance)
                ballX := newx
                ballY := newy
                drawfilloval (ballX, ballY, 10, 10, 2)
                delay (100)
                distance := distance
            end for
            drawfilloval (ballX, ballY, 10, 10, 0)
            newx := round (x + cos (rAngle) * distance)
            newy := round (y + sin (rAngle) * distance)
        end if
    end if
end loop


Any Help is appreciated to the max. Smile
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: