naveenraj2001 Posted September 1, 2019 Share Posted September 1, 2019 topic : Obstacles of Random Size myObstacles.push(new component(10, x - height - gap, "green", x, height + gap)); I can't find why (x-height-gap) is used for height if you can explain it it will be big help https://www.w3schools.com/graphics/game_obstacles.asp Link to comment Share on other sites More sharing options...
Funce Posted September 3, 2019 Share Posted September 3, 2019 X - Height - Gap is used so that the the second obstacles reach the bottom of the screen. Though "y" would be a better choice (canvas.height) this is immaterial as the code always runs with the width as larger than the height, which is the requirement for the bottom obstacle. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now