|
-
May 30th, 2002, 07:47 AM
#1
Thread Starter
New Member
movement in one time response
I've got a picture. Whenever I press the down key, the picture will go down. The problem is, I want it to response as even though I press and hold the down key, it will only move one step!
How do I do that?
Hate not me. Hate your weaknesses
-
May 30th, 2002, 09:01 AM
#2
Fanatic Member
ok..
assuming u mean u want it to keep going even after u lift the key...
dim keypressed as boolean
private sub form1_keydown(keycode as integer etc...)
if keycode = 40 then keypressed = true '40 is down right?
end sub
private sub timer1_timer
if keypressed = true then object1.top = object1.top + 1
end sub
this should make it always go down after u rpessed it, if u want ti to stop when u release the key, add
private sub form1_keyup(same as keydown i think)
if keycode= 40 then keypressed = false
end sub
Don't pay attention to this signature, it's contradictory.
-
May 30th, 2002, 10:00 AM
#3
Lively Member
keys
That will probably work in a simple game. But in my experiance if your codeing a complex game that requires the programe to sense someone holding the key down for a long time, its much better to use Direct X 's, Direct Input aspect anything else I tryed useing gave includeing GetAsncKeyState() gave me some occasional weird gliches. Its really easy to use too if you want that code e-mail me [email protected]
All will fall before the might of the Black Sashi...
-
May 31st, 2002, 12:30 AM
#4
Thread Starter
New Member
thanks all.
Thanks all. One more though. Is there a way to no matter how long the keydown is pressed and hold it will only move one step.
Anyone?
Hate not me. Hate your weaknesses
-
May 31st, 2002, 06:51 AM
#5
As he said...
As the other guy said, use the API call:
GetAsncKeyState()
then have som boolean switch that changes when GetAsncKeyState() is different from its previous value.
To check it against a previous value, just use another variable. I.e
a = GetAsncKeyState(40)
......Insert code
if GetAsncKeyState(40) <> a then BoolSwitch = NOT(BoolSwitch)
-
Jun 14th, 2002, 05:37 AM
#6
Thread Starter
New Member
a funny question.....
no matter how many times I tried the easy method by alkatran, if I would leave out the keyup procedure, the character still does not keep moving! Can someone then post the whole coding for it.
Hate not me. Hate your weaknesses
-
Jun 14th, 2002, 07:57 AM
#7
Hyperactive Member
under form1's keydown:
If Keycode = vbkeypress then object.top = object.top + 1
may also be keyascii.. I dunno.. make sure if it is in the sub.
that (if i did it right, don't have VB installed ATM..) will make it move only once, no matter how long you hold it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|