Skip to content

Commit 81202c3

Browse files
authored
Fix Kitchensink live example (mdn#41559)
1 parent cded376 commit 81202c3

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

files/en-us/mdn/kitchensink/index.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,24 +366,29 @@ if (5 < 30 && 55 > 20 && 5 < 20 && 55 > 10) {
366366
```js
367367
Crafty.init(200, 200);
368368

369-
var dim1 = {x: 5, y: 5, w: 50, h: 50}
370-
var dim2 = {x: 20, y: 10, w: 60, h: 40}
369+
var dim1 = { x: 5, y: 5, w: 50, h: 50 };
370+
var dim2 = { x: 20, y: 10, w: 60, h: 40 };
371371

372372
var rect1 = Crafty.e("2D, Canvas, Color").attr(dim1).color("red");
373373

374-
var rect2 = Crafty.e("2D, Canvas, Color, Keyboard, Fourway").fourway(2).attr(dim2).color("blue");
374+
var rect2 = Crafty.e("2D, Canvas, Color, Keyboard, Fourway")
375+
.fourway(2)
376+
.attr(dim2)
377+
.color("blue");
375378

376379
rect2.bind("EnterFrame", function () {
377-
if (rect1.x > rect2.x + rect2.w &#x26;&#x26;
378-
rect1.x + rect1.w > rect2.x &#x26;&#x26;
379-
rect1.y > rect2.y + rect2.h &#x26;&#x26;
380-
rect1.h + rect1.y > rect2.y) {
381-
// collision detected!
382-
this.color("green");
383-
} else {
384-
// no collision
385-
this.color("blue");
386-
}
380+
if (
381+
rect1.x > rect2.x + rect2.w &&
382+
rect1.x + rect1.w > rect2.x &&
383+
rect1.y > rect2.y + rect2.h &&
384+
rect1.h + rect1.y > rect2.y
385+
) {
386+
// collision detected!
387+
this.color("green");
388+
} else {
389+
// no collision
390+
this.color("blue");
391+
}
387392
});
388393
```
389394

0 commit comments

Comments
 (0)