• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

Drag And Drop Setting a timer / countdown?

N

nuyluy

Guest
Hey there!
I need to create a timer / countdown in two different rooms / levels, so that your time to finish the maze is limited. If the time is up I want the player to respawn at the beginning...
Please help me achieving this with Drag and Drop, I reaaally need your help
 
I've got a few methods that we can do this. The first thing we can do is setup a global variable. This variable let's call it "global.TIMER" or in DnD. Create an object, and on it's "CREATE" EVENT make sure to click on the icon that looks like a globe with an arrow going towards it, and set it to how much time you would like it to be. Then you would need to set an alarm under alarm[ 0 ]( Reason why I chose alarm 0 is because coding in DND can be prove difficult to manage ). In the "CREATE EVENT" Make sure to set the alarm 0 to "room_speed." This will assure you that it will be called every second. Game Maker runs... Then Create the "ALARM 0" event and make sure that the event is does two things. It needs to REDUCE the global.TIMER by 1 AND also RESET the alarm so that it runs infinitely... make sure the ALARM 0 repeats so in our case. Alarm 0 = room_speed; Inside Alarm 0, we need to do one more thing and that is to test if we've run out of time. So, If our global.TIMER is LESS THAN or EQUAL TO 0, we need to restart the game. This object should also be persistent, but make sure to NEVER return to the room you originally created this object in or you'll have TWO of the same object.
 
N

nuyluy

Guest
I've got a few methods that we can do this. The first thing we can do is setup a global variable. This variable let's call it "global.TIMER" or in DnD. Create an object, and on it's "CREATE" EVENT make sure to click on the icon that looks like a globe with an arrow going towards it, and set it to how much time you would like it to be. Then you would need to set an alarm under alarm[ 0 ]( Reason why I chose alarm 0 is because coding in DND can be prove difficult to manage ). In the "CREATE EVENT" Make sure to set the alarm 0 to "room_speed." This will assure you that it will be called every second. Game Maker runs... Then Create the "ALARM 0" event and make sure that the event is does two things. It needs to REDUCE the global.TIMER by 1 AND also RESET the alarm so that it runs infinitely... make sure the ALARM 0 repeats so in our case. Alarm 0 = room_speed; Inside Alarm 0, we need to do one more thing and that is to test if we've run out of time. So, If our global.TIMER is LESS THAN or EQUAL TO 0, we need to restart the game. This object should also be persistent, but make sure to NEVER return to the room you originally created this object in or you'll have TWO of the same object.
I couldn't quite follow completely through - Excuse my problems, I'm a total rookie. In the attached file is what I tried to recreate from your reply, but there's something missing right? Also how do make the timer show up on the screen after placing the object in the room?
Thank you soo much already :)
 

Attachments

FrostyCat

Member
I couldn't quite follow completely through - Excuse my problems, I'm a total rookie. In the attached file is what I tried to recreate from your reply, but there's something missing right? Also how do make the timer show up on the screen after placing the object in the room?
Thank you soo much already :)
You are missing this part of the instructions:
It needs to REDUCE the global.TIMER by 1 AND also RESET the alarm so that it runs infinitely
Copy the Set Alarm Countdown action from your Create event, and connect it to the currently empty end of the If Variable action in Alarm 0. If you don't see why this is important, mentally run through the actions until you do.

If you want to draw the variable, add a Draw event, put in a Set Draw Colour and Set Font action to set up a drawing colour and font, then use the Draw Value action.

If you're going to use Drag-and-Drop, you should do the official tutorial for Drag-and-Drop, learn what basic events and actions are about, and be as self-sufficient with basics. Almost everything you've posted so far suggests that you haven't done this tutorial or paid real attention to what it says. Many responders have only GML experience and even more find it annoying to support Drag-and-Drop in a forum setting, so don't work with the assumption that helping hands are in abundance.
 
N

nuyluy

Guest
You are missing this part of the instructions:

Copy the Set Alarm Countdown action from your Create event, and connect it to the currently empty end of the If Variable action in Alarm 0. If you don't see why this is important, mentally run through the actions until you do.

If you want to draw the variable, add a Draw event, put in a Set Draw Colour and Set Font action to set up a drawing colour and font, then use the Draw Value action.

If you're going to use Drag-and-Drop, you should do the official tutorial for Drag-and-Drop, learn what basic events and actions are about, and be as self-sufficient with basics. Almost everything you've posted so far suggests that you haven't done this tutorial or paid real attention to what it says. Many responders have only GML experience and even more find it annoying to support Drag-and-Drop in a forum setting, so don't work with the assumption that helping hands are in abundance.

I actually watched almost the complete playlist, but since English isn't my first language, I had a very hard time following the explained steps by myself. An additional description of my necessary steps from a different person in written form gives me an additional chance to understand the systems of DnD. I'm doing this the very first time and I am not going to excuse myself for asking questions on a forum made for asking questions.
Thank you for helping me with my troubles and have a nice day!
 
Top