Skip to content
ExamplesOpen editor ↗

phetogoYaPebaX

→ movedX

How far the mouse moved sideways since the previous frame.

phetogoYaPebaX

A number that is negative when the mouse went left and positive when it went right. When the mouse has not moved, it is zero.

It is NOT pebaX - pebaXEFetileng, however much it looks as though it should be. Measured in the running Bopa editor: on one drag, pebaX - pebaXEFetileng was 22.5 while phetogoYaPebaX was 68 — three times larger. The reason is that phetogoYaPebaX comes from the browser’s movementX, which is measured in screen pixels, while pebaX is measured in canvas pixels. Whenever the canvas is displayed larger or smaller than its true size, the two numbers differ by exactly that factor.

It is also reset to zero at the end of every frame. So its right home is inside pebaEGogilwe or pebaESutile — not inside tshwantsha, where it is usually zero.

Use it when you want a step rather than a position: spinning a picture by however far the mouse travelled, or driving the speed of something.

phetogo, not peba…. The name does not begin with peba because it does not tell you where the mouse is — it tells you how much it changed. That is a change, and phetogo is the ordinary Setswana word for one. The cost, recorded rather than hidden: it does not sit beside the other mouse members in an autocomplete list.

Spin a square by dragging
diri sekhutlo = 0;

tiro setaLoeto() {
  thalaKanefase(400, 260);
  seeloSaSekhutlo(DEGREES);
  tlhalosa('Sekwere se se mo bogareng se se retologang fa peba e gogwa ka fa thoko.');
}

tiro tshwantsha() {
  bokamorago(236);
  tlogelaMothalo();
  tlatsaMmala(120, 160, 210);

  baya();
  sutisa(200, 130);
  dikolosa(sekhutlo);
  thalaSekwere(-60, -60, 120);
  tsaya();
}

tiro pebaEGogilwe() {
  sekhutlo = sekhutlo + phetogoYaPebaX;
}

phetogoYaPebaY, pebaXEFetileng, pebaX, pebaEGogilwe