Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / need help on keyboard entries!!

Author
Message
yacine de lucia
19
Years of Service
User Offline
Joined: 19th Apr 2006
Location:
Posted: 20th Apr 2006 02:52
i've got a probleme can some one help me on coding a very simple stuff but very hard to me:
1/how do we code a simple 3d jump(if you just animate a jump and
put if inkey$()=stuff then play object a,x,y it won't work because it is just an animation and not a object positiony(stuff)moving
2/how we can code if a button is just pushed and not if a button is being hold
(if inkey$()=stuff just means is stuff is being hold)

so thank you in advance

the creator
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 20th Apr 2006 06:16 Edited at: 20th Apr 2006 07:05
1. When you jump, you have to alter the Y position of the object in 3D space at the same time as continuing in the current direction and playing the jump animation.

To make it look more realistic, you don't just set the Y position to the 'top' value, you change it gradually. Start by having a very small floating point value in a variable (like Velocity# = .1) which you add to the object's Y position.

You then add to the velocity value during the jump giving the appearence of acceleration.

When it reaches a certain height, you start reducing the value of velocity so the accelleration decreases. This gives the effect of gravity taking effect.

If you continue decreasing the velocity, it eventually becomes negative and applying this to the object's Y position will make it fall back down to earth - increasing in speed as it would in real life. Stop altering the object's Y position when you hit the floor and reset the velocity value ready for the next jump.

Some example code (deliberately simplified to demonstrate the principle):



2. If you need a key to be held down rather than just pressed and released to do something, then simply use a Repeat Until loop something like this:



TDK_Man

yacine de lucia
19
Years of Service
User Offline
Joined: 19th Apr 2006
Location:
Posted: 21st Apr 2006 20:39
thanks a lot it really had help i just used the parts i need from
your code and used it in my stuff

but i still have a little probleme i'am trying to deal with it my self but it could save me much time if you just explain what we can do it
1/i have the animation of the character jumping
so whent i put if spacekey()=1 then play object 1,20,40
he just dont move!!!
2/when i replace play object by loop object it moves
but my first probleme was that if you release spacebar the animation stops.but when i place loop object in the loop you created for jumping as well,then it continues playing until y position=0 so no probleme
3/now the animation is divided in three parts the pre jump the jumpinprogress and the jump finish (you know crouching knees and all the stuf), so what i want is if spacebar()=1
it will first play object 1(first part of animation) after it will
jump(it's know when the y position changes and play the secand part of the animation)and finally play the last part of the animation!
so that's all;(i know i'am just new to programming and this stuff is may be obvius to you but it really make me confuse + when i hear that there is a language that is called blitz3d and may be have more possibilities and more exact functions to what you really want i get's me reaaly confused)

the creator
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 28th Apr 2006 20:05
From what I've seen in Blitz, I can say that it's fairly similar to DB in capabilities, but I think that DB is a little easier to learn/use.

There's not a lot in it though to be honest.

TDK_Man

Dodic
19
Years of Service
User Offline
Joined: 6th Nov 2005
Location: SNM (Serbia&Montenegro)
Posted: 29th Apr 2006 04:50
Quote: "From what I've seen in Blitz, I can say that it's fairly similar to DB in capabilities, but I think that DB is a little easier to learn/use."


I sure agree on that one, it is quite easier to learn/use.


Login to post a reply

Server time is: 2025-05-23 14:42:11
Your offset time is: 2025-05-23 14:42:11