
-----------------------------------
noradII
Thu Jun 01, 2006 3:50 pm

need help with this program...
-----------------------------------
how am i suppose to make this program

setscreen ("graphics")          %puts the screen into graphics mode
var x, y : int := 0             %the variable for the dot
var dx, dy : int := 1           %the variable for bouncing off the wall
loop                            %starts the loop
    if whatdotcolor (x, y) not= 0 then      %if the dot hits the wall
    end if                                  
    drawfilloval (x, y, 10, 10, yellow)        %draws a black ball
    delay (4)                              %how fast the ball moves
    drawfilloval (x, y, 10, 10, white)      %"erases" the ball when it moves
    x := x + dx
    y := y + dy
    if x = 0 or x = maxx then               %makes the ball bounce off the wall
        dx := -dx
    end if
    if y = 0 or y = maxy then               %makes the ball bounce off the wall
        dy := -dy
    end if
end loop                                    %ends the loop

into a program that that have a ball that starts at the top of the screen so that its centre moves to the position it would move to under gravity in each step of the animation. 

Y = ymax  - ( Â½ )  *  a  *  t  ** 2


-----------------------------------
Cervantes
Thu Jun 01, 2006 4:11 pm


-----------------------------------
You could use the kinematic formulas, or you could actually simulate the gravity. Consider the following code:


View.Set ("offscreenonly")

var y := 300.0
var vy := 0.0
const Gravity := -0.3

loop

    y += vy             % Same as y := y + vy
    vy += Gravity       % Same as vy := vy + Gravity
    
    if y < 5 then
        vy *= -1        % Same as vy := vy * -1
    end if

    cls
    Draw.FillOval (200, round (y), 5, 5, black)
    View.Update
    delay (10)

end loop


-----------------------------------
noradII
Thu Jun 01, 2006 4:17 pm


-----------------------------------
o boy, where should i get a newer version of turing @_@, view.update dont work on my turing

-----------------------------------
Tony
Thu Jun 01, 2006 4:20 pm


-----------------------------------
you need version 4 or above. You can usually get it from your school. If they don't have it, let them know it's time to upgrade.

Otherwise you can get your own copy from Holtsoft. Or just take the command out. View.Update just draws from the double buffer to remove flicker in animation, doesn't change the actual program.

-----------------------------------
noradII
Thu Jun 01, 2006 4:25 pm


-----------------------------------
cool, thx...gotta remember to bring a disk to school next day [evil laugh]
