
-----------------------------------
Turing Man
Tue Nov 16, 2010 9:05 pm

Platform Game Help
-----------------------------------
What is it you are trying to achieve?
Well. I am new to Turing.
I am taking a Grade 10 course on it.
I have just came across one little small thing.
It may seem stupid to you higher people.
But here it is.
I need to know how to set a max high to jump, and I would also like to know how to add Borders so my sprite cannot go off screen on the x axis.

Help would be appreciated. Thank you. :)
-- Ray

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



% Raymond Schmidt
% November 16th, 2010


% Platform Game %

setscreen ("graphics:800;370")
setscreen ("offscreenonly")

% Global Variables %

var font : int := Font.New ("comic sans ms:20")

% Sprite Movement Variables %
var standingR : int := Pic.FileNew ("MarioFireStand.bmp") % R = RIGHT %
var walkingR : int := Pic.FileNew ("MarioFireWalk.bmp")
var jumpStanceR : int := Pic.FileNew ("MarioFireJump.bmp")
% --------------------------------------- %
% Main Program %

% Scaling Pictures %
standingR := Pic.Scale (standingR, 20, 40)
walkingR := Pic.Scale (walkingR, 20, 40)
jumpStanceR := Pic.Scale (jumpStanceR, 20, 40)

% Mirroirng The Right Pictures %
var jumpStanceL : int := Pic.Mirror (jumpStanceR)    % L = LEFT %
var walkingL : int := Pic.Mirror (walkingR)
var standingL : int := Pic.Mirror (standingR)

var maxJump : int := 80
var currentS := standingR   % Starting Picture %  % currentS =  CURRENT STANCE %
var x, y : int
x := 50
y := 300
var keys : array char of boolean % Keeps track of the keyboard %
% ------------------------------------------ %

loop

    % Drawing The Platform %
    cls
    drawfillbox (0, 0, 200, 10, 12)
    drawfillbox (250, 50, 350, 60, 12)
    drawfillbox (400, 50, 550, 60, 12)


    % Gravity %

    if whatdotcolour (x, y - 2) not= 12 and whatdotcolour (x + 20, y - 2) not= 12 then
        y := y - 4
    end if

    % Movement Of Sprite %

    Input.KeyDown (keys)

    % If Right Arrow Key is Pressed Down %
    if keys (KEY_RIGHT_ARROW) then
        x := x + 10

        % This will switch between the pictures %
        if currentS = standingR then
            currentS := walkingR
        else
            currentS := standingR
        end if

    end if

    % If Left Arrow Key is Pressed Down %
    if keys (KEY_LEFT_ARROW) then
        x := x - 10

        % This will switch between the pictures %
        if currentS = standingL then
            currentS := walkingL
        else
            currentS := standingL
        end if

    end if

    % If Up Arrow Key is Pressed Down %
    if keys (KEY_UP_ARROW) then
        y := y + 80
        

        if currentS = standingL then
            currentS := jumpStanceL
        elsif currentS = standingR then
            currentS := jumpStanceR
        else
            currentS := standingR
        end if
    end if

    
    Pic.Draw (currentS, x, y, picMerge)

    View.Update
    delay (50)

end loop




Please specify what version of Turing you are using


-----------------------------------
TokenHerbz
Wed Nov 17, 2010 12:57 pm

RE:Platform Game Help
-----------------------------------
below is the concept of what to do and how it works. read it carefully.
[code]
if keys (KEY_LEFT_ARROW) then
    x := x - 10 %% 10 being speed (put it as a variable speed)
    if x 