
-----------------------------------
altdas
Mon Jan 21, 2008 6:20 pm

Stay Alive - Game Help
-----------------------------------
Hello, I'm altdas and I need a little Turing help. I'm pretty new to Turing, almost done a course in it, and for my final project, well, I'm a little stuck with my game.

This is my project so far, and I am having a little problems with the animation, All the images and files you need are in the attached file, could you please look at some of the things it is doing, and tell me how to fix them? You will easily be able to see what is wrong with it.


% Screen Settings
var win := Window.Open ("graphics:644;404,offscreenonly")
var chars : array char of boolean

% ***************************************
% Variables & Constants
% ***************************************
% Physics
const RUN_SPEED := 10
const JUMP_SPEED := 15
const GRAVITY := 1

% Map
const GROUND_HEIGHT := 1
const WALL_LEFT := 1
const WALL_RIGHT := 573

% Character; Position
var posx, posy : int
var velx, vely : real

% Character; Physics Tracker
posx := 5
velx := 0
posy := 5
vely := 0

% Scene background
var background : string
background := "background.jpg"

% Character
var mc_air_right : string
mc_air_right := "mc_air_right.jpg"
var mc_air_left : string
mc_air_left := "mc_air_left.jpg"

% Character Running Right
const mc_run_right := "mc_run_right.gif"
var numFrames_right : int := Pic.Frames (mc_run_right)
% Load the picture
var delayTime_right : int
var pics_right : array 1 .. numFrames_right of int
Pic.FileNewFrames (mc_run_right, pics_right, delayTime_right)

% Character Running Left
const mc_run_left := "mc_run_left.gif"
var numFrames_left : int := Pic.Frames (mc_run_left)
% Load the picture
var delayTime_left : int
var pics_left : array 1 .. numFrames_left of int
Pic.FileNewFrames (mc_run_left, pics_left, delayTime_left)

%Rockets
var ranrocket : int

% ***************************************
% Main Program
% ***************************************
View.Set ("graphics,offscreenonly")
setscreen ("graphics")
% Pic.ScreenLoad (background, 0, 0, picCopy)

process character ()
    loop

        % In-game menu
        Input.KeyDown (chars)
        if chars ('q') then
            exit
        end if

        Input.KeyDown (chars)
        if chars ('i') then
            put "Info"
            % Instructions go here
        end if

        % Making the Character move
        if chars (KEY_LEFT_ARROW) then
            velx := -RUN_SPEED
        elsif chars (KEY_RIGHT_ARROW) then
            velx := RUN_SPEED
        else
            velx := 0
        end if

        % Character must be on the ground to jump
        if chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT then
            vely := JUMP_SPEED
        end if

        % Gravity working with velocity
        vely -= GRAVITY
        posx += round (velx)
        posy += round (vely)

        % Borders | ground, and walls
        if posy < GROUND_HEIGHT then
            posy := GROUND_HEIGHT
            vely := 0
        end if

        if posx = WALL_RIGHT then
            posx := WALL_RIGHT
            velx := 0
        end if

        % Draw Borders
        % Draw.Line (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, 0)

        % Delay render, this is needed for fast computers
        delay (15)

        View.Update

    end loop
end character



fork character
loop

    % Character Display
    if velx = 0 then
        for i : 1 .. 1
            Pic.DrawFrames (pics_left, posx, posy, picCopy, upper (pics_left), 70, false)
        end for
    end if

    if posy >= 5 and velx = 5 and velx >= 0 then
        Pic.ScreenLoad (mc_air_right, posx, posy, picCopy)
    end if

    View.Update
    Draw.Cls

end loop

fork character
loop

    randint (ranrocket, 1, 843)

end loop


-----------------------------------
isaiahk9
Mon May 05, 2008 5:42 pm

Re: Stay Alive - Game Help
-----------------------------------
what do you mean - on the laptop I'm working off now, it's working fine.
