• Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!

Legacy GM How to add tiny delays to help with timing?



My partner and I are working on a tutorial for our prototype.

Right now we have little pictures and textboxes that show up as the player progresses, as kind of a guided tour. The issue is, these textboxes and pictures show up INSTANTLY as soon as a requirement is met. Everything happens too fast. So how can you program in a small delay? for example:
  • Player gets hit
  • Wait two seconds
  • Display arrow animation over health bar
  • Wait for the animation to end
  • Display text "YO THIS THE HEATH BAR"
  • Wait a few seconds
  • Get rid of the text
  • Etc.
We just can't think of a good way to do this. Yes, we are familiar with how alarms work. It just seems like using an alarm every time we need a small pause would get grossly complicated.


There's no other way than using alarms of counting steps yourself...
Unless you want to use timelines. But for what you describe there, its not convenient much. Easier to go alarm or counting by yourself.
Yes, we are familiar with how alarms work. It just seems like using an alarm every time we need a small pause would get grossly complicated.
You would only need to use up to 3 alarms (how I would do it; delay before showing, minimum time for message to display, and [optional] maximum time to display a message [if you aren't getting the player to press a button to advance or clear the message]) for each individual message, and these could all be vastly simplified by turning the system into a script or set of scripts. It's hard to say _exactly_ how to approach your problem not knowing how you have implemented your message system.
Expanding on what @RangerX said, you could have an object called "ob_tutorial_healthbar" and have different tutorial objects for each different item that you are teaching. When the player gets hit, you would create an instance of the tutorial object and set it's alarm[0] = room_speed * 2 (2 seconds) then when alarm[0] triggers, do the next thing and set alarm[1] to a value etc, etc.


The lerp function finds a value between two values.

Create event:
lerpAmount = 0;
lerpSpeed = 1/room_speed;

Draw Event:
draw_set_alpha( lerp(0,1, lerpAmount) );
draw_sprite(spr_arrow, -1, x, y);

draw_set_alpha( lerp(0, 1, lerpAmount-1) );
draw_text(x,y,"Health goes here dawg");



Develop a standard way you use alarms, either coding manual timer variables (I use coded manual, alarms are clunky IMO), or using gm built in alarms.
For example, name all timers with timerXXX prefix, and all default values as timerXXXDefault or something like that.
Get use to using it, ensure its a robust standard. At some point it will be second nature.

That's the best solution IMO, its the least complex and most versatile. If it's a moderately complex game you will use so many timers that this reluctance to use a few timers for things that need timers will seem silly :)


The way I do this is by creating a simple object that I pass a script id to and then set its alarm to trigger that script and delete itself when the alarm completes. So basically everytime I need an alarm for something that is arbitrary I generate one of these objects and it just runs a script after some time and then removes itself. Simple, straightforward and extendable.


Alarms seems to be most simple if u dont pref everything in script and use icons, but if there are many objects with timers or u want timers to be "alive", id say go for codes. For example im working on turn based strategy/tycoon game with large maps and built in timers are a big no. Actually im crying that i cant put more load on other processor cores :p. Or if you want popups above character in action adventure etc, variables should be better to handle switching between them when things get hot and you hit/are hit multiple times per second. For your current problem, id pick built in alarms if it concerns only short tutorial, but if these messages should popup lets say whole game as guide, id go for scripted variables. Or if by any chance your tutorial is not stone set and things like 2 messages at once may occur, id go for timer variables too as its much easier to handle such cases. Basically: built in alarms are simple, but its complicated to do anything not-simple with them :p


Since I've lost my passion for alarms, I would solve this by using a couple of variables like sequenceCount, sequenceIndex and sequenceTimer, which would start counting down from X after player gets hit and after reaching zero would execute the code for sequenceIndex=0, increment index, increase timer again by the delay needed before next code execution and repeat that until sequenceIndex reaches sequenceCount. The problem with this approach is getting hit again before all of the executions ended, which can be solved in multiple ways (having a queue, multiple instances, etc).