Answer the question
In order to leave comments, you need to log in
Questions about playing arkanoid on JS?
I'm new to JS, I'm doing it for practice. Looked at:
habrahabr.ru/post/202530 - arkanoid in 30 lines (no comments in the code)
codingcraft.ru/web-design/arcanoid.php - arkanoid on jQuery (but I want it on JS)
Sorry for being noob, but I don’t know where to clarify questions like:
1. It is clear that the cubes at the top are inline blocks, but what to do with the cube-div after the collision? How to remove it? Give it display: none? Moreover, so that the rest would not move and that the next time the ball flew through this place calmly through and through.
2. It is necessary not only to arrange inline-divs, but also to determine and assign its coordinates to each? Otherwise, how then will the ball know whether it crashed into something or not?
3.The direction of movement of the cutting racket. There is touch. In order to determine the direction, it is necessary to determine in advance and store the direction of the racket in its properties, and at the moment of touch, only look at the desired property?
4. At the moment the ball bounces off the obstacle, some end point is calculated and set, where will it fly? Or does it simply fly along the vector with the desired angle and each time it is checked whether it has reached some object?
Answer the question
In order to leave comments, you need to log in
1. Cubes are just not inline blocks. In this situation, when one of them is destroyed, the entire structure will move. Do it on position: absolute.
In extreme cases, just set opacity: 0
or visibility: hidden
and a condition for the ball that blocks with such and such a class should be ignored.
2. Position: absolute
solves
3. Yes, the less you calculate on the fly, the faster it works. Once we change the variable when changing by pressing the buttons to the right / left
4. Here at your discretion. With a vector it will be easier (IMHO).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question