User:Mirjam Dissel/slide images: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
[[File:Slideimages.png|257px]] | |||
slidetest2.py | slidetest2.py | ||
<source lang="python"> | <source lang="python"> |
Latest revision as of 14:03, 23 April 2012
slidetest2.py
import pygame, sys, os, random
from pygame.locals import *
screen = pygame.display.set_mode((640, 480))
player = pygame.image.load("resized/0_resized.jpeg").convert()
WHITE = (255,255,255)
#background = screen.fill(WHITE)
background = pygame.image.load('resized/2-6_resized.jpeg').convert()
screen.blit(background, (0, 0)) #draw the background
position = player.get_rect()
screen.blit(player, position) #draw the player
pygame.display.update() #and show it all
def slideImages():
global position
for x in range(100): #animate 100 frames
screen.blit(background, position, position) #erase
position = position.move(0, 2) #move player
screen.blit(player, position) #draw new player
pygame.display.update() #and show it all
pygame.time.delay(5) #stop the program for 1/10 second
while 1:
for event in pygame.event.get():
if event.type in (QUIT, KEYDOWN):
sys.exit()
slideImages()
This is a test file, to be implemented in the bigger association machine script, to make the images move.