Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+5 votes

Hi guys, I am working on my midterm 3, and wondering how I could make the car move. As I create the method move and call it in while loops of the main function but they do not move at all. Are there any recommendations? Thanks

asked in CSC201 Spring 2021 by (1 point)

2 Answers

+5 votes

In the move method, you should have a randomly generate x which is the distance the car moves horizontally. As the car only moves horizontally, y will be 0. So you will have something like this:
You will have to move all the four parts of the car ( Body, top, frontWheel, backWheel)

answered by (1 point)
+3 votes

you need to create a move method that moves all the body parts in the x-direction where x is a randomly generated number from 5,15. So when you call move, you just do the object.move() where the object is either a red car or a blue car, so you need to do it for both. So you either don't see it move because you move it in the y direction and/or you don't have a time.sleep in your while loop.
Hope that helps,

answered by (1 point)