📜 ⬆️ ⬇️

PyGame. Introduction

PyGame. Introduction


I had a chance to somehow communicate with this library , which I would like to share with you, and leave myself a job, so as not to forget :) In this small, I hope, post, I am using a good example, omitting some outlined in the documentation ), show the basic principles of working with the library.



Task.

Create a "game" space in which, using the arrow keys, you can move the object.
')

Theory.

Before laying out the listings, I will focus on the methods used from the library modules, the description of which is taken from the office. documentation.

Image module
1. pygame.image.load (filename): return Surface
As you can guess, the function loads a certain image, and returns it as a surface, a type with which you can perform any operations using the pygame functions (transform, drag, delete, etc.)

Surface module
2. Surface.blit (source, dest, area = None, special_flags = 0)
Draws a given surface (source) on top of the base (Surface), where dest is a tuple (x, y), coordinates of the drawing, area - (width, height) - the dimensions of the source surface. At the expense of flags, to be honest, I did not understand it yet))
3. Surface.get_rect ()
Returns a tuple of the form (x, y, width, height), where x, y are the coordinates of the upper left corner of the surface (Surface), width, height are its dimensions, respectively.

Event module
It allows you to interact with events and requests. In other words, any event in pygame, pressing a key for example, is placed in a list consisting of Event objects. All these "event objects" have a type that can be accessed by Event.type.
4. pygame.event.get ()
The get () method allows you to get a list of events.

Module rect
A module for working with rect tuples.
5. Rect.move (X, Y)
Returns a new rect in which the coordinates are shifted, relative to the source, by the given X, Y, which can be a positive or negative integer.

Practice.

Using the above, we get:
  1. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  2. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  3. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  4. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  5. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  6. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  7. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  8. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  9. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  10. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  11. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  12. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  13. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  14. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  15. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  16. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  17. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  18. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  19. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  20. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  21. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  22. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  23. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  24. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  25. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  26. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  27. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  28. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  29. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  30. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  31. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  32. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  33. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  34. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  35. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  36. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  37. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  38. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  39. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  40. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  41. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  42. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  43. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  44. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  45. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  46. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  47. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  48. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  49. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  50. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  51. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  52. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  53. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  54. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  55. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  56. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  57. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )
  58. # -*- coding: cp1251 -*-
    # pygame.

    from pygame import *
    import sys
    # .
    init ( )

    # 640480
    screen = display. set_mode ( ( 640 , 480 ) )

    #
    display. set_caption ( 'example' )

    # , :
    # jpg, png, gif( ), bmp, pcx, tga( ), tif.
    background = image. load ( 'background.bmp' )

    #
    screen. blit ( background, ( 0 , 0 ) )

    #
    class GameObj:
    def __init__ ( self , img, x, y, step ) :
    self . img = img #
    self . x = x # x, y -
    self . y = y
    self . step = step # ,
    self . pos = img. get_rect ( ) . move ( x, y )
    def _move ( self , event ) :
    if event. key == K_UP: #273
    self . pos = self . pos . move ( 0 , - self . step )
    if event. key == K_DOWN:
    self . pos = self . pos . move ( 0 , self . step )
    if event. key == 276 :
    self . pos = self . pos . move ( - self . step , 0 )
    if event. key == 275 :
    self . pos = self . pos . move ( self . step , 0 )

    avatar = image. load ( 'player.bmp' )

    #
    x = GameObj ( avatar, 320 , 220 , 10 )

    # ,
    screen. blit ( x. img , x. pos )

    # , :)
    while 1 :
    for i in event. get ( ) : #
    if i. type == QUIT: #
    sys . exit ( )
    if i. type == KEYDOWN:
    screen. blit ( background, x. pos , x. pos )
    x._move ( i )
    screen. blit ( x. img , x. pos )
    # ,
    display. flip ( )


Afterword.


Actually, that's all, short and angry :) Having looked through the huge call-in games laid out at the office. the site, and finding real 3D crafts there - was surprised and rejoiced at the same time)) Although I am not going to conquer igrodelcheskie peaks, but it's nice that my favorite language is so multidimensional. If this topic is interesting to someone, and I don’t lose the desire to record, then there will certainly be a continuation).

Source: https://habr.com/ru/post/56255/


All Articles