Platform Game Help
Author |
Message |
Turing Man
|
Posted: Tue Nov 16, 2010 9:05 pm Post subject: 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)
Turing: |
% 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
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Wed Nov 17, 2010 12:57 pm Post subject: 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 <= 0 then %%if players x location is (off the map or at 0 of map)
x := 1 %%put him on the map so he can't run off it
end if
if walkingLeft then %%your basic set up for changing pictures
draw walkingLeft
elsif walkingRight then
draw walkingRight
else
draw standing
end if
end if
%%same idea for right X axis,
%%set him back on the map if he goes to run off, before he's drawn
%%And again, same with his JUMP Height, Except this uses "Y" Axis.
|
|
|
|
|
|
|
TerranceN
|
Posted: Wed Nov 17, 2010 3:52 pm Post subject: RE:Platform Game Help |
|
|
If what the OP means is making it so you cannot jump infinitely, then just think of it like real life. What is the biggest condition required for jumping? It is having something to jump off of. You can tell when the person (or w/e your picture is) is on the ground by when it is able to fall. Use a boolean value to only allow the person to jump when it is on the ground. |
|
|
|
|
|
Turing Man
|
Posted: Wed Nov 17, 2010 4:10 pm Post subject: RE:Platform Game Help |
|
|
Thank you everybody. But I figured it out on my own
But I did take your border idea Token.
Thanks.
-- Ray |
|
|
|
|
|
|
|