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.

Newcomers DBPro Corner / Scancode to fast :(

Author
Message
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 11th Jul 2006 02:10
Am currently attempting to make an FPS (as i figured it cant be that hard - surely?) using DBC, i decieded to walk a bit faster than my legs can carry me, and implement the Weapon change using number (1-4 atm) and '[ , ]' for last/next. I assuemd the Scancode would work, but it works a bit too well and jumps a gun or 2 when using '[ , ]' *sorry if this makes no sense*

Heres my code for it all


it may not be perfect, but i figured that out in 5mins. any guidance or links to appropiate code in the '$c' would be most helpful.

Ginga
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 11th Jul 2006 04:49 Edited at: 11th Jul 2006 04:49
Hmmm... Judging by what you're saying you're going to need to put a short delay timer in there. Just make some variable called I don't know, DELAY go down forever by putting Delay=Delay-1 in your loop. Next, make it so that you can only swap weapons when Delay is less than 0. When you switch weapons, make delay 15 or something. That way it will go to 15 when you switch, and then keep going down, giving you some time to release the weapon switch key.

Quote: "Joined: Mon Jul 3rd 2006"

You know a lot for somebody who has been programming for only a week... Unless your join date lies.

Anyways, hope this helped. Respond saying if it did or not please. I don't like it when people get your help and don't say thank you.

My Functions: Mine
Post yours: Post
hyrichter
20
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 11th Jul 2006 07:26
Hi Ginga. You could use a timer as Sixty Squares suggested, but an even better way to do it is to not let the code execute again until you release the key and press it down again. I'll try to explain with an example here. We'll use a variable called keydown to determine if we should continue to execute your weapon switching code or not.

BTW, there's really no reason for you to use scancode for this. The inkey$() command will work just as well.



Another thing I noticed is that you're using G# for your object number. There's really no need to do that since objects can only be integers. Use the # for variables that need a decimal.

Good performance is better than a good excuse.
CodeSurge -- DBP Editor for serious programmers.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 11th Jul 2006 13:03
Thanks hyritcher I'm going to use that one

My Functions: Mine
Post yours: Post
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 11th Jul 2006 13:43
Thank you Sixty Squares and hyrichter, you've been a big help. I'll implement this as soon as i can and post the results.

Quote: "[quote]Quote: "Joined: Mon Jul 3rd 2006"[/quote
You know a lot for somebody who has been programming for only a week... Unless your join date lies."


couple of reasons for this, I read turtorials/help pages/any thing else i can get my mitts on, and create an example to drill the code into my head.

I'm a fast learner =D (naturally)

Finally, I have Visual Studio.NET so i pretty much know the basics, just havn't done any 3D programming so cant use all my knowledge.
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 11th Jul 2006 15:47
Thank you Sixty Squares and hyrichter, you've been a big help. I'll implement this as soon as i can and post the results.

Quote: "[quote]Quote: "Joined: Mon Jul 3rd 2006""

You know a lot for somebody who has been programming for only a week... Unless your join date lies.[/quote]

couple of reasons for this, I read turtorials/help pages/any thing else i can get my mitts on, and create an example to drill the code into my head.

I'm a fast learner =D (naturally)

Finally, I have Visual Studio.NET so i pretty much know the basics, just havn't done any 3D programming so cant use all my knowledge.

Sorry about the double post but it wouldnt let me edit my post and the quote was all wrong

Just to let you guys know, i tried both ways, but neither worked tho, hyrichter i swapped scancode for inkey. I guess if ican't resolve this issue, i'll just take the whole command out.
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 12th Jul 2006 07:08
all you'd need to do is make it where it doesn't jump more than one at a time, so you'd have to release the key and press it again to go the the next one. Like this:

I have to do that sort of thing quite a bit, so unless I'm not thinking right or made a typo, that should work for you .

Pirates of Port Royale
Live the life of a pirate.
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 12th Jul 2006 12:26
thanks for the input Gil Galvanti tried it your way, and for some reason it still doesnt like it. Which is really quite annoying. Just had an idea on how to do it.. am gunna try it out now. may totally fail so i will more than likely be on here still needing help.
Ginga
18
Years of Service
User Offline
Joined: 3rd Jul 2006
Location: Dorset, England
Posted: 12th Jul 2006 12:45
YAY! i've adapted your snippet Gil Galvanti and added an extra line, that basically ses if keystate and reset = 1 do nothing. (dont know if you forgot to put it in or not), and now it works! so thank you to every1 who posted
Zerk
18
Years of Service
User Offline
Joined: 13th May 2006
Location: Orbiting Jupiter
Posted: 15th Jul 2006 03:45 Edited at: 15th Jul 2006 03:49
I basically set up an array for the keycodes like this...



This way you have a seperate memory for each key and dont have to worry about reusing variables like "reset".

I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do. ~Hal-9000
Gil Galvanti
19
Years of Service
User Offline
Joined: 22nd Dec 2004
Location: Texas, United States
Posted: 15th Jul 2006 08:20
Quote: "i've adapted your snippet Gil Galvanti and added an extra line, that basically ses if keystate and reset = 1 do nothing. (dont know if you forgot to put it in or not), and now it works! so thank you to every1 who posted "

ok, cool . I don't know why adding an empty if...endif statement would make it work though. It shouldn't change anything...oh well .

Pirates of Port Royale
Live the life of a pirate.

Login to post a reply

Server time is: 2024-09-25 03:40:14
Your offset time is: 2024-09-25 03:40:14