en de

Modulo

Der Star des heutigen Türchens ist ein mathematisches Tool. Die Modulo Funktion. Die für zwei Zahlen den Rest der Ganzzahligen Division der einen durch die andere liefert. Damit lassen sich z.B. mit einem Spritesheet sehr leicht Animationen abspielen, wenn die Frames in der richtigen Reihenfolge angeordnet sind. Ein Tool für Game Jams und kleine Projekte.

Anbei eine Tabelle für einigen Modulo-Variation wobei f die Frames oder Ticks raufzählt.

f f%3 f%6 (f%6)+22 flr(i/2)%3 abs((f%6)-3)
0 0 0 22 0 3
1 1 1 23 0 2
2 2 2 24 1 1
3 0 3 25 1 0
4 1 4 26 2 1
5 2 5 27 2 2
6 0 0 22 0 3
7 1 1 23 0 2
8 2 2 24 1 1
9 0 3 25 1 0
10 1 4 26 2 1
globaler Frame counter 3 Frames 6 Frames 6 Frames
ab 22
halb so schnell hin und her. knight rider mode

===

The tool of today is a mathematical function. The Modulo Function or Operator which gives the Remainder of a Division of the two arguments. This can be used to very lightly index an animation in simple well ordered spritsheet. This might be sometimes everything you need during a jam or for a small project.

Above is a table of some handy modulo variations, where f counts the frames or ticks.