User:Mirjam Dissel/slide images

From XPUB & Lens-Based wiki
< User:Mirjam Dissel
Revision as of 13:58, 23 April 2012 by Mirjam Dissel (talk | contribs) (Created page with "slidetest2.py <source lang="python"> import pygame, sys, os, random from pygame.locals import * screen = pygame.display.set_mode((640, 480)) player = pygame.image.load("resiz...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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()