Closed Eilandis closed 5 years ago
Thanks for the fixes! Though it was supposed that the type was called "CrystalsWidget", and the real typo is at line https://github.com/ct-js/docs.ctjs.rocks/pull/12/commits/02cf39d26f9180a4b71e0600aadc77f2727000ae#diff-b17a7df3caa6d9cf99c4c9fda01cad96R497
In the last code snippet (better code for moving platforms), you look for the robot two times [...] Is there any reason for that?
Yes, there is. We have two clauses: when a robot overlaps with a platform and when it doesn't. If a robot does, then the platform can be walked through.
In the second case, when a robot does not overlap with a platform, the platform does not yet know about the existence of the robot, because ct.place.meet(this, this.x, this.y, 'Robot');
returns nothing. Thus, the robot
is undefined as well. We need to search again, above the platform, if we want to move our robot. As we have pixel-perfect collisions, a lookup at one pixel above the platform is enough. robot = ct.place.occupied(this, this.x, this.y - 1, 'Robot');
finds a robot that is standing right on top of the platform, so the variable robot
can be defined (and used) once again.
I'll push the fixes for CrystalsWidget
and a better explanation of the platform code in the nearest time.
You named the crystal widget
CrystalCounter
in the tutorial, notCrystalsWidget
. (also, the linect.types.copy('CrystalCounter', 0, 0);
does not appear on the screenshot below, and therefore is not explained)In the last code snippet (better code for moving platforms), you look for the robot two times (
var robot = ct.place.meet(this, this.x, this.y, 'Robot');
thenrobot = ct.place.meet(this, this.x, this.y - 1, 'Robot');
). Is there any reason for that ?Thanks for the tutorial ;)