Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo D. Arce S <rodolfo.arce.s@gmail.com>2011-05-12 18:19:38 (GMT)
committer Rodolfo D. Arce S <rodolfo.arce.s@gmail.com>2011-05-12 18:19:38 (GMT)
commit5a7e21902636fd1bea66ca3fde3ecdff73a5ade3 (patch)
tree9bce8de7393997ae69b4d15bd65279f4613a2757
parent41927a251dda31adc8451d76e3545235429b4eba (diff)
Added random movement for garbage object
-rw-r--r--README1
-rw-r--r--images/paper.pngbin1374 -> 1849 bytes
-rw-r--r--main.py22
3 files changed, 15 insertions, 8 deletions
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()