Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411500 Posts in 69373 Topics- by 58428 Members - Latest Member: shelton786

April 25, 2024, 10:01:22 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Help with using delta time
Pages: 1 [2]
Print
Author Topic: Help with using delta time  (Read 6259 times)
Moth
Level 4
****



View Profile WWW
« Reply #20 on: August 27, 2015, 04:47:08 PM »

you would want to use the time get functions rather than steps. Check the manual for the "Date and Time" section.

current_time returns the number of milliseconds since the game was started, so you could do something like make a script like:

global.track_start=current_time;

and then to check how many milliseconds have passed:

global.track_position=(current_time-global.track_start);

A basic approach could be to lay out all the notes of the song into arrays  and using loops to render upcoming notes at different locations based on the difference between global.track_position and the point in the song at which they occur.
Logged

lvldesignII
Level 0
**


View Profile
« Reply #21 on: August 28, 2015, 12:40:09 AM »

Thanks everyone, I think this might be a little advanced for my skill level but I got the weekend free and I'll spend it trying to make this happen.  Crazy
Logged
Moth
Level 4
****



View Profile WWW
« Reply #22 on: August 28, 2015, 11:59:34 AM »

Check your PM box here, I slapped something together that might help you out.
Logged

lvldesignII
Level 0
**


View Profile
« Reply #23 on: August 28, 2015, 06:10:00 PM »

Check your PM box here, I slapped something together that might help you out.

This helped a lot I can't thank you enough.
Logged
ProgramGamer
Administrator
Level 10
******


aka Mireille


View Profile
« Reply #24 on: August 28, 2015, 06:14:37 PM »

Great now I'm curious...
Logged

Moth
Level 4
****



View Profile WWW
« Reply #25 on: August 28, 2015, 06:44:21 PM »

You're welcome! I'm glad that it helped. Oh, in case you didn't know, I should maybe point out that by default the .ini files will be generated at appdata/local/(game name), at least for me on windows 7. If you have any questions with how I did anything don't hesitate to ask.

@ProgramGamer: I basically just threw together a simple way to read a list of notes + timing values for them based on milliseconds rather than steps. I considered posting it publically but since I just slapped it together in a couple of hours the coding isn't totally tidy, not everything is done as optimally as it could be, etc. that makes me feel a little guilty sharing it publically Tongue don't wanna set a bad example. I could share it if people were really interested though.
Logged

lvldesignII
Level 0
**


View Profile
« Reply #26 on: August 29, 2015, 11:14:55 PM »

Okay weekend is nearly over and I'm probably more lost then when I began. Facepalm Thanks again to Moth for his example, I tried my best to understand why everything was working the way it was but I think I'm punching above my weight, I'm not ready to give up just yet (I'm in too deep) and I'll continue learning as much I can. Thanks for all the help.  Smiley



 

Logged
Moth
Level 4
****



View Profile WWW
« Reply #27 on: August 29, 2015, 11:17:27 PM »

Hey, could you say what it is in specific you're getting stuck on or having trouble understanding? I would be happy to go in depth!
Logged

lvldesignII
Level 0
**


View Profile
« Reply #28 on: August 29, 2015, 11:52:50 PM »

I think it was the general setup/layout, it was different to how I thought a rhythm beat system would work which really just threw me off, the end result was the same for what I'm trying to build but the setup was different to what I had in mind, this is my fault I know there's different ways of reaching the same outcome and my skills are just not good enough to be able to adapt it. Still picked up a few things from your example so all is not lost.  Smiley I'll keep working at it until I get it.
Logged
lvldesignII
Level 0
**


View Profile
« Reply #29 on: August 30, 2015, 01:30:52 AM »

Hey, could you say what it is in specific you're getting stuck on or having trouble understanding? I would be happy to go in depth!

I think it was the general setup/layout, it was different to how I thought a rhythm beat system would work which really just threw me off, the end result was the same for what I'm trying to build but the setup was different to what I had in mind, this is my fault I know there's different ways of reaching the same outcome and my skills are just not good enough to be able to adapt it. Still picked up a few things from your example so all is not lost.  Smiley I'll keep working at it until I get it.


I should probably explain what I had in mind and why I'm having trouble adapting your example into something I could use, this is totally my fault, lack of experience on my part.

Example of what I had in mind:

