All pastes #1417905 Raw Edit

Anonymous

public text v1 · immutable
#1417905 ·published 2009-05-10 01:33 UTC
rendered paste body
% Victoria Esnard
% Chapter 7 Question 6
% April 17th 2009


% try to finish this one off by looking at spencer's
% just get daytons helpp, also add in paramiters on procedures



setscreen ("graphics")

% variable for counting the number of loops
var count : int := 0
% varables to moves the loading dot over horizontally
var xdot : int := 60
% variables for fonts used in program
var font1, font2 : int
font1 := Font.New ("shruti:12:bold")
font2 := Font.New ("shruti:40:bold")
% variable for time delay
var tim1, tim2 : int
tim1 := 50
tim2 := 500
var bg : int := 53
% variables to move the ball
var x : int := 710
var y : int := 305
var y2 : int := 305
var t : int := 0
% variables for window settings( size of window, buttonbar or no, and window title.)
var lowin := Window.Open ("graphics:400;50,nobuttonbar,title:Please Wait")
var mainwin := Window.Open ("graphics:700;500,buttonbar,title:Cliff Physics")

% ADDON:loading procedure is done. Add a moving ball along the bottom or a loading bar
% ADDON:increase by 8 % each time for loading bar
% ADDON:or have a ball rolling along the bottom

% Procedure that displays a small loading screen. This allows the program to look more offical.
proc loading
    loop
        Window.Show (lowin)
        Window.SetActive (lowin)
        Window.Hide (mainwin)
        put "Loading"
        loop
            drawdot (xdot, 38, 7)
            delay (tim2)
            xdot := xdot + 5
            count := count + 1
            exit when xdot = 80
        end loop
        xdot := 60
        cls
        exit when count = 12
    end loop
end loading
% procedure for the introduction to Cliff Physics
proc intro
    % Hides the loading bar window and hows the main window
    Window.Show (mainwin)
    Window.SetActive (mainwin)
    Window.Hide (lowin)
    % FIX UP: fix spelling mistakes
    % Displays a pictures of a cliff and a small explanation of whats going to happen.
    Pic.ScreenLoad ("cliff for C7 Q6.JPG", 0, -130, picMerge)
    Font.Draw ("Welcome to Cliff Physics", 40, 460, font2, 9)
    Font.Draw ("Cliff Physics is a program used to show you how a rock will react if it falls off a cliff.", 35, 440, font1, 9)
    Font.Draw ("For all intentive purposes, the rock may look similar to a ball.", 120, 420, font1, 9)
    % ADDON:add in the options to chose what the ball is made of so that program can be completely physics
end intro


% Procedure to allow the user to move onto the next screen by pressing anykey.
procedure anykey
    var line : string (1)
    locatexy (230, 400)
    put "Please press any key to contine."
    locatexy (500, 400)
    getch (line)
    cls
end anykey


% ADDON: add the choices for gravity difference here
proc gvariables
    put "Physics is the study"
end gvariables

% ADDON:add blue bg for sky, and make the text appear in clouds

% shows the center coords of the ball in the top left hand part of screen.
proc show_center_of_ball
    colorback (bg)
    locatexy (90, 490)
    put "Ball Location: (",x, ",  ", y,")"
end show_center_of_ball

% procedure that draws the background, cliff, clouds, and sun.
proc cliff_drawings
    % Sky
    drawfillbox (0, 0, maxx, maxy, 53)
    % Cliff
    drawfillbox (maxx, 0, 300, 285, 27)
    % Clouds
    drawfilloval (600, 450, 50, 20, 31)
    drawfilloval (580, 430, 50, 20, 31)
    drawfilloval (195, 395, 35, 20, 31)
    drawfilloval (230, 405, 40, 20, 31)
    % Sun
    drawfilloval (0, maxy, 70, 70, 14)
end cliff_drawings

% procedure that moves the ball along the top of the cliff
proc moving_ball_part1
    loop
        drawfilloval (x, y2, 20, 20, 12)
        delay (tim1)
        drawfilloval (x, y2, 20, 20, 53)
        x := x - 5
        show_center_of_ball
        exit when x = 300
    end loop
end moving_ball_part1
% procedure that moves the ball don off the cliff with attention to gravity


proc moving_ball_part2
loop
        drawfilloval (x, y2, 20, 20, 12)
        delay (tim1)
        drawfilloval (x, y2, 20, 20, 53)
        var yc2 : real := 0
        yc2 := yc2 + 0.08
        % fix this so that the eqn qorks propery
        % should be something lie y := 305 - .5*9.81*t^2
        y2 := (round (-9.81 * 0.5 * yc2 * yc2) + 305)
        
    end loop
end moving_ball_part2

% Procedure that takes all the procedures and calls them with only one procedure.
proc Call_All
    loading
    intro
    anykey
    show_center_of_ball
    cliff_drawings
    moving_ball_part1
    moving_ball_part2
end Call_All

Call_All