nakoYaKgato
→ deltaTimeHow long the previous frame took to draw, in milliseconds.
nakoYaKgatoComputers do not all run at the same speed. If you move something with x = x + 2 every frame, it travels fast on a quick computer and slowly on a slow one.
nakoYaKgato fixes that. Instead of moving by a fixed amount each frame, you move by an amount that depends on how long the last frame took: x = x + 60 * nakoYaKgato / 1000 travels 60 pixels a second on every computer.
When things are going well it sits near 16.7 — one second divided by 60.
There is no Setswana word for “millisecond”. It is seripagare se le sengwe sa motsotswana — one thousandth of a second. See
millis.
Examples
Section titled “Examples”diri x = 0;
tiro setaLoeto() {
thalaKanefase(400, 200);
tlhalosa('Sediko se se tsamayang go tswa molemeng go ya mojeng, se boela kwa tshimologong fa se fitlha kwa bokhutlong.');
}
tiro tshwantsha() {
bokamorago(240);
tlogelaMothalo();
tlatsaMmala(220, 90, 70);
// Diphikisele di le 120 mo motsotswaneng, go sa kgathalesege lebelo la khomphiutha
x = x + 120 * nakoYaKgato / 1000;
fa (x > 400) {
x = 0;
}
thalaSediko(x, 100, 60);
}