Are timers in gdevelop working with timedelta?
For example, if a game gets a frame drop, does that cause the timer to slow down (gets offset as compared to the real time) or does it continue to show the correct time (automatically takes into consideration frame drops/lag)?
in order to get a timer that automatically corrects itself when there are frame drops. Or does the timer in gdevelop already do that? In which case, setting up an elaborate timer like the one in the link would be kind of a waste of time (no pun intended).
You can let the timer run, and then test each seconds. i’ll post an example that you can test (I can’t create FPS drop myself).
Like this : Projet.gdg (7.26 KB)
(Adapt BEAT_INTERVAL and the sound files).
Ok thinking more about it, the problem really is with the sound system. When the game lags, the music that is played also lags. This introduces a time offset between the game’s internal clock (timer) and the actual song being played. A single offset breaks the entire game onward- because it is based on timing.
Basically I see two ways around it:
I can do one of the two:
get a timer that lags with the game - equal to the lag of the music - so when music lags,timer lags too. (both timer and music lag)
get a way to readjust the music, so when a lag is introduced, the game readjusts the timing of the music to be correct with the game’s timer
(music lags–>music readjusts itself - skips ahead to make up for the lag so its back to the same value as the timer)
The music that is played has a timer of its own that just as any other timer in gdevelop does not get affected by lags. So when there is a lag, instead of pausing/slowing the music, the game skips to the appropriate time of the song. Automatically correcting the time of the song.
-do it manualy - New condition to check if the game framerate is too low and a new action to set the music being played time to a new value (in this case - set it to the overal timer clock we have running from the beginning of the frame)
or do it internally - automatically.
this is important to get right before doing any further work. I will try to implement a laggy timerwith the event system now
EDIT: After further look into this, I need to be able to get the game’s current framerate in order to be able to implement a laggy timer with this logic:
in place of the “60” I need to put an expression command that gets the game’s current FPS. Can this be done in gdevelop?
Just discovered that gdevelop , being awesome as it is, has a way of checking the current time of a channel!
So I added a line to check if there is an offset that is bigger than 0.25. If so, readjust the time of the music playing in channel 0 to the time of the overalTime timer.
This way it will stay in sync when there is lag, but there will be an ugly skip in the song if there is offset.
A better solution would be to have the timer lag with the song lag. I tried to do that with the previous post formula and got horrible results.
I am actually getting a new idea! Why not set the timer to the song offset!
That way the lag happens to the song - then instead of the song skipping ahead - the timer readjusts itself.
Since there is no action to adjust the value of a timer, I have to store the timer in a variable. This probably doesnt work, because the variable is overwritten by the other action which sets it to the overalTimer timer.
Or even a cleaner solution would be instead of using a stupid timer, just use the song offset!
but for some reason this stops working after a while. Probably because after the first loop, the song’s offset is lower than the nextBeat value. Unfortunatelly there is no way to check how many times a song has looped.
Why is the sound performance so bad in html5 and ok in native?
Ok the best solution to me seems to be in using the song’s offset rather than a timer. The problem with that is that gdevelop does not show it in milliseconds and skips evaluating the time between seconds
I need to be able to evaluate in quaters of a second at least:
I having been developing a rhythm game for android in gdevelop for 6 months now. I can assure you everyone making rhythm games is over complicating it. My game is set up for 360p resolution. 360 x 640. My graphics are all PNG high quality with transparency. My songs are all MP3 and my sound effects are all wavs. My arrows come from the top and are laid out manually in the scene at 500px force on y value. I have one song that’s even over 1100 notes. And it runs perfectly fine with no lag and matches the song how I built it. I’ve had a few people say I have to sync the video with the audio and other crap but it’s not true. As long as the resolution is low enough for the phone running it to play it there is no video lag. and the game works fine. It doesn’t look bad at 360p either. And it runs on a phone I have that is like 15 years old. Gdevelop is an excellent program. I built an Online leaderboard in it. I had to test my game over 1000 times to get it working right. For some reason the timing is off when I test it, but it’s fine on android. I figured it out by testing over and over. But the song and notes stay in sync the whole time now. All you have to do is create a blank hit box spanning above your target zone about 2000 pixels. a different blank box in the target area, and a blank line underneath the target area for another hit test. Buttons have to me set up properly. And when you do the hit test on push on a button you have to use the code, pick the object that is closest to (whatever pixels are closest to the target area) once I did that it was able to only focus on the arrows that where in the target area. You need a script for on push in the outer target area for a miss, and a script on push in the target area for a successful hit. When the user gets a successful note, the animation in the arrows change to a different animation with no hit test box. called “clear” So if you hit it on time it can’t collide with the box below the target area for a miss. and if you press the button too early it hit tests on the outer area box that is also a miss. I have 14 different styles of buttons and arrows, and it doesn’t slow the game down at all. Each arrow has 14 different animations inside of it and some songs are over 1000 notes. so 14000 animations in one object times 4 in one scene. And it doesn’t lag at all. My frame rate is 26. Once you lower the resolution enough you would be surprised at how well gdevelop works.
I figured I’d explain this to people because I see everyone struggling trying to make the notes come at specific times. Don’t do that! Just lay them out above at a certain speed. Guitar hero does it that way. And if the user misses, reset the note streak variable etc. etc. And make the volume on the song drop 70 percent for a few seconds or until the user hits a successful note again.
Rhythm Retro will be available in a month or two on the play store. Thanks.