| Trying to make a parabolic jump trail for characters mario-like game :( 
 
	 
	
		| Author | Message |   
		| blackheart5598 
 
 
 
 
 | 
			
				|  Posted: Mon Jan 13, 2014 6:08 pm    Post subject: Trying to make a parabolic jump trail for characters mario-like game :( |  |   
				| 
 |  
				| What is it you are trying to achieve? I am trying to make a parabolic jump trail for my characters so that they don't all jump in the same way and height which makes it look awkward.
 
 
 What is the problem you are having?
 I am unable to do what I said above
   
 
 Describe what you have tried to solve this problem
 I have tried using a parabolic formula of y=x**2 but that doesn't seem to work.
 
 
 Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
 here is my jump procedure, if it is not enough i don't ming giving more information about my game. Thanks in advance
 
 
 	  | Turing: |  	  | 
procedure jump
    for  count : 1 . . 180 by 5
        Input.KeyDown ( chars)
        if  chars ('d') then 
            d :=  d + 25
            if (100  + d)  >= 300 then 
                picx :=  picx - 10
            end if
        end if
        if  chars ('a') then 
            d :=  d - 25
        end if
        if ((70  + d)  <= 0) then 
            d := 0
        end if
        if ((160  + d)  >= maxx) then 
            d := 1140
        end if 
        w := 0 
        w += 150 * (sind ( count))
        Draw.FillOval (100  + d, 200  + round ( w), 30 , 40 , 68)
        Draw.FillBox (72  + d, 240  + round ( w), 160  + d, 230  + round ( w), red)
        Draw.FillArc (102  + d, 240  + round ( w), 30 , 30 , 0 , 180 , brightred)
        Draw.FillOval (87  + d, 210  + round ( w), 5 , 5 , black)
        Draw.FillOval (115  + d, 210  + round ( w), 5 , 5 , black)
        Draw.FillArc (105  + d, 190  + round ( w), 10 , 10 , 0 , 20 , black)
        Draw.FillArc (100  + d, 190  + round ( w), 10 , 10 , 160 , 180 , black)
        Draw.FillArc (105  + d, 175  + round ( w), 15 , 15 , -30 , 30 , black)
        Draw.FillBox (70  + d, 90  + round ( w), 130  + d, 160  + round ( w), brightred)
        Draw.FillArc (105  + d, 160  + round ( w), 25 , 25 , 0 , 25 , red)
        Draw.FillArc (95  + d, 160  + round ( w), 25 , 25 , 155 , 180 , red)
        Draw.Line (70  + d, 90  + round ( w), 70  + d, 30  + round ( w), black)
        Draw.Line (100  + d, 90  + round ( w), 100  + d, 30  + round ( w), black)
        Draw.Line (101  + d, 90  + round ( w), 101  + d, 30  + round ( w), black)
        Draw.Line (130  + d, 90  + round ( w), 130  + d, 30  + round ( w), black)
        Draw.FillOval (60  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -40  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -140  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -240  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -340  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillBox (40  + d, 70  + round ( w), 100  + d, 80  + round ( w), red)
        Draw.FillBox ( -60  + d, 70  + round ( w), 0  + d, 80  + round ( w), red)
        Draw.FillBox ( -160  + d, 70  + round ( w),  -100  + d, 80  + round ( w), red)
        Draw.FillBox ( -260  + d, 70  + round ( w),  -200  + d, 80  + round ( w), red)
        Draw.FillBox ( -360  + d, 70  + round ( w),  -300  + d, 80  + round ( w), red)
        View.Update
        delay (25)
        Draw.FillOval (100  + d, 200  + round ( w), 30 , 40 , colorbg)
        Draw.FillBox (72  + d, 240  + round ( w), 160  + d, 230  + round ( w), colorbg)
        Draw.FillArc (102  + d, 240  + round ( w), 30 , 30 , 0 , 180 , colorbg)
        Draw.FillOval (87  + d, 210  + round ( w), 5 , 5 , colorbg)
        Draw.FillOval (115  + d, 210  + round ( w), 5 , 5 , colorbg)
        Draw.FillArc (105  + d, 190  + round ( w), 10 , 10 , 0 , 20 , colorbg)
        Draw.FillArc (100  + d, 190  + round ( w), 10 , 10 , 160 , 180 , colorbg)
        Draw.FillArc (105  + d, 175  + round ( w), 15 , 15 , -30 , 30 , colorbg)
        Draw.FillBox (70  + d, 90  + round ( w), 130  + d, 160  + round ( w), colorbg)
        Draw.FillArc (105  + d, 160  + round ( w), 25 , 25 , 0 , 25 , colorbg)
        Draw.FillArc (95  + d, 160  + round ( w), 25 , 25 , 155 , 180 , colorbg)
        Draw.Line (70  + d, 90  + round ( w), 70  + d, 30  + round ( w), colorbg)
        Draw.Line (100  + d, 90  + round ( w), 100  + d, 30  + round ( w), colorbg)
        Draw.Line (101  + d, 90  + round ( w), 101  + d, 30  + round ( w), colorbg)
        Draw.Line (130  + d, 90  + round ( w), 130  + d, 30  + round ( w), colorbg)
        Draw.FillOval (60  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -40  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -140  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -240  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillOval ( -340  + d, 50  + round ( w), 20 , 20 , 68)
        Draw.FillBox (40  + d, 70  + round ( w), 100  + d, 80  + round ( w), red)
        Draw.FillBox ( -60  + d, 70  + round ( w), 0  + d, 80  + round ( w), red)
        Draw.FillBox ( -160  + d, 70  + round ( w),  -100  + d, 80  + round ( w), red)
        Draw.FillBox ( -260  + d, 70  + round ( w),  -200  + d, 80  + round ( w), red)
        Draw.FillBox ( -360  + d, 70  + round ( w),  -300  + d, 80  + round ( w), red)
        if (100  + d)  >= 700 then 
            picx :=  picx - 5
        end if
        if  picx <= -2000 then 
            picx := 0
        end if
        Pic.Draw ( backgroundlevel1, picx, 0 , picCopy)
    end for
end  jump
 | 
 
 Please specify what version of Turing you are using
 latest version
 
   |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| keyboardwalker 
 
  
 
 
 | 
			
				|  Posted: Mon Jan 13, 2014 8:59 pm    Post subject: Re: Trying to make a parabolic jump trail for characters mario-like game :( |  |   
				| 
 |  
				| This may give you the desired effect and there isn't any exponentiation. 
 	  | Turing: |  	  | 
const EARTHSGRAVITY := 9 .80665
var  ballXLoc, ballYLoc : real
var  xVelocity, yVelocity : real 
ballXLoc := 15 
ballYLoc := 15
%Inceasing the xVelocity will change how far to the right the ball will go. 
xVelocity := 30
%Inceasing the yVelocity will change how high the ball will go. 
yVelocity := 70
loop
    drawfilloval (round ( ballXLoc), round ( ballYLoc), 5 , 5 , red)
    drawline (round ( ballXLoc), round ( ballYLoc), round ( ballXLoc + xVelocity), round ( ballYLoc + yVelocity), red)
    delay (50)
    %Moving the ball's location 
    ballXLoc :=  ballXLoc + xVelocity
 
    ballYLoc :=  ballYLoc + yVelocity
    %Applying the force of gravity to the vertical component of the ball's velocity. 
    yVelocity -=  EARTHSGRAVITY %usually you would * mass but it's unecessary in this case.
    exit when  ballXLoc < 0 or  ballYLoc < 0
end loop | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| evildaddy911 
 
 
 
 
 | 
			
				|  Posted: Mon Jan 13, 2014 9:00 pm    Post subject: RE:Trying to make a parabolic jump trail for characters mario-like game :( |  |   
				| 
 |  
				| youre looking at this wrong. its actually quite simple. here some psuedocode: 
 	  | code: |  	  | 
y : real % the current height of the character
 y_vel : real % how many units to move the character each time
 
 y_velocity = 5
 loop
 if y > ground
 y = y + y_velocity % move the character upwards 'y_vel'
 y_velocity = y_vel - 0.5 % decrement y_vel by a constant
 else
 y_vel = 0 % set y_vel to zero
 end loop
 
 | 
 
 EDIT: it seems somebody beat me to the punch...
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Raknarg 
 
  
 
 
 | 
			
				|  Posted: Mon Jan 13, 2014 9:07 pm    Post subject: RE:Trying to make a parabolic jump trail for characters mario-like game :( |  |   
				| 
 |  
				| As the others have suggested, think about how gravity works in real life. It doesn't matter what your horizontal direction is, that will stay constant. However, what happens when you jump? You move upwards at a certain initial speed, and then the earth is pulling you down at a constant rate. 
 Try converting that into code.
 
 If the player jumps, set the y direction speed up.
 
 While the player is in the air (think about what that means in terms of x and y), constantly pull him towards the ground.
 
 @keyboardwalker & evildaddy giving a new person in programming a bunch of code to help him out is giving him a fish instead of teaching him how o fish.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |