Moving Layer Calculations

Share guides you have written for SMBX, and related tools here.
Fuyu
Boom Boom
Boom Boom
Posts: 3137
Joined: Sat Dec 21, 2013 2:40 pm
Pronouns: He/Him

Moving Layer Calculations

Postby Fuyu » Sun Aug 17, 2014 2:35 pm

Ok, so same as I some people are starting to use this calculation for their own levels, and honestly, who wouldn't want some accurate moving layers? So I'm taking part of my time to explain two calculations that I'm using for my project.

If you want to calculate the speed you want for a moving layer to reach a certain position in a certain time of your choice, use the calculation below:
32 * (NºBlocks) / (Desired time) / 65 = (Desired Speed)

Though, if you want to calculate the desire time based upon a certain speed, use this calculation instead:
32 * (NºBlocks) / (Desired Speed) / 65 = (Desired time)
PixelPest wrote:Btw if you want to use more exact numbers if syncing issues are a problem use 2500/39 instead of 65 or in LunaLua code just use lunatime.toSeconds()
Note that the desired time can be deduced by replacing them like in any polynomial operation. Hope this helped.
Last edited by Fuyu on Fri Nov 03, 2017 9:42 am, edited 2 times in total.

Fuyu
Boom Boom
Boom Boom
Posts: 3137
Joined: Sat Dec 21, 2013 2:40 pm
Pronouns: He/Him

Re: Moving Layer Calculations

Postby Fuyu » Sun Sep 14, 2014 8:30 pm

Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.

HeroLinik
Boom Boom
Boom Boom
Posts: 3459
Joined: Fri Dec 20, 2013 1:28 pm
Contact:

Re: Moving Layer Calculations

Postby HeroLinik » Tue Sep 16, 2014 10:48 am

Natsu wrote:Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.
I agree. This is a helpful guide for any SMBX user, whether they are newbies or veterans, and it will save them time when trying to exact the speed/time of the moving layer. You should put the distance on there as well.

Fuyu
Boom Boom
Boom Boom
Posts: 3137
Joined: Sat Dec 21, 2013 2:40 pm
Pronouns: He/Him

Re: Moving Layer Calculations

Postby Fuyu » Tue Sep 16, 2014 10:54 am

@castlewars: The distance is the NºBlocks.

lighthouse64
Charged Spiny
Charged Spiny
Posts: 1804
Joined: Sat Apr 26, 2014 6:28 am

Re: Moving Layer Calculations

Postby lighthouse64 » Sun Sep 28, 2014 11:28 pm

Natsu wrote:Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.
Well, It happened. :)

DatDude
Lakitu
Lakitu
Posts: 490
Joined: Wed Sep 03, 2014 5:58 am

Re: Moving Layer Calculations

Postby DatDude » Sat Oct 04, 2014 6:24 am

Wait, what does the "*" stand for?

bossedit8
Banned
Posts: 6838
Joined: Fri Dec 20, 2013 12:35 pm
Contact:

Re: Moving Layer Calculations

Postby bossedit8 » Sat Oct 04, 2014 6:28 am

DatDude wrote:Wait, what does the "*" stand for?
That stands for Multiply. Like 2 * 10 = 20

PROX
Banned
Posts: 1953
Joined: Sun Jul 06, 2014 8:50 pm

Re: Moving Layer Calculations

Postby PROX » Fri Nov 21, 2014 2:58 pm

I usually just do it in my head through trial and error and it works just fine lol

Mista Epic
Guest

Re: Moving Layer Calculations

Postby Mista Epic » Sat Jan 31, 2015 2:52 pm

I've created a quick VBS file to help with this so you don't have to go through a calculator and do this. Excuse me for not making it a .EXE but I don't know how to code in VBScript or how to wrap VBScript or convert it to VBScript.

Download

I should also mention that because it is a Windows-based code, it should only work on Windows. But maybe it works on Mac or Linux or whatever. I don't know.

[]Yaroslav269[]
Fighter Fly
Fighter Fly
Posts: 40
Joined: Wed Feb 25, 2015 11:10 am

Re: Moving Layer Calculations

Postby []Yaroslav269[] » Wed Apr 08, 2015 12:36 pm

Desired time in seconds?

crusher169
Flurry
Flurry
Posts: 351
Joined: Tue Apr 22, 2014 9:09 am

Re: Moving Layer Calculations

