
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0  Or InitSprite3D() = 0
  MessageRequester("Error", "Can't open the sprite system", 0)
  End
EndIf
  UsePNGImageDecoder()
  

  If OpenWindow(0, 0, 0, 500, 500, "Gadget and sprites!", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  ButtonGadget(1, 10,  10, 100, 25, "F9-Загрузить")
  ButtonGadget(2, 120,  10, 100, 25, "F8-Сохранить")
  ButtonGadget(3, 230,  10, 100, 25, "Рисовать")
  ButtonGadget(4, 340,  10, 100, 25, "Выход")
  ;
  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the EventID
  ; isn't 0 and we just have to see what have happened...
  ;
   OpenWindowedScreen(WindowID(0), 10, 70, 1024, 768, 1, 0, 0)
  
  
  


  
  
  LoadSprite (1, "gfx/str.png" )
  LoadSprite (2, "gfx/rama.png" )
LoadSprite (3, "fon/1.png" )


;-----------------------------------непроходимые
LoadSprite (9, "sprite/1.png" )
LoadSprite (10, "sprite/1.png" )
LoadSprite (11, "sprite/2.png" )
LoadSprite (12, "sprite/3.png" )
LoadSprite (13, "sprite/4.png" )
LoadSprite (14, "sprite/5.png" )
LoadSprite (15, "sprite/6.png" )
LoadSprite (16, "sprite/7.png" )
LoadSprite (17, "sprite/8.png" )
LoadSprite (18, "sprite/9.png" )
LoadSprite (19, "sprite/10.png" )
LoadSprite (20, "sprite/53.png" )
LoadSprite (21, "sprite/11.png" )
LoadSprite (22, "sprite/12.png" )
LoadSprite (23, "sprite/13.png" )
LoadSprite (24, "sprite/14.png" )
LoadSprite (25, "sprite/15.bmp" )
LoadSprite (26, "sprite/16.bmp" )
LoadSprite (27, "sprite/chest_0000.png" )
LoadSprite (28, "sprite/chest_0001.png" )
LoadSprite (29, "sprite/duplo.png" )
LoadSprite (30, "sprite/77.png" )
LoadSprite (31, "sprite/8b.png" )
LoadSprite (32, "sprite/8bb.png" )
LoadSprite (33, "sprite/107.png" )
LoadSprite (34, "sprite/108.png" )
LoadSprite (35, "sprite/109.png" )
LoadSprite (36, "sprite/110.png" )
LoadSprite (37, "sprite/111.png" )
LoadSprite (38, "sprite/112.png" )
LoadSprite (39, "sprite/113.png" )
LoadSprite (40, "sprite/114.png" )
LoadSprite (41, "sprite/115.png" )
LoadSprite (42, "sprite/116.png" )
LoadSprite (43, "sprite/117.png" )
;-----------------------------------проходимые

LoadSprite (50, "sprite/50.png" )
LoadSprite (51, "sprite/51.png" )
LoadSprite (52, "sprite/52.png" )
LoadSprite (53, "sprite/53.png" )
LoadSprite (54, "sprite/54.png" )
LoadSprite (55, "sprite/55.png" )
LoadSprite (56, "sprite/56.png" )
LoadSprite (57, "sprite/57.png" )
LoadSprite (58, "sprite/top_lamp_0000.png" )
LoadSprite (59, "sprite/top_lamp_0001.png" )
LoadSprite (60, "sprite/top_lamp_0002.png" )
LoadSprite (61, "sprite/top_lamp_0003.png" )
LoadSprite (62, "sprite/top_lamp_0004.png" )
LoadSprite (63, "sprite/top_lamp_0005.png" )
LoadSprite (64, "sprite/top_lamp_0006.png" )
LoadSprite (65, "sprite/top_lamp_0007.png" )
LoadSprite (66, "sprite/top_lamp_0008.png" )
LoadSprite (67, "sprite/gem_0000.png" )
LoadSprite (68, "sprite/gem_0001.png" )
LoadSprite (69, "sprite/gem_0002.png" )
LoadSprite (70, "sprite/gem_0003.png" )
LoadSprite (71, "sprite/gem_0004.png" )
LoadSprite (72, "sprite/gem_0005.png" )
LoadSprite (73, "sprite/gem_0006.png" )
LoadSprite (74, "sprite/gem_0007.png" )
LoadSprite (75, "sprite/gem_0008.png" )
LoadSprite (76, "sprite/gem_0009.png" )
LoadSprite (77, "sprite/water3_0000.png" )
LoadSprite (78, "sprite/water3_0001.png" )
LoadSprite (79, "sprite/water3_0002.png" )
LoadSprite (80, "sprite/water3_0003.png" )
LoadSprite (81, "sprite/water3_0004.png" )
LoadSprite (82, "sprite/water3_0005.png" )
LoadSprite (83, "sprite/water3_0006.png" )

LoadSprite (84, "sprite/fence_0010.png" )
LoadSprite (85, "sprite/fence_0011.png" )
LoadSprite (86, "sprite/fence_0012.png" )
LoadSprite (87, "sprite/fence_0013.png" )
LoadSprite (88, "sprite/fence_0014.png" )
LoadSprite (89, "sprite/fence_0015.png" )
LoadSprite (90, "sprite/fence_0016.png" )
LoadSprite (91, "sprite/fence_0017.png" )
LoadSprite (92, "sprite/barrell0000.png" )
LoadSprite (93, "sprite/barrell0001.png" )
LoadSprite (94, "sprite/barrell0002.png" )
LoadSprite (95, "sprite/barrell0001.png" )



CreateSprite(96, 48, 1,0)

  ;-----------------------------------Передний план

LoadSprite (100, "sprite/fence_0000.png" )
LoadSprite (101, "sprite/fence_0001.png" )
LoadSprite (102, "sprite/fence_0002.png" )
LoadSprite (103, "sprite/fence_0003.png" )
LoadSprite (104, "sprite/fence_0004.png" )
LoadSprite (105, "sprite/fence_0005.png" )
LoadSprite (106, "sprite/fence_0006.png" )
LoadSprite (107, "sprite/fence_0007.png" )

;-----------------------------------задний план
LoadSprite (119, "fon/fon1.png" )
LoadSprite (120, "sprite/104.png" )
LoadSprite (121, "sprite/105.png" )
LoadSprite (122, "sprite/106.png" )
LoadSprite (123, "sprite/65.png" )
LoadSprite (124, "sprite/66.png" )
LoadSprite (125, "sprite/67.png" )
LoadSprite (126, "sprite/68.png" )
LoadSprite (127, "sprite/69.png" )
LoadSprite (128, "sprite/70.png" )
LoadSprite (129, "sprite/71.png" )
LoadSprite (130, "sprite/72.png" )
LoadSprite (131, "sprite/73.png" )
LoadSprite (132, "sprite/74.png" )
LoadSprite (133, "sprite/75.png" )
LoadSprite (134, "sprite/76.png" )
LoadSprite (135, "sprite/103.png" )
LoadSprite (136, "sprite/200.png" )
LoadSprite (137, "sprite/201.png" )
LoadSprite (138, "sprite/202.png" )

LoadSprite (200, "sprite/58.png" )
LoadSprite (201, "sprite/59.png" )
LoadSprite (202, "sprite/60.png" )
LoadSprite (203, "sprite/61.png" )
LoadSprite (204, "sprite/62.png" )

LoadSprite (220, "sprite/78.png" );   предметы 
LoadSprite (221, "sprite/79.png" )

LoadSprite (250, "sprite/100.png" )
LoadSprite (251, "sprite/101.png" )
LoadSprite (252, "sprite/102.png" )


LoadSprite (280, "fon/1.png" )
LoadSprite (281, "sprite/63.png" )
LoadSprite (282, "sprite/64.png" )
LoadSprite (283, "fon/fon1a.png" )


LoadSprite (300, "sprite/z1.png",#PB_Sprite_Texture )
LoadSprite (301, "sprite/z2.png",#PB_Sprite_Texture )
LoadSprite (302, "sprite/z3.png",#PB_Sprite_Texture )
LoadSprite (303, "sprite/z4.png",#PB_Sprite_Texture )
LoadSprite (304, "sprite/z5.png",#PB_Sprite_Texture )
LoadSprite (305, "sprite/z6.png",#PB_Sprite_Texture )
LoadSprite (306, "sprite/z7.png",#PB_Sprite_Texture )
LoadSprite (307, "sprite/z8.png",#PB_Sprite_Texture )
LoadSprite (308, "sprite/z7.png",#PB_Sprite_Texture )
LoadSprite (309, "sprite/z6.png",#PB_Sprite_Texture )
LoadSprite (310, "sprite/z5.png",#PB_Sprite_Texture )
LoadSprite (311, "sprite/z4.png",#PB_Sprite_Texture )
LoadSprite (312, "sprite/z3.png",#PB_Sprite_Texture )
LoadSprite (313, "sprite/z2.png",#PB_Sprite_Texture )


CreateSprite3D(1, 300)
CreateSprite3D(2, 301)
CreateSprite3D(3, 302)
CreateSprite3D(4, 303)
CreateSprite3D(5, 304)
CreateSprite3D(6, 305)
CreateSprite3D(7, 306)
CreateSprite3D(8, 307)
CreateSprite3D(9, 308)
CreateSprite3D(10, 309)
CreateSprite3D(11, 310)
CreateSprite3D(12, 311)
CreateSprite3D(13, 312)
CreateSprite3D(14, 313)




exitm=1

xm=0:ym=0; x y mouse
razmer=96; razmer lokacii
xyraz=32
fon=0; ------какой фон
c=0:d=0
obx=10
chet=0
obx2=0
tele=0
Structure Person
    x.w
    y.w
    nom.w
    swo.w
  EndStructure

  NewList tur.Person ()
  
  
  Structure Person2
    x.w
    y.w
    xx.w
    yy.w
    nom.w
    ani.w
        tim.w
           tim2.w
           pow.w
  EndStructure

  NewList tur2.Person2 ()
  
  
okno=1


Gosub load:

Gosub instal:



   
ClearScreen (RGB(0, 132, 255))


Gosub print2



Gosub print

Gosub print3
If okno=1:Gosub okno:EndIf 

Gosub mouse


FlipBuffers()


  Repeat
  

  
   Event = WaitWindowEvent()
  
  
    Select EventGadget()
Case 1
If EventType() =  #PB_EventType_LeftClick 
  If  OpenWindow(1, 0, 0, 400, 200, "Сохранить файл", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ExplorerListGadget(0, 10, 10, 380, 180, "C:\Documents and Settings\Администратор\Рабочий стол\снусмумр2\Tur", #PB_Explorer_AlwaysShowSelection )
 Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf 

EndIf 


          Case 4
End 
          Case 3
 If EventType() =  #PB_EventType_LeftClick :  exitm=0: EndIf





EndSelect
  
    If Event = #PB_Event_CloseWindow  ; If the user has pressed on the close button
      Quit = 1
    EndIf

 


Gosub print2

Gosub print
Gosub print3
If okno=1:Gosub okno:EndIf 

Gosub mouse



FlipBuffers()
ClearScreen (RGB(0, 132, 255))




If exitm=0:ReleaseMouse(0):DisableGadget(3, 1):EndIf 
If exitm=1:ReleaseMouse(1):DisableGadget(3, 0):EndIf 

   Until Quit = 1
  
  

    
EndIf

End 




print:

ResetList( tur() ) 

While NextElement( tur())
If tur()\nom=77:DisplayTransparentSprite( tur()\nom+anim4 , tur()\x + c, tur()\y + d):Goto su:EndIf 
If tur()\nom=92:DisplayTransparentSprite( tur()\nom+anim5 , tur()\x + c, tur()\y + d):Goto su:EndIf 
If tur()\nom=25:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+8):Goto su:EndIf 
If tur()\nom=26:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+28):Goto su:EndIf 
If tur()\nom=29:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+28):Goto su:EndIf 

If tur()\nom=27:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=28:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=100:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=101:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=102:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=103:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=104:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=105:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=106:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=107:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto su:EndIf 
If tur()\nom=250:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=251:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=252:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 

If tur()\nom=21:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+1):Goto su:EndIf 
If tur()\nom=22:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+1):Goto su:EndIf 
If tur()\nom=23:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+1):Goto su:EndIf 
If tur()\nom=24:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+1):Goto su:EndIf 
If tur()\nom=67:DisplayTransparentSprite( tur()\nom+anim3 , tur()\x + c, tur()\y + d):Goto su:EndIf 
If tur()\nom=58:DisplayTransparentSprite( tur()\nom+anim , tur()\x + c, tur()\y + d):Goto su:EndIf 
 If tur()\nom=19:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+16):Goto su:EndIf 
  If tur()\nom=14:DisplayTransparentSprite( tur()\nom , tur()\x + c+25, tur()\y + d):Goto su:EndIf 
  If tur()\nom=52:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d-30):Goto su:EndIf 
     If tur()\nom=120:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+30):Goto su:EndIf 
          If tur()\nom=122:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+2):Goto su:EndIf 
  If tur()\nom=53 Or tur()\nom=54:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+3):Goto su:EndIf 
  If tur()\nom<=100:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
  If tur()\nom=>280 And tur()\nom<300:Goto su:EndIf 
    If tur()\nom=>120:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
  su:
Wend

Return 

print2:

ResetList( tur() ) 

While NextElement( tur())

  ;If tur()\nom=>110 And tur()\nom<123:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
   ; If tur()\nom=>280 And tur()\nom<300:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
      If tur()\nom=>110 And tur()\nom<120:DisplayTransparentSprite( tur()\nom , tur()\x + c/4, tur()\y + d):EndIf 
    If tur()\nom=>280 And tur()\nom<300:DisplayTransparentSprite( tur()\nom , tur()\x + c/2, tur()\y + d):EndIf 
Wend

Return 













escc:

exitm=1:
Return 


mouse:

ExamineKeyboard()

If KeyboardPushed(#PB_Key_F1):Goto f1:EndIf 
If KeyboardPushed(#PB_Key_Escape):Goto escc:EndIf 
If KeyboardPushed(#PB_Key_Left) And korx>-200:korx-1:c+16:xf+4:xff+2:xfff+5:EndIf  
If KeyboardPushed(#PB_Key_Right) And korx<razmer:korx+1:c-16:xf-4:xff-2:xfff-5:EndIf  
If KeyboardPushed(#PB_Key_Up) And kory>0-50:kory-1:d+16:yf+4:EndIf 
If KeyboardPushed(#PB_Key_Down) And kory<razmer+20:kory+1:d-16:yf-4:EndIf 
If KeyboardPushed(#PB_Key_W):Goto w1:EndIf 
If KeyboardPushed(#PB_Key_S):Goto s1:EndIf 
If KeyboardPushed(#PB_Key_Z):Goto z1:EndIf 
If KeyboardPushed(#PB_Key_F8):Goto save:EndIf 
If KeyboardPushed(#PB_Key_F9):Goto load:EndIf 

ExamineMouse() 
 
 xm = MouseX()                         
 ym = MouseY() 
 
If okno=1 And xm>730:Goto oknono:EndIf 

xm-c:ym-d
If obx=>33 And obx<50:
xm/2:xm*2
ym/2:ym*2
Goto ifif 
EndIf 
xm/48:xm*48
ym/48:ym*48
ifif:
xm3=xm
ym3=ym
DisplayTransparentSprite(obx, xm3+c, ym3+d)

 xm = MouseX()                         
 ym = MouseY() 

DisplayTransparentSprite(1, xm, ym)
anim2+1
anim22+1
If anim2=4:
anim+1
anim3+1
anim4+1
If anim=9:anim=0:EndIf 
If anim4=7:anim4=0:EndIf
If anim3=10:anim3=0:EndIf 
anim2=0
EndIf 
If anim22=10:
anim5+1
If anim5=3:anim5=0:EndIf 
anim22=0
EndIf 


ExamineMouse() 

If MouseButton(1) 

 xm = MouseX()                         
 ym = MouseY()  
 
 xm-c:ym-d
;-------------------------------------
obx2=obx
 Gosub prow
 If pro=0
   ExamineMouse() 
   xm = MouseX()                         
   ym = MouseY() 
   xm-c:ym-d
 If obx=>33 And obx<50:
xm/2:xm*2
ym/2:ym*2
Goto ifif2 
EndIf 
   xm/48:xm*48
   ym/48:ym*48
   ifif2:
 Gosub sraw
  AddElement( tur() )
  tur()\x = xm-sdy
  tur()\y = ym-sdx
  tur()\nom = obx
  If obx=30:
  tur()\swo=tele
  
Debug tele 
  tele+1
  EndIf  
  obx=obx2
  
EndIf 

EndIf 

If MouseButton(2) 
xm-c:ym-d
xm/48:xm*48
ym/48:ym*48
Goto mou
EndIf 

Return  
mou:
 ExamineMouse() 
If MouseButton(2) :Goto mou:EndIf 
ResetList( tur() ) 
While NextElement( tur())
 If SpriteCollision(obx, xm3, ym3, tur()\nom, tur()\x, tur()\y): DeleteElement( tur() ):Return:EndIf   
Wend
Return 


sraw:
Return 





prow:

pro=0
Goto prow3a:

If obx=>110:Goto prow3:EndIf 
If obx=>50:Goto prow3a:EndIf 
ResetList( tur() ) 

While NextElement( tur())
If obx<110 And SpriteCollision(obx, xm3, ym3, tur()\nom, tur()\x, tur()\y):pro=1:EndIf 
Wend
Return 
prow3:
ResetList( tur() ) 

While NextElement( tur())
If tur()\nom>10 And SpriteCollision(obx, xm3, ym3, tur()\nom, tur()\x, tur()\y):pro=1:EndIf 
Wend
Return 


prow3a:
 ExamineMouse() 
If obx=>110 And MouseButton(1) :Goto prow3a:EndIf 
If obx=>21 And obx<25 And MouseButton(1) :Goto prow3a:EndIf 
If obx=>110 And obx<120:Return:EndIf 
If obx=>280 And obx<300:Return:EndIf 
If obx=>21 And obx<25:Return:EndIf 
ResetList( tur() ) 

While NextElement( tur())
If tur()\nom=obx And SpriteCollision(obx, xm3, ym3, tur()\nom, tur()\x, tur()\y):pro=1:EndIf 

Wend
Return 








z1:
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Z):Goto z1:EndIf 
If KeyboardPushed(#PB_Key_LeftControl):DeleteElement( tur() ):EndIf 
Return 
















 oknono:
 If okno=1:
 xmz= MouseX()                        
 ymz = MouseY() 
 DisplayTransparentSprite(1, xm, ym)
 
 xmz/48
ymz/48
  If MouseButton(1) 
  If xmz=16 And ymz=0:obx=10:EndIf 
    If xmz=17 And ymz=0:obx=51:EndIf 
    If xmz=18 And ymz=0:obx=50:EndIf 
    If xmz=19 And ymz=0:obx=52:EndIf 
       If xmz=16 And ymz=1:obx=53:EndIf 
            If xmz=17 And ymz=1:obx=58:EndIf 
             If xmz=18 And ymz=1:obx=67:EndIf 
                      If xmz=19 And ymz=1:obx=21:EndIf 
                      If xmz=16 And ymz=2:obx=100:EndIf 
                         If xmz=17 And ymz=2:obx=84:EndIf 
                          If xmz=18 And ymz=2:obx=120:EndIf 
                             If xmz=16 And ymz=3:obx=92:EndIf 
                               If xmz=16 And ymz=4:obx=200:EndIf 
                                 If xmz=17 And ymz=4:obx=220:EndIf 
                                   If xmz=18 And ymz=4:obx=250:EndIf 
                                   If xmz=19 And ymz=4:obx=9:EndIf 
                                    If xmz=17 And ymz=5:obx=33:EndIf 
           If xmz=16 And ymz=5:obx=280:EndIf 
           
  EndIf 
EndIf 
Return 








w1:
ExamineKeyboard()
If obx=43:obx=49:EndIf 
If KeyboardPushed(#PB_Key_W):Goto w1:EndIf 
obx+1
Return 
s1:
If obx=50:obx=33:EndIf 
ExamineKeyboard()
If KeyboardPushed(#PB_Key_S):Goto s1:EndIf 
If obx>10:obx-1:EndIf 
Return 
 











text:
  StartDrawing( ScreenOutput() )
      DrawingMode(1)
      
      
  
   DrawText(xp, yp, a$, RGB((0),(0),(0)) )

      
   StopDrawing()


Return 


f1:
ExamineKeyboard()
If KeyboardPushed(#PB_Key_F1):Goto f1:EndIf 
If okno=1:okno=0:Return:EndIf 
If okno=0:okno=1:Return:EndIf 
Return 



okno:
 xmm = MouseX()                         
 ymm = MouseY() 
 xmm+48
 xmm/48:xmm*48
ymm/48:ymm*48
  StartDrawing( ScreenOutput() )
      DrawingMode(1)
      Box(800-70,0,256+8,1024+8,RGB((200),(200),(200)))


  If xmm>730 :Box(xmm-48,ymm+16,48,48,RGB((255),(0),(255))):EndIf 

   StopDrawing()
   
   
  DisplayTransparentSprite(10, 768, 16)
  DisplayTransparentSprite(51, 768+48, 16)
  DisplayTransparentSprite(50, 768+48+48, 16)
  DisplayTransparentSprite(52, 768+96+48, 16)
   DisplayTransparentSprite(53, 768, 16+48)
     DisplayTransparentSprite(58, 768+48, 16+48)
          DisplayTransparentSprite(67, 768+48+48, 16+48)
           DisplayTransparentSprite(21, 768+48+48+48, 16+48)
             DisplayTransparentSprite(100, 768, 16+48+48)
                 DisplayTransparentSprite(84, 768+48, 16+48+48)
                  DisplayTransparentSprite(120, 768+48+48, 16+48+48)
                    DisplayTransparentSprite(92, 768, 16+48+48+48)
            
                       DisplayTransparentSprite(200, 768, 16+48+48+48+48)
                       DisplayTransparentSprite(220, 768+48, 16+48+48+48+48)
                        DisplayTransparentSprite(250, 768+48+48, 16+48+48+48+48)
                         DisplayTransparentSprite(9, 768+48+48+48, 16+48+48+48+48)
                          DisplayTransparentSprite(280, 768, 16+48+48+48+48+48)
                             DisplayTransparentSprite(33, 768+48, 16+48+48+48+48+48)
   
   xp=730:yp=550
a$="Hомер обьекта -"
Gosub text
xp=730:yp=560
a$=Str(obx)
Gosub text
Return 







instal:

ResetList( tur() ) 
While NextElement( tur())
If tur()\nom=30:tele+1:Gosub instal2:EndIf 
Wend
Return 

instal2:




xx=tur()\x
yy=tur()\y

aas=32
Repeat 


  AddElement( tur2() )
  tur2()\x = tur()\x+Random(48)-8
  tur2()\y = tur()\y+16
  tur2()\xx = tur()\x-8
  tur2()\yy = tur()\y+16
  tur2()\nom = 1
  tur2()\ani = 16+Random(128)
  
  tur2()\tim = 0+Random(8)
    tur2()\tim2= tur2()\tim
    tur2()\pow = Random(3)
      If aas>0:aas-1:EndIf 
    Until aas=0
Return 




print3:

Start3D()

ResetList( tur2() ) 

While NextElement( tur2())

  If tur2()\nom>0:
  :DisplaySprite3D( tur2()\nom , tur2()\x + c, tur2()\y + d, tur2()\ani):EndIf 
  
  If tur2()\pow=1 And tur2()\tim/2=0: tur2()\x-1:EndIf
    If tur2()\pow=2 And tur2()\tim/2=0: tur2()\x+1:EndIf
  
If tur2()\tim>0: tur2()\tim-1:EndIf
If tur2()\tim=0: tur2()\tim=tur2()\tim2:tur2()\nom+1:EndIf
If tur2()\nom=14:tur2()\nom=1:EndIf 

  If tur2()\ani>0:tur2()\ani-1:tur2()\y-1:EndIf
     If tur2()\ani=0:xx=tur2()\xx:yy=tur2()\yy:DeleteElement( tur2() ): Gosub soz:EndIf 
Wend

Stop3D()

Return 


soz:



  AddElement( tur2() )
  tur2()\xx = xx
  tur2()\yy = yy
  tur2()\x = xx+Random(48)
  tur2()\y = yy
  tur2()\nom = 1
  tur2()\ani = 16+Random(128)
  tur2()\tim = 0+Random(8)
    tur2()\tim2= tur2()\tim
    tur2()\pow = Random(3)
  
Return 










save:
CreateFile(0,"Tur/1.txt")
ResetList( tur() ) 
While NextElement( tur())
WriteLong(0,tur()\nom)
WriteLong(0,tur()\x)
WriteLong(0,tur()\y)
WriteLong(0,tur()\swo)
Wend
WriteLong(0,xyraz)
WriteLong(0,fon)
CloseFile(0) 

CreateFile(0,"Tur/1copy.txt")
ResetList( tur() ) 
While NextElement( tur())
WriteLong(0,tur()\nom)
WriteLong(0,tur()\x)
WriteLong(0,tur()\y)
WriteLong(0,tur()\swo)
Wend
WriteLong(0,xyraz)
WriteLong(0,fon)
CloseFile(0) 
Return


load:

ResetList( tur() ) 
While NextElement( tur())
DeleteElement( tur() )
Wend
OpenFile(0,"Tur/1.txt")
Length = Lof(0)
Length-8
ResetList( tur() ) 
Repeat
 AddElement( tur() )
tur()\nom=ReadLong(0)
tur()\x=ReadLong(0)
tur()\y=ReadLong(0)
tur()\swo=ReadLong(0)
Length-16

Until Length=0
xyraz=ReadLong(0)
fon=ReadLong(0)
 CloseFile(0)

Return

; IDE Options = PureBasic 4.30 (Windows - x86)
; CursorPosition = 506
; FirstLine = 489
; Folding = -
; EnableXP