A room with 3 note objects each with their own sprite, and then use instance_create to create them above the screen and have them fall down, when they reach the bar if you pressed the correct key you destroy it if not it falls off screen and would it destroyed anyway. For the timing of the notes (this is what I had/still having the problem with) is maybe creating a tool that stores the timing info into a list/text file that I could then open and input manually into to my "game". Shrug

Example by RujiK from GMF

//Do this at start. Create an array that holds the times the notes need to be created.

Time_Note[0] = 3*1000; //3 seconds.
Time_Note[1] = 4*1000; //4 seconds.
Time_Note[2] = 5*1000; //5 seconds.
Time_Note[3] = 7*1000; //7 seconds.
current_note = 0; //used to select next array
music_start_time = current_time;

And then for your main step event or whatever.

current_music_time = current_time - music_start_time;
if current_music_time > Time_Note[current_note] {create_note_script(); current_note +=1;}

Now with your example you did everything but the setup was different and again my skill level isn't good enough to be able to adapt/understand it fully Sad, but I did learn a few things such as using the 1 sprite and sub images and just drawing the image I needed this didn't even come to mind and the recording would save a lot of time instead of having to input everything manually. I'll hold onto your example and keep trying to understand it better.   Smiley I hope you know what I mean.  Shrug

I'll keep at it.  Waaagh!
Logged
Moth
Level 4
****



View Profile WWW
« Reply #30 on: August 30, 2015, 07:17:47 AM »

I understand what you had in mind. The reason why I directly draw notes without creating objects is because just timing objects to be created at the right time is a bit more finicky and hard to coordinate- in the case of creating objects, instead of just drawing a note where one is calculated to be, you have to extrapolate from your timing information and create the note at the time it should enter the screen and then manipulate the note's object to be in the right spot at the right time. When you're not using objects it's much easier, since you're simply drawing notes where they should be, basically just fake objects.

Again, if you have any questions about any particular parts of my example, I would be happy to explain them in detail to help you understand! One of my goals with the example was to help demonstrate an easy way to read a list of notes by using an INI file. The example's built in recording mode isn't necessary for making the INI, you can also just tweak the ms timing in the INI in notepad for more precision!
Logged

lvldesignII
Level 0
**


View Profile
« Reply #31 on: August 31, 2015, 01:12:35 AM »

I understand what you had in mind. The reason why I directly draw notes without creating objects is because just timing objects to be created at the right time is a bit more finicky and hard to coordinate- in the case of creating objects, instead of just drawing a note where one is calculated to be, you have to extrapolate from your timing information and create the note at the time it should enter the screen and then manipulate the note's object to be in the right spot at the right time. When you're not using objects it's much easier, since you're simply drawing notes where they should be, basically just fake objects.

Again, if you have any questions about any particular parts of my example, I would be happy to explain them in detail to help you understand! One of my goals with the example was to help demonstrate an easy way to read a list of notes by using an INI file. The example's built in recording mode isn't necessary for making the INI, you can also just tweak the ms timing in the INI in notepad for more precision!

Hey just a question regarding the example. How does the start_tracking script know when the song starts playing, I can't seem to find out how this works/why.  Facepalm

Logged
Moth
Level 4
****



View Profile WWW
« Reply #32 on: August 31, 2015, 09:06:43 AM »

Okay, no problem:

start_tracking is a script meant to set the following variable to memorize the millsecond the song starts playing:

global.track_start=current_time;

That will set the variable global.track_start to current_time, a function which returns the milliseconds the game has been running. For example, if the game has been open for 10 seconds before the start of the song, that value would be 10000, and that's what global.track_start would be set to.

Later global.track_start will be referenced to see how long the song has been playing. Going with our above example where the song started 10 seconds in, then five more seconds after it started playing, current_time would return 15000. We take this value and reduce it by global.track_start to see how many milliseconds the song has been playing, and therefore, our position in the song (15000-10000=5000, so we are 5 seconds into the song).

Also, in the script call for running start_tracking:

Code:
play_song(song_cabeza,"Por Una Cabeza")
start_tracking()

Play the song first before you use start_tracking(), because I suspect GM might stutter several milliseconds as the song starts- if it does, running the script before the song plays would offset the millisecond timing from the proper song positioning a bit.
Logged

Pages: 1 [2]
Print
Jump to:  

Theme orange-lt created by panic