Add exact physics in order to give the game a more natural look.
Now we need to do a few fixes to the paddle.…In order to add collision to the paddle, we need to add…the same logic we did to the bricks.…First of all, we need to add the registration point…to the paddle…so that X0 and Y0 values of the paddle will be exact…middle of the paddle.…
So we're gonna add the paddle registration X as half…the width of a paddle, and registration Y as half…the height of the paddle.…We've added the get.bounds function here.…As you can see, we're testing it in the check collision.…Now when test the general element and ask for the…get.bounds function, it's supposed to give us the…rectangle of that hit element.…Now this rectangle is not part of the create JS framework.…
We need to add it manually.…Every time we want to test the bounds of a certain element…by using the get.bounds, we need to make sure that we set…it beforehand when we created that element.…So we're gonna set bounds of the paddle.…We're setting the middle point, which is the paddle…registration X and paddle.…
Registration Y, and then we set the…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Playing sounds in various browsers using SoundJS
- Tweening objects using TweenJS
- Creating graphic assets and basic animations
- Game stage creation and object positioning
- Adding the basic game logic
- Add the game physics
- Adding mouse and keyboard controls
- Debugging with breakpoints in Chrome
- Debugging on Android and iOS
- Character movement and input handling