What I Made!
I have been participating in MIT/Emeritus’ Coding Bootcamp. In Module 2, we were challenged to create a program that made a ball move. First, we made the ball move in one dimension, on the x-axis. Then, we were asked to make the ball move in two dimension, the x-axis and y-axis. After about half a day of trying different things, I managed to get my ball to move diagonally.
What I Tried
At one point, I tried to make a container for the ball to bounce around in. I finally got it to work in one dimension, but I struggled to make it work in two dimensions. I took out the container div and instead added the Xmin, Xmax, Ymin, and Ymax variables instead. I originally had the variable direction, but changed that to reverse due to part of the challenge requirements. To make the ball move on the y-axis, I copied the same if statement and changed the X to Y.
What I Would Do Differently
At this point, my code is pretty cluttered. With time, I’m hoping to learn how to accomplish the same task with less code. Overall, I enjoyed this task. It was challenging, but it felt great when I finally got the ball to do what I wanted.