Nailing Down SMBX FPS and Event/Layer Timing

General discussion about Super Mario Bros. X.
User avatar
Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Nailing Down SMBX FPS and Event/Layer Timing

Postby Quantumenace » Thu Apr 28, 2016 11:39 pm

Supposedly SMBX runs at 65 frames per second, at least according to the FPS counter. However, I'm trying to sync the timing of events in a particular section of my level to music, and noticed that 65 ticks per second isn't really that accurate.

Using this code:
Spoiler: show

Code: Select all

starttime = 0
dtime=0
tickcounter=-10 --small delay at start

function onTick()
	tickcounter=tickcounter+1
	if tickcounter > 0 then
		dtime= os.clock()-starttime
		Text.print(math.floor(dtime/60)..":"..dtime%60,0,0)
		Text.print(tickcounter,0,16)
		Text.print(tickcounter/dtime,0,32)
	elseif tickcounter == 0 then
		starttime=os.clock()
	end
end
I get about 64.1 ticks per second, not 65. I'd like to know what other people get on other systems.

...But that doesn't matter too much to most people. What really matters (at least when you're not using LunaLua) is the timing on moving layers.

I measured the number of ticks between a pair of events triggering each other on a given delay, causing a block to move up and down. As expected, at speed 1 the block moved the same distance as the number of ticks (speed being measured in pixels per tick, where a block length = 32 pixels). The number of ticks, however, turned out strange:
Spoiler: show
0.1 = 7 ticks
0.2 = 14 ticks
0.3 = 21 ticks
0.4 = 27 ticks
0.5 = 33 ticks
0.6 = 40 ticks
0.7 = 47 ticks
0.8 = 53 ticks
0.9 = 59 ticks
1.0 = 66 ticks
1.1 = 73 ticks
1.2 = 79 ticks
1.3 = 85 ticks
1.4 = 92 ticks
1.5 = 99 ticks
1.6 = 105 ticks
1.7 = 111 ticks
1.8 = 118 ticks
1.9 = 125 ticks
2.0 = 131 ticks

8.0 = 521 ticks
No wonder it's so hard to prevent cycling layers from getting farther and farther off if you don't use the same speed and delay both ways. A 2 second delay isn't even the same as two 1-second delays!

Natsu said in this thread that, effectively, the distance moved is speed*time*65. This is pretty close, but you can't have a fraction of a tick. The number of ticks for a given number of seconds appears to be:

(seconds*65)+1, rounded to the nearest ODD number if it ends in .5

Normally .5 is rounded to the nearest even number, but presumably it's rounded before the 1 is added, resulting in it rounding towards odd numbers instead.

In that case the distance moved is:

speed*((seconds*65)+1, rounded to the nearest ODD number if it ends in .5)

The extra 1 is what tends to throw off the timing of layers. For example, a speed of -1 for 2 seconds and a speed of 2 for 1 second moves the layer -131 and then +132, causing it to go further off by 1 each cycle.

However, moving it by -1 for 1 second and +2 for 0.5 seconds does work because the number of ticks for 1 second is twice the number for 0.5 seconds. Another solution is to split up the first delay, so you have the layer moving -1 for 1 second, then -1 for 1 second again, then +2 for 1 second.

It's all in how the ticks add up. I hope this is helpful!
Last edited by Quantumenace on Fri May 20, 2016 2:54 am, edited 3 times in total.

Enjl
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 8734
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Orphion Egamalenitar Osmos IV, Esq.

Re: Nailing Down SMBX FPS and Event/Layer Timing

Postby Enjl » Fri Apr 29, 2016 12:44 am

SMBX frames per second are about 64.14. I have noticed that the calculation is off after a while, too. What I usually do is just test out numbers until I get something that works.
Ideas are useless if you can't make them real.
Image

User avatar
Imaynotbehere4long
Kamikaze Koopa
Kamikaze Koopa
Posts: 1389
Joined: Thu Jan 23, 2014 3:00 pm
Current Project: Chaotic Culmination: Universe Rescuer

Re: Nailing Down SMBX FPS and Event/Layer Timing

Postby Imaynotbehere4long » Thu May 19, 2016 10:04 pm

I actually figured out that Natsu's formula didn't quite work for looping movements shortly before you made this thread, but never got around to posting about it. While the chart has been helpful for me, I have a complaint about this:
Quantumenace wrote:The number of ticks for a given number of seconds appears to be:

(seconds/65)+1, with a .5 rounded to the nearest ODD number
I can't figure out how you expect people to be able to use that formula. You give an example, but never properly walk people through how to use it. For example, let's use a 1 second delay, like you did in the example. 1/65= ~0.015. Then the formula says to add 1 to it, giving us 1.015. Then there's that last part: a .5 rounded to the nearest odd number. I assume you mean to add this to the number we already have, which would give us 1.515. However, the nearest odd number to that would be 1, an entire 65 ticks too low. Either you left out a step or didn't explain your formula well. I'd appreciate if you would clarify this.
I've decided to cancel SMBXville Under Seige. After my 1st Senior year of college, I realized I wouldn't have enough time to devote to finishing my four-level episode. Apologies to those who cared.
My favorite quote on the entire forum:
Spoiler: show
mechamind wrote:
AeroMatter wrote:People who think "autistic" is an adjective and not a verb.
You autistic some people so much with that statement.
My SMBX portfolio:
Spoiler: show
Image
(includes a Sonic 3D Blast styled level.)
SOMEONE ANSWER MY CRY FOR HELP: http://www.supermariobrosx.org/forums/v ... =69&t=2026

User avatar
Quantumenace
Ripper II
Ripper II
Posts: 308
Joined: Mon Dec 28, 2015 2:17 am

Re: Nailing Down SMBX FPS and Event/Layer Timing

Postby Quantumenace » Fri May 20, 2016 2:51 am

*facepalm* I meant to say you need to multiply the seconds by 65, not divide. I edited the post to fix it. Sorry about that.

So, multiply the number of seconds by 65, add 1, and round to the nearest odd number if the result ends in a .5.

User avatar
Imaynotbehere4long
Kamikaze Koopa
Kamikaze Koopa
Posts: 1389
Joined: Thu Jan 23, 2014 3:00 pm
Current Project: Chaotic Culmination: Universe Rescuer

Re: Nailing Down SMBX FPS and Event/Layer Timing

Postby Imaynotbehere4long » Fri May 20, 2016 11:40 am

Ah, that makes way more sense! Thanks for the clarification; this will be really helpful for me.
I've decided to cancel SMBXville Under Seige. After my 1st Senior year of college, I realized I wouldn't have enough time to devote to finishing my four-level episode. Apologies to those who cared.
My favorite quote on the entire forum:
Spoiler: show
mechamind wrote:
AeroMatter wrote:People who think "autistic" is an adjective and not a verb.
You autistic some people so much with that statement.
My SMBX portfolio:
Spoiler: show
Image
(includes a Sonic 3D Blast styled level.)
SOMEONE ANSWER MY CRY FOR HELP: http://www.supermariobrosx.org/forums/v ... =69&t=2026

User avatar
Valtteri
Larry Koopa
Larry Koopa
Posts: 2153
Joined: Sun Dec 01, 2013 1:16 pm

Re: Nailing Down SMBX FPS and Event/Layer Timing

Postby Valtteri » Sun Jun 12, 2016 9:00 am

The exact FPS of SMBX is 1/0.0156 = 64.1025 641025 641025...
Image


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests