From 5a7e21902636fd1bea66ca3fde3ecdff73a5ade3 Mon Sep 17 00:00:00 2001 From: Rodolfo D. Arce S Date: Thu, 12 May 2011 18:19:38 +0000 Subject: Added random movement for garbage object --- diff --git a/README b/README index fe97cd2..369c6ad 100644 --- a/README +++ b/README @@ -12,6 +12,7 @@ http://www.openclipart.org/detail/161 Paper: http://www.openclipart.org/detail/16727 +http://www.openclipart.org/detail/102793 Person: http://www.openclipart.org/detail/27903 diff --git a/images/paper.png b/images/paper.png index fc510bc..7c24e85 100644 --- a/images/paper.png +++ b/images/paper.png Binary files differ diff --git a/main.py b/main.py index f5b2fcb..101b2de 100644 --- a/main.py +++ b/main.py @@ -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() -- cgit v0.9.1