Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Need help with Turing platforms Please (Urgent)
Author Message

Posted: Sat Jun 09, 2018 3:06 pm   Post subject: Need help with Turing platforms Please (Urgent)

What is it you are trying to achieve?

i am trying to make platforms where i could jump and stay on when i am at a certain x coordinate

What is the problem you are having?

whenever the program is started it does not on the platform and falls to the floor

Describe what you have tried to solve this problem

i have tried many things but do not know how to describe what i am doing since i started Turing 1 mount ago

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

setscreen ("graphics:1211, 607")

const GROUND_HEIGHT := 63
const RUN_SPEED := 10
const JUMP_SPEED := 30
const GRAVITY := 2.0

var chars : array char of boolean

% player position and velocity
var posx, posy : int
var velx, vely : real

posx := 20
velx := 0
posy := 400
vely := 0

loop
Input.KeyDown (chars)
if chars ('q') then
exit
end if

% to make the player move
if chars (KEY_LEFT_ARROW) then
velx := -RUN_SPEED
elsif chars (KEY_RIGHT_ARROW) then
velx := RUN_SPEED
else
velx := 0
end if

% remember, in order to jump you MUST be on the ground when pressing UP
if chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT or posy = 148 or posy = 231 or posy = 314 or posy = 397 then
vely := JUMP_SPEED
end if

% subtract your "gravity" constant from the velocity EACH frame
vely -= GRAVITY
posx += round (velx)
posy += round (vely)

% simple "collision" check. just makes sure the player stays above ground
if posy < GROUND_HEIGHT then
vely := 0
elsif posy = 148 then
posy := 148
vely := 0
elsif posy = 231 then
posy := 231
vely := 0
elsif posy = 314 then
posy := 314
vely := 0
elsif posy = 397 then
posy := 397
vely := 0
end if

% different colours just to illustrate whether or not you may jump
if posy = 63 or posy = 148 or posy = 231 or posy = 314 or posy = 397 then
drawfillbox (posx - 10, posy, posx + 10, posy + 20, green)
else
drawfillbox (posx - 10, posy, posx + 10, posy + 20, red)
end if
drawbox (104, 21, 559, 63, brightred)
drawbox (1100, 21, 646, 63, brightred)

drawbox (104, 135, 559, 148, brightred)
drawbox (1100, 135, 646, 148, brightred)

drawbox (104, 218, 559, 231, brightred)
drawbox (1100, 218, 646, 231, brightred)

drawbox (104, 301, 559, 314, brightred)
drawbox (1100, 301, 646, 314, brightred)

drawbox (104, 384, 559, 397, brightred)
drawbox (1100, 384, 646, 397, brightred)

drawbox (24, 1, 1180, 527, brightred)
drawline (104, GROUND_HEIGHT, 1100, GROUND_HEIGHT, blue)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if whatdotcolor (posx, posy) = 3 then
posy := 220
vely := 1
end if

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View.Update
delay (85)
cls
end loop

 Turing:

Please specify what version of Turing you are using

Insectoid

Posted: Sun Jun 10, 2018 7:25 am   Post subject: RE:Need help with Turing platforms Please (Urgent)

Your code only registers the platforms when the character is exactly on them. How often is that going to happen when you're moving by 20 or more pixels at a time?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: