More Personal Projects
RTS-TankCombat

What did I learn while making a 2D RTS Tank Combat similar to the Command and Conquer game?
I implemented pixel-based diagonal movement using the slope formula. When the player clicked on a location with the mouse after selecting the tank image, the tank calculated the optimal path using the slope formula to move diagonally. If the clicked location created a horizontal or vertical path, the tank would move in straight lines along the respective axis using basic algebraic slope logic.
​​
Challanges when coding this game?
One of my challenges during this development process was implementing a normalized vector for diagonal movement. I explored different approaches to achieve this, but due to the demands of full-time work and full-time school, I didn’t have time to fully implement it.
​​
Solution to the problem?
​To normalize a vector for diagonal movement, I calculated the direction of the vector by finding the change in position from the tank's starting position to the ending position where the mouse clicked. After calculating the directional vector, the next step is to find the length between the starting and ending points using the Pythagorean theorem. This length is used to normalize the vector, ensuring consistent movement regardless of direction. Normalized vector, I divided the changed in x with the length of the vector and the change in y with the length of the vector to reduce the original vector to a unit vector that retains its direction with magnitude 1