Postby crusher169 » Thu Apr 09, 2015 3:54 am

this just doesn't work for me for some reason, I keep trying it but it isn't accurate

Trace
Buster Beetle
Buster Beetle
Posts: 431
Joined: Thu Jun 19, 2014 7:45 am

Re: Moving Layer Calculations

Postby Trace » Mon May 25, 2015 10:44 am

wait, i dont get it. HOW am i supposed to calculate it?

RudeGuy
Fry Guy
Fry Guy
Posts: 4993
Joined: Fri Dec 27, 2013 7:36 am
Flair: local guy

Re: Moving Layer Calculations

Postby RudeGuy » Mon May 25, 2015 10:53 am

Trace42 wrote:wait, i dont get it. HOW am i supposed to calculate it?
Use the calculator and write the formula in the OP replacing what needs to be replaced. Is it really that hard?

Trace
Buster Beetle
Buster Beetle
Posts: 431
Joined: Thu Jun 19, 2014 7:45 am

Re: Moving Layer Calculations

Postby Trace » Mon May 25, 2015 11:09 am

what i get when i try that is what i always get: invalid Input

RudeGuy
Fry Guy
Fry Guy
Posts: 4993
Joined: Fri Dec 27, 2013 7:36 am
Flair: local guy

Re: Moving Layer Calculations

Postby RudeGuy » Mon May 25, 2015 11:11 am

Trace42 wrote:what i get when i try that is what i always get: invalid Input
Then what about using one of the milion of calculators in the internet?

Drachenbauer
Tweeter
Tweeter
Posts: 174
Joined: Sun Sep 13, 2015 3:24 pm

Re: Moving Layer Calculations

Postby Drachenbauer » Thu Oct 01, 2015 5:27 pm

someone asked, if the time in secconds.
but got no answer...
i need this answer too.
i want to make an item move 1 block (32pix) up and needs 1 sec for this distance.
i calculated this and got a vaule with a long tail of didits after the comma...
speed: 0,4923076 (endless: the sequence 923076 will repeat forever after the comma)
is that right

RudeGuy
Fry Guy
Fry Guy
Posts: 4993
Joined: Fri Dec 27, 2013 7:36 am
Flair: local guy

Re: Moving Layer Calculations

Postby RudeGuy » Fri Oct 02, 2015 1:53 am

Drachenbauer wrote:someone asked, if the time in secconds.
but got no answer...
i need this answer too.
But it's so obvious, even the delay (the time) says that it's in seconds.
Drachenbauer wrote: is that right
Use just the first 4 numbers after the comma.

Fuyu
Boom Boom
Boom Boom
Posts: 3137
Joined: Sat Dec 21, 2013 2:40 pm
Pronouns: He/Him

Re: Moving Layer Calculations

Postby Fuyu » Sat Dec 19, 2015 4:00 pm

I apologize to those that asked on this thread, but around a year and a half I left the forums because of studies. So now I'll try to answer as many questions as possible. If you have trouble with the calculation just let me know and I'll answer as soon as possible.

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

Re: Moving Layer Calculations

Postby Quantumenace » Sun May 22, 2016 3:15 am

If I had realized this thread was a sticky I'd have posted my findings here to begin with. It's actually a little more complicated than this. The game is run in "ticks" (equivalent to frames), the speed is measured in pixels per tick, and you can't have a fraction of a tick; the layer will move a distance equal to the speed*ticks. 1 block length is equal to 32 pixels.

What makes it dicey is that the number of ticks are a bit off from what is expected.
Spoiler: show
0.1 second = 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!

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 (in pixels) is:

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

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.

HVMetal
Snifit
Snifit
Posts: 234
Joined: Tue Dec 29, 2015 9:44 am

Re: Moving Layer Calculations

Postby HVMetal » Sun May 22, 2016 5:31 am

This is probably the same but simplified with less math:

|Speed| * Delay * 2 ~ Nr. of Blocks => Speed ~ Nr. of Blocks / Delay * 2 => Delay ~ Nr. of Blocks / |Speed| * 2

The results wont be so accurate but people wont turn off "Auto Align" just to place the block 2.123 blocks away.
Speed= -2
Delay= 1
Then approx. the Nr. of Blocks will be 4 since |-2| * 1 * 2 = 4
Last edited by HVMetal on Tue May 24, 2016 10:07 am, edited 2 times in total.


Return to “Guides”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari