|
-
Nov 10th, 2000, 12:09 PM
#1
Thread Starter
Junior Member
-
Nov 10th, 2000, 02:01 PM
#2
transcendental analytic
Don't use more than one timer! If your game is timecritical you could as well make it run in a infinite loop with gettickcount managing the timing. Actually i would recommend the second for you since it might be real confusing to control several asyncronous timer events. What are you using a two dimensional array for to have npc's? might be i'm missing something important.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 10th, 2000, 02:11 PM
#3
Thread Starter
Junior Member
Timers are a must (it seems)
Eventually I already have timer for every PC player as well. Timers are needed for dealyed actions. For example PC wants to attack another PC so he writes:
hit Ace
Then he sees:
You're aiming... (Or something like that)
After some time he sees:
You land the blow on...
When a player does a delayed command only half of it is executed, then the timer of the player is turned on for the delay, when the delay is over the timer of the player is turned off and the command proceeds.
You get the idea. As I see it now there is no other way to do this delay and even though I don't like the way I am using the timers it is the only way.
Basically NPCs would need something like that too.
VitalyB - VB6 Pro 
-
Nov 10th, 2000, 02:24 PM
#4
Fanatic Member
You can use an endless loop like this:
Code:
Form_Load
Do
'get the time
Time = GetTickCount
'do something
If Time = 5 Then
Msgbox ":-)"
End If
'don't freeze the system
DoEvents
Loop
End Sub
Note that the code doesn't work, it just some example. Use GetTickCount for the delay.
-
Nov 10th, 2000, 03:00 PM
#5
Thread Starter
Junior Member
Right, that was my first my choise the following problem occured with that way (Do DoEvents Loop).
See this example:
Player A (PC) presses hit and actually enters the delay loop. Now before the time delay is over player B presses hit too. Because of the DoEvents it makes the command work and the command is being processed now player B enters to the same loop as well which means that player A won't be able to hit until player B hits. The loop of player A hit command doesn't process because there is another loop going on for player B.
Hope I said it right *crosses his fingers*
VitalyB - VB6 Pro 
-
Nov 10th, 2000, 03:25 PM
#6
Fanatic Member
Create a collection, holding the tasks and when (milliseconds) they're needed to execute. So, then loop processes all tasks in the collection.
-
Nov 10th, 2000, 03:38 PM
#7
Thread Starter
Junior Member
Collection like the one you said is a possible solution however testing the collection every time it is in the Do loop is being even more messy than doing the delay timer.
I don't seem to understand what's so wrong (But the two dimensional part :|) in using timers?
VitalyB - VB6 Pro 
-
Nov 10th, 2000, 03:40 PM
#8
transcendental analytic
The whole idea with the game loop is that id doesn't initialize every time, it's running all the time and waiting for next thing to do, while drawing the grapphics, reading keyboard, mouse or whatever. So if you still are working with events, just set flags on and off, otherways you should use a directinput device or enumerating all keys with getasynckeystate.
Now as oetje said, you make a queue of tasks, which have assigned time when they will fire and be removed from the list, that is easiest done with linked lists like collections but can also be done faster with arrays if you just optimize it once a while or have another array storing the free spaces, like freefile does for filesystem in vb.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 10th, 2000, 04:13 PM
#9
Thread Starter
Junior Member
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
|