-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
- Instead of global variables you can group application state into abstractions like struct/object, classes, closures, functors:
Lines 1 to 8 in 5603d25
let cvs = document.getElementById("canvas"); let ctx = cvs.getContext("2d"); let frog = new Image(); let background = new Image(); let foreground = new Image(); let fly = new Image(); let pipeBottom = new Image(); - Multiple magic numbers and global variables, terrible approach for application state:
Lines 19 to 41 in 5603d25
function jump(){ yPos -= 100; } let pipe = []; pipe[0] = { x: cvs.width, y: 300 } let xPos = 10; let yPos = 490; let widthFrog = 90; let heightFrog = 80; let grav = 3; let max = 100; let gap = 90; let score = 0; - Use intermediate variables and constants instead of hardcodes magic numbers:
Line 48 in 5603d25
ctx.drawImage(fly, pipe[i].x, pipe[i].y - pipeBottom.height + gap, 50, 50); - Decompose complex conditions/expressions:
Line 61 in 5603d25
if (xPos + widthFrog >= pipe[i].x && yPos + heightFrog >= pipe[i].y) { - Project is short and rude, no linting, not prettier, no tests, single commit (no work history)
Metadata
Metadata
Assignees
Labels
No labels