|
-
Aug 3rd, 2001, 01:23 AM
#1
Thread Starter
New Member
game programm.. need help
i have a chase game... the computer chases u... and the problem is well sometimes when i quickly press right... it goes twice, not once to the right =(... i use timers for both computer and human controls.. so plz help me! I need to fix this cause the human char can get into a base and be safe from the computer... but if he misses it w/ one of those 2 walks thatd be bad.. PLZ HELP!
-
Aug 3rd, 2001, 02:24 AM
#2
Retired VBF Adm1nistrator
Well the way I do it is that I store what the 4 key positions are like :
VB Code:
Private keyLeft As Boolean
Private keyRight As Boolean
Private keyUp As Boolean
Private keyDown As Boolean
So when the user presses a key, it sets two of the above to either True or False. If the user presses Right, then keyRight is True, and keyLeft is False.
And then in the timer event (though I normally use GetTickCount), I check is keyLeft or keyRight true, and if one of them is, then move the person in that direction, and then set it to false.
Same for up/down.
Ya follow ?
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 3rd, 2001, 06:38 AM
#3
Frenzied Member
How are you collecting your input at the moment?
Harry.
"From one thing, know ten thousand things."
-
Aug 4th, 2001, 05:16 AM
#4
Frenzied Member
With windows programming the way it works is by sending messages to the window everytime an action occurs, whats happenign here is when a key is held windows doesnt sa "hey that keys being pressed" it just repeatedly says "key pressed". So on the forms keyUp / KeyDown u have to set a boolean variable on whether the key is down and then check if the vari is true or false.
-
Aug 4th, 2001, 04:15 PM
#5
Thread Starter
New Member
...
Actually that is almost what i did.... and that wasnt the problem... the problem is that i held the button down for 3 milli-seconds and the timer looped about every 1 milli-second... and well i dont need that no more cause i changed the game around so it dont need that nomore =). but thnx for re-plying
-
Aug 6th, 2001, 11:29 PM
#6
Retired VBF Adm1nistrator
Remember,
Timer Control : Evil
GetTickCount : Saintly
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 7th, 2001, 09:29 AM
#7
Frenzied Member
Originally posted by plenderj
Remember,
Timer Control : Evil
GetTickCount : Saintly
Lol theres nothing that bad about Timer. Its just imprecise below about 60 ms. If you want evil just look at FSO...
You just proved that sig advertisements work.
-
Aug 7th, 2001, 09:59 AM
#8
Good Ol' Platypus
You must limit the number of times the game updates, instead of the number of times the SCREEN updates. They should be different, unless the screen refresh is limited as well.
Try this.
VB Code:
Dim ms as Long
ms = GetTickCount
Do
UpdateSCREEN 'draw things
If GetTickCount - ms >= 1000 / gameUpdsPerSecond 'set this variable to like 33 or so, for 30 updates per second. For refrence, the SNES console has this set to 60 for all games.
UpdateGAME
ms = GetTickCount
End If
DoEvents
Loop
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
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
|