phetogoYaPebaX
→ movedXHow far the mouse moved sideways since the previous frame.
phetogoYaPebaXA 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 - pebaXEFetilengwas 22.5 whilephetogoYaPebaXwas 68 — three times larger. The reason is thatphetogoYaPebaXcomes from the browser’smovementX, which is measured in screen pixels, whilepebaXis 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
pebaEGogilweorpebaESutile— not insidetshwantsha, 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, notpeba…. The name does not begin withpebabecause it does not tell you where the mouse is — it tells you how much it changed. That is a change, andphetogois 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.
Examples
Section titled “Examples”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;
}