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.

Author
Message
Timber Wolf
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location:
Posted: 5th Jun 2004 18:28 Edited at: 5th Jun 2004 18:29
ok, what i have is a long set of commands and variables dictating movement. I'm trying to make the player have a wide variety of movement (first person), where crouching slows you down, you can toggle between fast and slow, all the good stuff. so far its all nice, but what i can't get to work is the toggling between fast and slow



fast and slow are what matters with what i'm doing. any help?


"Death Before Dishonor"
"Vengance Before Death"
JerBil
21
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 5th Jun 2004 20:02
Here's an old trick, Timber. you have to set slow=1 before you enter your loop. Since sleep is hit only if key 29 is hit, it won't slow your program.

if keystate(29)
slow=1-slow
fast=1-fast
sleep 200
endif

-JerBil
Timber Wolf
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location:
Posted: 5th Jun 2004 20:41
well, the sleep does pretty much pause the game for a tenth of a second, but it did the trick. I now have full control. thx Jerbil


"Death Before Dishonor"
"Vengance Before Death"
JerBil
21
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 5th Jun 2004 23:55
Here's another way. This code will set your variables when press and then let go of the key. Any delay will depend only on how long you hold the key down.

if keystate(29)
while keystate(29)
endwhile
slow=1-slow
fast=1-fast
endif

-JerBil
Timber Wolf
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location:
Posted: 7th Jun 2004 03:49 Edited at: 7th Jun 2004 03:51
actually i found another way

at the beginning i did this

speedchange=0

now, inside the keystate command, i added a new trigger and action, so it looked like so

If keystate(29) and slow=1 and speedchange<1 then fast=1 : slow=0 : speedchange=15
If keystate(29) and fast=1 and speedchange<1 then slow=1 : fast=0 : speedchange=15

and at the end of my loop i put

speedchange=speedchange-1

I have found many uses for this and it has the same effect but without slowing the program down whatsoever!!! . I'll have to spreed the word if i don't see it used... maybe later


"Death Before Dishonor"
"Vengance Before Death"
Phaelax
DBPro Master
22
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 7th Jun 2004 07:08


"eureka" - Archimedes
Night Giant
21
Years of Service
User Offline
Joined: 26th Jul 2003
Location:
Posted: 7th Jun 2004 18:18
judging from the fixes you've recieved i am guessing your problem was that it was flipping from slow to fast very rapidly, right? maybe you didn't notice it because you didn't have an onscreen indicator of the that flag, but that was probably the problem. imo the best way to fix that (and this is great for any situation where a key is pressed or mouse button clicked once) is to store the position of the key before and during the loop.



that way it will only do the stuff if ctrl was just pressed, it won't continue doing it even if you hold down ctrl. using this method you can also set it so stuff only works if you hold down a key, or when you release a key.

oh, wow. insignificantpunks.cjb.net.
no: website for progs yet.

Login to post a reply

Server time is: 2025-05-24 00:10:31
Your offset time is: 2025-05-24 00:10:31