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

Username:   Password: 
 RegisterRegister   
 Jump help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mayb123




PostPosted: Thu Nov 22, 2007 12:28 pm   Post subject: Jump help

Hello fellow programmers. i'm trying to make a jumping procedure where height is determined by how long you hold the 'w' key, but it adds a fraction of the speed, but say, if you let go partway up the jump, the arc of the jump is lower and you fall down. for example, in N-Game, if anyone here has played it, the longer you hold the jump button, the higher you jump, but there's still a limit. what kind of code would i use?

code:
procedure jump %fix this part by adding horizontal motion

if y > mcrad then
        vy -= gravity
    else
        vy := 0
        end if
    if vy = 0 and key ('w') then
vy+=3
    end if   
   
%     if vy=0 and key ('w') and y>=platformx2(1) and y>= platformy1(2)
%     % if key ('w') then
%     %     vy += ax
%     %
%     % % end if
%     % % if round (y) > 10 then
%     % %     ax += gravity %Fix these
%     % % end if
%     % if round (y) <= 0 then
%     %     vy := 0
%     % end if
 end jump
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Thu Nov 22, 2007 1:40 pm   Post subject: RE:Jump help

Let's say you have a force variable, called force, and a gravity constant. When in the air, subtract your gravity constant no matter what. Then, check to see if the jump key is being pressed, if it is, add your force to the jump, the decrement the force.
Mayb123




PostPosted: Fri Nov 23, 2007 12:12 am   Post subject: Re: RE:Jump help

Clayton @ Thu Nov 22, 2007 1:40 pm wrote:
Let's say you have a force variable, called force, and a gravity constant. When in the air, subtract your gravity constant no matter what. Then, check to see if the jump key is being pressed, if it is, add your force to the jump, the decrement the force.


sorry, but i'm just having a bit of trouble wrapping my head around where to put in code to do that. please elaborate
petree08




PostPosted: Fri Nov 23, 2007 2:05 pm   Post subject: RE:Jump help

hows about

if Key is pressed then
if JumpForce < (max force) then

JumpForce := JumpForce + (whatever you increase it by)

end if

end if
if Key is not pressed then the Jumpforce = 0

well that's a rough outline
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  [ 4 Posts ]
Jump to:   


Style:  
Search: