diff options
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -3,6 +3,7 @@ import os import sys import time +import random import pygame from pygame.locals import * @@ -22,9 +23,9 @@ screen.blit(object_background, (0, 0)) speed = 9 # Garbage image -#object_garbage = pygame.image.load('images/paper.png') -#position_garbage = [ 400, 300 ] -#screen.blit(object_garbage, position_garbage) +object_garbage = pygame.image.load('images/paper.png') +position_garbage = [ 400, 300 ] +screen.blit(object_garbage, position_garbage) # Robot image object_robot = pygame.image.load('images/robot_1.png') @@ -90,12 +91,17 @@ while not exit: # draw the background first, because it will cover all the screen screen.blit(object_background, (0,0)) # draw everything else over the background + # Robot screen.blit(object_robot, (position_robot[0], position_robot[1])) - - # Move the character around the screen - position_robot = [((position_robot[0] + x_direction * speed )%window_w), ((position_robot[1] + y_direction * speed )%window_h) ] - - + # Move the character around the screen + position_robot = [((position_robot[0] + x_direction * speed )%window_w), \ + ((position_robot[1] + y_direction * speed )%window_h) ] + + # Garbage + screen.blit(object_garbage, (position_garbage[0], position_garbage[1])) + position_garbage = [((position_garbage[0] + random.randint(0,10) )%window_w), \ + ((position_garbage[1] + random.randint(0,10) )%window_h) ] +# position_garbage = [(position_garbage[0] + 3 ), (position_garbage[1] + 3 ) ] pygame.display.update() pygame.quit() |