Timer redux

AntonBrz

Member
Licensed User
Longtime User
Thank you for your patience with this question. The question is, I want to separate the display on screen of different things, toast messages or sounds.
Now if I create a timer properly by declaring it in the sub globals, then initialize it properly in the subglobals, can I then use it in a sub routine, where within that routine are several events, like this for example?




MyT.ToastMessageShow2("First message.", 4, 40, 40, "", Colors.Red, Colors.Black, 14, False ,False)

mytimer_tick

MyT.ToastMessageShow2("Second message later.", 4, 40, 40, "", Colors.Red, Colors.Black, 28, False ,False)

 

AntonBrz

Member
Licensed User
Longtime User
Timers for short delays

Thanik you for responding, Erel. I want to show toast messages separated by intervals. Since I can control the font, color, time displayed, of the custom toast messages, I thought using delays between would be good for a sequence, such as, and this is a crazy example, "In a kingdom you never heard of" then a timer generated pause then another toast message.
"Lived a hero no one's ever heard of." If you' read my other posts in other forums, you know I'm coding a card game, so a timed message or timed sound question may seem I quit and am fooling around doing different programs, but I'm not. My card game is the equivalent of a Dungeons and Dragons game. This might sound ambitious for a first project, but it's really not. All it requires is displaying a couple of cards, and the logic of if-thens to make it work, and I'm succeeding there.Instead of 3d characters walking around, or lengthy sequences of memory chewing graphics, I'm doing it with small images of cards. But I don't want it to be stiff and static, so I'm adding sound fx and short animations. With the ability to time the display of messages, sounds and bitmaps, many good effects can be inserted. Otherwise it all runs together and happens as soon as you press the deal button.

Thank you for remembering that some of us are beginners, Knowledgeable programmers who bother to answer our lame questions are the heroes. (Sorry for the brown nosing)
How to use Timers fluently seems to be the one thing I need to know most right now. I have searched the forum and studied the code of working programs like Duck Hunt and others, and I saw timers are explained in the documentation. I try not to ask questions without trying to find an answer.

Anton
 
Last edited:
Upvote 0

TomA

Active Member
Licensed User
Longtime User
Short delays without using a timer

I found this code for creating short delays somewhere in a forum and it does not use a timer. I am using it in a program I am currently developing and it works great.

First, you create a subroutine like:

Sub WaitFor(Milliseconds As Int)
Dim Present As Long
Present = DateTime.Now
Do While DateTime.Now < Present + Milliseconds
Loop
End Sub

The routine acts like a "Sleep" command. In the code where you want the short delay, simply call the sub with the number of milliseconds need to create the desired delay:

WaitFor(2000) ' Create a 2 second delay

Tom Aman
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Thanks Tom

Thank you, TomA. While I know the timer system has its uses and was carefully conceived, there are times when a "sleep" like command would be easier. I'll try yours. Strapped for time to program now tho. I have Jury duty in the morning. I'd rather hit my fingers with a sledgehammer. I'll be working on my game ASAP.

Anton
 
Upvote 0
Top