Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
I Need help with angles and parabolas
Author Message
Delta

Posted: 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.