setscreen ("offscreenonly")
 
setscreen ("nobuttonbar")
 
setscreen ("graphics:640;480")
 
var key : array char of boolean
 
var chief : array 1 .. 5 of int
 
var ground, vcap, x, y, vx, vy, ax, g, charx, chary, carvx : real
 
const gravity := 0.06
 
const decel := 0.95
 
const mcrad := 5
 
var platformx1 : array 1 .. 6 of int := init (50, 100, 150, 200, 250, 300)
 
var platformx2 : array 1 .. 6 of int := init (60, 110, 160, 210, 260, 310)
 
var platformy1 : array 1 .. 6 of int := init (50, 100, 150, 200, 250, 300)
 
var platformy2 : array 1 .. 6 of int := init (60, 110, 160, 210, 260, 310)
 
 
 
var pos : int := 3
 
% chief (1) := Pic.FileNew ("MC sprite lsiderun.bmp")
 
% chief (2) := Pic.FileNew ("MC sprite lside.bmp")
 
% chief (3) := Pic.FileNew ("MC sprite.bmp")
 
% chief (4) := Pic.FileNew ("MC sprite rside.bmp")
 
% chief (5) := Pic.FileNew ("MC sprite rsiderun.bmp")
 
x := 10
 
y := 10
 
vx := 0
 
ax := .5
 
vy := 0
 
 
 
% PROCEDURES
 
 
procedure samplelevel
 
    for i : 1 .. 6
 
        drawfillbox (platformx1 (i), platformy1 (i), platformx2 (i), platformy2 (i), black)
 
    end for
 
end samplelevel
 
procedure movement
 
    if key ('d') and vx <= 5 and y = 10 then
 
        vx += 0.059
 
        pos := 4
 
    elsif key ('a') and vx >= -5 and y = 10 then
 
        vx -= 0.059
 
        pos := 2
 
    else
 
        vx *= decel
 
    end if
 
end movement
 
procedure velocity
 
    x += vx
 
    y += vy
 
end velocity
 
procedure jump %fix this part by adding horizontal motion
 
    if y > mcrad then
 
        vy -= gravity
 
    else
 
        vy := 0
 
    end if
 
    if vy = 0 and key ('w') then
 
        vy := 2
 
    end if
 
    % if key ('w') then
 
    %     vy += ax
 
    %
 
    % % end if
 
    % % if round (y) > 10 then
 
    % %     ax += gravity %Fix these
 
    % % end if
 
    % if round (y) <= 0 then
 
    %     vy := 0
 
    % end if
 
end jump
 
% procedure right
 
%     if key (KEY_RIGHT_ARROW) and vx <= 5 and y = 10 then
 
%         vx += 0.099
 
%         pos := 4
 
%     else
 
%         vx *= decel
 
%     end if
 
% end right
 
% procedure left
 
%     if key (KEY_LEFT_ARROW) and vx >= -5 and y = 10 then
 
%         vx -= 0.099
 
%         pos := 2
 
%     else
 
%         vx *= decel
 
%     end if
 
% end left
 
procedure background
 
    drawfillbox (0, 0, maxx, maxy, black)
 
    drawfillbox (10, 10, 630, 470, white)
 
end background
 
procedure endofscreendetection
 
    if round (x) >= 633 and round (x) <= 640 then
 
        x := 8
 
    end if
 
    if round (x) <= 7 and round (x) >= 0 then
 
        x := 632
 
    end if
 
end endofscreendetection
 
 
 
%IMPLEMENTATION
 
 
 
 
 
loop
 
    Input.KeyDown (key)
 
    cls
 
    movement
 
    endofscreendetection
 
    jump %comment this to allow horizontal motion using a and d keys
 
    velocity
 
    drawfilloval (round (x), round (y), 2, 2, black)
 
    % Pic.Draw (chief (pos), round (x), round (y), picMerge)
 
    delay (10)
 
    View.Update
 
end loop
 
  |