Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mario - Fixes #47

Open
soggybag opened this issue Oct 27, 2020 · 0 comments
Open

Mario - Fixes #47

soggybag opened this issue Oct 27, 2020 · 0 comments

Comments

@soggybag
Copy link
Owner

ctx.rect( 4 * size + 5 , 1 * size + 5 , size - 10, size -10)

This looks pretty good. I feel like you're writing more code than you need to. Might be easier to define the x and y once at the top and use them in the code below:

// define x and y here
const x = 4 * size
const y = 1 * size

ctx.beginPath()
// Use x and y here
			ctx.rect(        x + 5 , y + 5  , size - 10, size -10)
			ctx.fillStyle = 'red'
			ctx.fill()
            ctx.beginPath()
// and here
            ctx.rect(x + 10 , y + 10  , size - 20, size -20)
			ctx.fillStyle = 'orange'
			ctx.fill()
            ctx.beginPath()
// and here
            ctx.rect(x + 15 ,   y + 15  , size - 30, size -30)
			ctx.fillStyle = 'yellow'
			ctx.fill()
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant