In a 2D display, two squares with a given speed, weight, and size (size is defined based on the weight) will collide. The goal of this project is to explore the physics (ignoring friction) behind the collision of two squares.
Project: Collision Between 2 Squares
Project Goal:
Visual Demonstration



Algorithmic Structure
MainFunction() // Ask for basic info Ask for weight and speed of square1 Ask for weight and speed of square2 // Place the squares Place square1 at a position Place square2 at another position // Main loop While the program is running If the user wants to stop, exit // Move the squares Move square1 with its speed Move square2 with its speed // Handle walls If square1 hits a wall, reverse its speed If square2 hits a wall, reverse its speed // Handle collision If square1 and square2 touch Change their speeds Count one collision End If // Display on screen Draw the squares and the number of collisions