Moving the element in a random direction is the basic concept behind programmatic mathematics. Where the different rules and conditions are. This is a simple web Application that's show you how things are work in mathematical way.
We use the angle for moving ball and calculate Cos/Sin again and again. If you want to go in advance them you can calculate with use unit velocity direction vector with components. And when ball get hit the wall we change the angle by use of 180/360.
Here is the all material if you want to understand how is works. You need these videos for better understanding.
- Click on green Clone or download button and choose Download ZIP.
- Find the downloaded zipped file on your pc and extract it.
- Go to folder. Inside the folder you will find a file named index.html.
- Double click on index.html file and your browser wlicenseill open (or maybe just a new tab) and you will see the reuslt.
- If for whatever reason your browser does not open, right click on index.html file go down to Open with and choose your web browser. This will open the browser and launch it.
Once you are done playing you can close the tab in your browser.
If you have any issues with the feel free to let me know!
If you are more interested, check out the collection of others DSDmark Repos.