Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to make proper jumping for turing platformer
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Turing BEEESD




PostPosted: Thu May 03, 2018 9:27 am   Post subject: How to make proper jumping for turing platformer

Trying to make a turing platformer game for a projects. Having trouble with the jumping mechanic, ive made a parabola but it only really jumps when on a certian area and dissapears if youre not on there. It also jumpes from below the line on the second jump. Is using a parabola the only way to jump and is their anyway I could make it fully jump without holding the jump button?

Heres

View.Set ("graphics:600;600,offscreenonly,nobuttonbar")
%parabola
var x2 : real := 0
var y2 : real := 0
%center
var x : real := 62.5
var y : real := 37.5
%input
var control : array char of boolean
%box
var boxx1 : int := 50
var boxy1 : int := 25
var boxx2 : int := 75
var boxy2 : int := 50
%Direction
var dx : real := 0
var dy : real := 0
%B
var p1x : int := 500
var p1y : int := 500
var eaten := false


loop

%borders
Draw.FillBox (0, 0, 1000, 1000, green)
Draw.Line (0, 37, 1000, 37, black)


%if below bottom
Draw.FillBox (x div 1, y div 1, (x + 20) div 1, (y + 20) div 1, black)
if Math.DistancePointLine (62.5, 37.5, p1x, p1y, p1x, p1y) < 35 then
eaten := true
end if

x := x + dx
y := y + dy
%%% input %%%
Input.KeyDown (control)

if control ('d') then
dx := 2
dy := 0
elsif control ('a') then
dx := -2
dy := 0
elsif control ('s') then
dx := 0
dy := 0
elsif control ('w') then
x := x + .4
y := -0.3 * (x - 100) ** 2 + 100

delay (30)
Draw.FillBox (x div 1, y div 1, (x + 20) div 1, (y + 20) div 1, black)

%Bottom

elsif Math.DistancePointLine (x, y, -50, 37.5, 1000, 37.5) < 47 then
y := 37.5



end if

View.Update
delay (15)
cls
end loop
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Sun May 06, 2018 12:21 am   Post subject: Re: How to make proper jumping for turing platformer

Turing BEEESD @ Thu May 03, 2018 10:27 am wrote:
is their anyway I could make it fully jump without holding the jump button?


just make a function or proc called when you hit your jump key, which will in itself continue the jump provided collision allows/controls allow it Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: