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 / walk to run

Author
Message
LOTR HITMAN
20
Years of Service
User Offline
Joined: 2nd Nov 2004
Location:
Posted: 11th Apr 2007 02:33
i was wondering how i can make my character seem to run by simply moving faster. here is the code i have for it right now.


i want to be able to push the left shift key and make it speed everything up to seem as if it were running. any ideas?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Apr 2007 09:30
You seem to be using the literal values 3 and -3 for the amount you move when using the cursor up and down key.

If you used a variable like 'Speed', you could set it to 3 initially and when the Shift key is pressed set it to 6. On releasing the Shift key you would set it back to 3.

TDK_Man

LOTR HITMAN
20
Years of Service
User Offline
Joined: 2nd Nov 2004
Location:
Posted: 11th Apr 2007 15:58
how would the code look for something like that though? i was thinking something along those lines, but then i thought i would have to have that code twice; once with walking, and once with running, but i didn't know if that would work.
Clackersmith
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location:
Posted: 11th Apr 2007 17:47 Edited at: 11th Apr 2007 18:16


Or a very basic way of toggling it on and off if you wanted it
(Just make sure you set a speed value before the main loop otherwise you will have to hit shift to get moving)



The inadequacies of human cognitive ability are cause for the imperfection of reality.
LOTR HITMAN
20
Years of Service
User Offline
Joined: 2nd Nov 2004
Location:
Posted: 11th Apr 2007 20:50
i tried putting that code into mine, but it didn't work. it said newxvalue expects (real,real,real). i am using db classic if that affects things. also, how exactly do i set the speed before the loop? sorry, i am very new with this so i don't understand much about it.
Clackersmith
21
Years of Service
User Offline
Joined: 4th Sep 2003
Location:
Posted: 12th Apr 2007 08:27 Edited at: 12th Apr 2007 09:31
Wired one this, I originally thought the variable "Speed" just needed to be changed to a float because the newxvalue function was having trouble with integers for some reason. Got dark basic classic up and going to test it but didn’t have any luck. It seems that it has a problem with the negative operator contained within -

x#=NEWXVALUE(x#,a#,-Speed) and z#=NEWZVALUE(z#,a#,-Speed)

No matter what kind of variable I add as a parameter (float, integer) or variation of the contence of that variable (3,3.0) it doesn’t seem to work when there is a negative operator involved even though it works fine with the examples below without a variable.

x#=NEWXVALUE(x#,a#,-3) or z#=NEWZVALUE(z#,a#,-3.564)

Works fine in Dark Basic Pro by the way. Since I have never used this function (Bit of a sin and cos man myself) I have never in counted this problem so I'm not sure as to why it is happerning so Que TDK_Man to come and explain.

The inadequacies of human cognitive ability are cause for the imperfection of reality.
LOTR HITMAN
20
Years of Service
User Offline
Joined: 2nd Nov 2004
Location:
Posted: 12th Apr 2007 17:57
how do i que him for that? oh, and i am using darkbasic classic. sorry , i didn't read the full title of this section.

Login to post a reply

Server time is: 2025-05-29 03:46:55
Your offset time is: 2025-05-29 03:46:55