marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.02k stars 796 forks source link

Small bugs in platformer tutorial #515

Closed lemiesz closed 4 years ago

lemiesz commented 4 years ago

I noticed a few bugs while going through the platformer tutorial Chatper 16. https://eloquentjavascript.net/16_game.html

1.) When creating the Coin class the use of Math.sin() is mentioned. However the create method omits this in its third paramter

return new Coin(basePos, basePos, Math.random() * Math.PI * 2);

2.) The simpleLevel plan can break if it is used in a editor that has autoformatting. In my case VSCode was adding additional spacing to some of the lines. I was able to fix this by trimming each row before mapping it.

let rows = plan.trim().split("\n").map(l => [...l.trim()]);

lemiesz commented 4 years ago

Ah i spoke to soon. You add the Math.sin() in the update method.

marijnh commented 4 years ago

The simpleLevel plan can break if it is used in a editor that has autoformatting. In my case VSCode was adding additional spacing to some of the lines.

I'd say that's an (embarassing) bug in VSCode, and not something my code can help. Proper autoformatting (example) would know to leave template strings alone.

lemiesz commented 4 years ago

yah but also .trim() would solve that issue.