PyGame。 はじめに

PyGame。 はじめに



私はこのライブラリと話をする機会がありましたが、あなたと共有したいので、忘れないように自分自身のためにノッチを残してください:)この短い、私は良い例を使用して、最も理論的な基礎のいくつかを省略しますドキュメントで説明されています )、ライブラリを操作する基本的な原理を示します。







チャレンジ。

矢印キーを使用してオブジェクトを移動できる「ゲーム」スペースを作成します。



理論

リストを投稿する前に、ライブラリモジュールで使用されているメソッドに焦点を当てます。ライブラリモジュールの説明はオフィスから取得されます。 ドキュメント。



画像モジュール

1. pygame.image.load(ファイル名):Surfaceを返す

ご想像のとおり、この関数は特定の画像をロードし、表面の形で返します。これはすでにpygame関数でいくつかの操作(変換、移動、削除など)を実行できるタイプです。



表面モジュール

2. Surface.blit(source、dest、area = None、special_flags = 0)

指定されたサーフェス(ソース)をベース(サーフェス)の上に描画します。ここで、destはタプル(x、y)、レンダリングの座標、面積-(幅、高さ)はソースサーフェスのサイズです。 フラグを犠牲にして、正直に言うと、私はまだ理解していませんでした))

3. Surface.get_rect()

フォームのタプル(x、y、幅、高さ)を返します。ここで、x、yはそれぞれ表面(表面)の左上隅の座標、幅、高さはその次元です。



イベントモジュール

イベントやリクエストとやり取りすることができます。 つまり、pygameのイベント、たとえばキーストロークは、Eventオブジェクトで構成されるリストに配置されます。 これらすべての「イベントオブジェクト」は、Event.typeを介してアクセスできるタイプです。

4. pygame.event.get()

get()メソッドを使用すると、イベントのリストを取得できます。



長方形モジュール

長方形のタプルを操作するためのモジュール。

5. Rect.move(X、Y)

正の整数または負の整数を指定したX、Yだけ、元の座標に対して座標がオフセットされた新しい四角形を返します。



練習。

上記を考慮して、以下を取得します。

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








あとがき。



実際、それはすべて、簡潔かつ怒ってです:)オフィスでレイアウトされた膨大な数のゲームを調べました。 サイト、そしてそこに本物の3Dクラフトを発見しました-同時に驚き、喜びました))ゲームのピークを征服するつもりはありませんが、私の好きな言語が多次元であることは素晴らしいことです。 誰かがこのトピックに興味があり、記録する意欲を失わないなら、確かに継続があります)。



All Articles