Jumping
Blitz3D Forums/Blitz3D Beginners Area/Jumping
| ||
OK so I am still experimenting with a jump command... I did this in my game to move the dude up when the spacebar is pressed... only problem is if you hit the spacebar repeatedly you jump like the hulk (up and up and up but not away!) So I thought I would create an instance that you couldn't jump for a few seconds after the first spacebar press... you know to limit the jumpage... I did this: But it doesn't work. I set the flag jumpflag to 0 before starting the main program loop. I also plonked a bit after render that would show me the status of jumpflag... it stays at 1 all the time... 1 is true isn't it. Where does my logic fail? Keeping in mind that I am not an exteremely logical person! -RZ |
| ||
It appears by your indentation that you intend all of this If KeyHit(57)=True And jumpflag = False Then For jasc=1 To 90 TranslateEntity camera,+0,+1,+0 Next For jasc=90 To 1 MoveEntity camera,0,-1,0 Next oldtime=MilliSecs() If MilliSecs()< oldtime + 5000 Then jumpflag=True Else jumpflag = Falseto be contained within your If Keyhit(57) condition. To do that, you need to take the "Then For jasc=1 To 90" statement off of the IF line and move it down to the next line. You also need an ENDIF statement after the last line like this: If KeyHit(57)=True And jumpflag = False For jasc=1 To 90 TranslateEntity camera,+0,+1,+0 Next For jasc=90 To 1 MoveEntity camera,0,-1,0 Next oldtime=MilliSecs() If MilliSecs()< oldtime + 5000 Then jumpflag=True Else jumpflag = False Endif However, none of the above is going to work anyways because you are jumping your camera up 90 units and then down 90 units all within the same frame! Change your code to something like this: If KeyHit(57)=True And jumpflag = False jumpflag = True oldtime=MilliSecs() Endif If jumpflag = True TranslateEntity camera,+0,+2,+0 ;need 2 units in order to counteract gravity If MilliSecs() > oldtime+500 Then jumpflag=False EndifNotice that we are only moving the camera up. I reduced your jump time to 500ms. I doubt you actually wanted it to jump for 5 whole seconds? And then just let your gravity section of code bring him back down :) y#=y#-1Of course, actual gravity increases velocity with time, but what you have here will work for now... |
| ||
Thats what it is... all in the same frame??? OY!!! <--- SLAPPING HEAD and thereby increasing bald spot... Will try your idea. I can get him to jump but it is too fast! Thanks -Rook |
| ||
It does work!!! I get a "ENDIF without IF" on the last endif but I deleted that and changed the value of UP translation a bit and all works well!!! : ) Thank you WolRon! |