More Realistic Jump

BlitzMax Forums/BlitzMax Beginners Area/More Realistic Jump

W(Posted 2006) [#1]
well Hello...fellow programmers, I am in need of assistance concerning the development of a more realistic method of allowing a character in my program to jump, so far I have this sloppy bit of code--

If KeyHit(57) ;Jumping
jumptimer = MilliSecs() + 1.5
uptimer = MilliSecs() + 1
	
While jumptimer > MilliSecs()
	While uptimer > MilliSecs()
		TranslateEntity user\model,0,0,.001
	Wend 
Wend
 	
EndIf


As you can see it's not all that impressive, and I could really use a helping hand, Thanks Guys!!


Grey Alien(Posted 2006) [#2]
Well you need to have a gravity constant. You also need your sprite to have a yspeed field as well as a normal y field. When the jump is initiated you set your yspeed to be a certain value in pixels per frame (need to tweak this value yourself). Then each frame, you need to reduce the yspeed by gravity and also add yspeed onto y. At a certain point, yspeed will go -ve and the sprite will start to drop down. At somepoint your "platform collision code" or whatever should detect that the sprite is now on solid ground and set the yspeed to 0.


CS_TBL(Posted 2006) [#3]
looks like B3d code btw..


Grey Alien(Posted 2006) [#4]
I wondered that too ... "TranslateEntity"


CS_TBL(Posted 2006) [#5]
mhoa, more like noticing the \ seperator for type-fields :P TranslateEntity could be a function made in Bmax as well.. ^_^


Grey Alien(Posted 2006) [#6]
I thought that too, and didn't say anything until I saw your "it's blitz3d code" post. I didn't notice the \ because I've been using plus for 15 months! :-)


CS_TBL(Posted 2006) [#7]
I figure you mean 'max', not 'plus', since plus has \ seperators. ^__^


Grey Alien(Posted 2006) [#8]
No I meant I didn't notice the \ as *abnormal* because I've been using PLUS for 15 months ^___^


CS_TBL(Posted 2006) [#9]
o_O

O_o

O_O

oh! Wait, I see.. ^_^

* runs to collide with wall @ 20km/h


Grey Alien(Posted 2006) [#10]
clarity is such a beautiful thing. Hey "W" never replied to say thanks or stop derailing my thread :-)