Moving Car Program in C++
This program is written in C++ using graphics to create and move a car.
- A car is made using two rectangles and two circles which act as tyres of car.
- A for loop is used to move the car forward by changing the rectangle and circle coordinates and erasing the previous contents on screen using clearviewport, you can also use cleardevice.
- Speed of car can be adjusted using delay function, more the delay lesser will be the speed or lesser the delay your car will move fast. In this program color of the car also keeps on changing, this is accomplished by incrementing the color value by one each time in for loop, you can also use random function for this purpose.
/*Moving a car*/
for (int i=0;i<500;i++)
/***CAR BODY ******/