[Tutor] images in pygame
Joe F
english_summer_rain01 at yahoo.com
Sun Jul 23 19:51:48 CEST 2006
Hello, I have a code here. and I want to make the "rockwholescreen.gif" blocked, but still displayed. I want it so "001.png" can't walk through that gif. any ideas?
import pygame, os, sys
from pygame.locals import *
pygame.init( )
def _loadImages_ ( path, name ):
image_obj = os.path.join( path, name )
image_load = pygame.image.load( image_obj )
return image_load
images_path = './img/'
images_dict = {}
image_names = { 1:"001.png", 2:"rockwholescreen.gif" }
for dir, name in image_names.items( ):
images_dict[dir] = _loadImages_( images_path, name )
setwinsize = ( 640, 480 )
windows = pygame.display.set_mode( setwinsize )
#load First Image
imageload = images_dict[1]
imagerect = imageload.get_rect( 0, 0, * windows.get_size( ))
#load Second Image
imageloads = images_dict[2]
imagerects = pygame.Rect( 0, 448, * windows.get_size( ))
while True:
events = pygame.event.wait( )
if events.type == pygame.QUIT:
break
if events.type == pygame.KEYDOWN:
if events.key == K_DOWN:
imagerect.move_ip( 0, 10 ); imageload = images_dict[1]
if events.key == K_UP:
imagerect.move_ip( 0, -10 ); imageload = images_dict[1]
if events.key == K_RIGHT:
imagerect.move_ip( 10, 0 ); imageload = images_dict[1]
if events.key == K_LEFT:
imagerect.move_ip( -10, 0 ); imageload = images_dict[1]
windows.fill(( 25, 110, 189 ))
windows.blit( imageload, imagerect )
windows.blit( imageloads, imagerects )
pygame.display.flip( )
print "Image One Rect: %s \n" % imagerect
print "Image Two Rect: %s \n" % imagerects
fonts = pygame.font.Font(None, 26)
_colors_ = { "black" : (0, 0, 0),
"red" : (255, 0, 0)
}
_text_ = fonts.render('Testing', 0, _colors_['red'] )
_rtext_ = screensize[0] - _text_.get_width( ), 0
while True:
events = pygame.event.wait( )
if events.type == pygame.QUIT:
break
windows.blit( _text_, _rtext_ )
pygame.display.flip( )
pygame.quit( )
thanks..
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060723/5e3ab927/attachment.html
More information about the Tutor
mailing list