Some advice to help you implement the cars and trucks assignment:
Consider a rectangle shape from the drawCar method as an example. The rectangle’s upper left corner is at (100,150), width is 100, and height is 50.
def drawCar(x,y,scale): pygame.draw.rect(surface, color,(100 + x, 50 + y, 100 * scale, 50 * scale) # more shapes completing the car drawing
Then in “main”:
vehicle = random.randint(1,2) x = random.randint(20,30) y = random.randint(10,20) scale = random.random() if vehicle == 1: drawCar(x,y,scale) else: drawTruck(x,y,scale)
1. Define all definitions without x, y and scale.
2. Test them all
3. Include x and y and test your program again.
4. Include the scale and test your program again.
5. Include the random component