User:Mirjam Dissel/slide images: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
Line 33: Line 33:
slideImages()
slideImages()
</source>
</source>
This is a test file, to be implemented in the bigger association machine script, to make the images move.

Revision as of 13:59, 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.