Skip to content
ExamplesOpen editor ↗

paloYaDikgato

→ frameCount

How many frames `tshwantsha` has drawn since the sketch started.

paloYaDikgato

It starts at 0 and goes up by one on every frame. With tshwantsha running about 60 times a second, paloYaDikgato reaches 60 after one second.

It is what you use for things that repeat: paloYaDikgato % 60 gives you the frame’s number within the second, and fa (paloYaDikgato % 30 === 0) happens twice a second.

It does not count time — it counts frames. On a slow computer it rises slowly, which is what nakoYaKgato is for.

A circle that jumps every 30 frames
tiro setaLoeto() {
  thalaKanefase(400, 200);
  tlhalosa('Sediko se se fetolang mmala le lefelo morago ga sephatlo sa motsotswana mongwe le mongwe.');
}
tiro tshwantsha() {
  bokamorago(240);
  tlogelaMothalo();

  // Nomoro ya kgato mo lenaneong la 30
  metlha kgato = paloYaDikgato % 30;

  tlatsaMmala(lekanyetsa(kgato, 0, 29, 60, 240), 120, 200);
  thalaSediko(lekanyetsa(kgato, 0, 29, 60, 340), 100, 70);

  bogoloJwaMokwalo(16);
  tlatsaMmala(40);
  thalaMokwalo(paloYaDikgato, 20, 30);
}

tshwantsha, nakoYaKgato, lebeloLaDikgato, millis