Timing in a basic game

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JasonTravers
Posts: 7
Joined: Fri Mar 13, 2009 6:23 pm

Timing in a basic game

Post by JasonTravers » Sat Apr 25, 2009 12:19 am

Hello. I'm creating a basic educational game with music, sound effects, visual effects and a automatic timer. I would like the user to manipulate objects on the screen to produce sound/visual effects while a player plays music. I want the stack to advance the use to the next card after a specified period of time, but can't quite figure out how to run a timer while allowing the user to perform actions.

Also, variables are counting correct and incorrect responses. Any advice for a newbie?

Thanks!

SparkOut
Posts: 2862
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Sat Apr 25, 2009 12:28 am

You will probably need to look at "send" (in <time>) constructions.

For example if you have a sequence of cards that you need to advance after a time limit, as you say, you could make a stack script that has the handler

Code: Select all

on advanceCard
  go next card
end advanceCard
Then when you need to initiate an event timer (say on cardOpen) you can do something like

Code: Select all

on cardOpen
  send "advanceCard" to me in 30 seconds
end cardOpen
That means that when the card with the cardOpen script is opened, it will put a message in the pending messages queue that will activate in 30 seconds. That message will then arrive in the stack script and trigger the advanceCard handler, which will "go next card".
If that's not clear enough, let me know, but HTH.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Post by malte » Sat Apr 25, 2009 9:21 am

Hi Jason,

I wrote quite a bit about timing in the past. My free eBook for Mac and Windows is still available (even though it is a bit dated)

For Windows: http://downloads.runrev.com/revselect/a ... ls_win.zip
For Mac: http://downloads.runrev.com/revselect/a ... ials_x.zip

Hope that helps a bit.

Malte

JasonTravers
Posts: 7
Joined: Fri Mar 13, 2009 6:23 pm

Timing in a basic game

Post by JasonTravers » Mon Apr 27, 2009 4:30 pm

Lovely!
Thanks for the tips. I knew there had to be a easier way than what I was doing (using several "if, then" scripts.

Cheers!
Jason

Post Reply

Return to “Multimedia”