
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, "Выдры.", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  ButtonGadget(1, 10,  10, 100, 25, "Настройки")
  ButtonGadget(2, 120,  10, 100, 25, "Чат")
  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...
  ;
  xraz=600
  yraz=486
  ;xraz=800
  ;yraz=600
  ;xraz=1024
  ;yraz=768
   OpenWindowedScreen(WindowID(0), 10, 70, xraz, yraz, 1, 0, 0)
   
  

  


  
  
  LoadSprite (1, "gfx/str.png" )
  LoadSprite (2, "gfx/rama.png" )
LoadSprite (3, "fon/1.png" )
LoadSprite (4, "fon/2.png" )
LoadSprite (5, "fon/3.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 (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" )
  ;-----------------------------------Передний план
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 (120, "fon/1.png" )
LoadSprite (121, "sprite/63.png" )
LoadSprite (122, "sprite/64.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 (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 (253, "sprite/101.png" )
LoadSprite (254, "sprite/102.png" )
LoadSprite (255, "sprite/101.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 )



LoadSprite (500, "harak/vudra_walk_0000.png",#PB_Sprite_Texture )
LoadSprite (501, "harak/vudra_walk_0001.png",#PB_Sprite_Texture )
LoadSprite (502, "harak/vudra_walk_0002.png",#PB_Sprite_Texture )
LoadSprite (503, "harak/vudra_walk_0003.png",#PB_Sprite_Texture )
LoadSprite (504, "harak/vudra_walk_0004.png",#PB_Sprite_Texture )
LoadSprite (505, "harak/vudra_walk_0005.png",#PB_Sprite_Texture )
LoadSprite (506, "harak/vudra_walk_0006.png",#PB_Sprite_Texture )
LoadSprite (507, "harak/vudra_walk_0007.png",#PB_Sprite_Texture )
LoadSprite (508, "harak/2/vudra_walk_0000.png",#PB_Sprite_Texture )
LoadSprite (509, "harak/2/vudra_walk_0001.png",#PB_Sprite_Texture )
LoadSprite (510, "harak/2/vudra_walk_0002.png",#PB_Sprite_Texture )
LoadSprite (511, "harak/2/vudra_walk_0003.png",#PB_Sprite_Texture )
LoadSprite (512, "harak/2/vudra_walk_0004.png",#PB_Sprite_Texture )
LoadSprite (513, "harak/2/vudra_walk_0005.png",#PB_Sprite_Texture )
LoadSprite (514, "harak/2/vudra_walk_0006.png",#PB_Sprite_Texture )
LoadSprite (515, "harak/2/vudra_walk_0007.png",#PB_Sprite_Texture )


LoadSprite (1000, "gfx/str1.png",#PB_Sprite_Texture )
LoadSprite (1001, "gfx/str2.png",#PB_Sprite_Texture )
LoadSprite (1002, "gfx/str2.png",#PB_Sprite_Texture )
LoadSprite (1003, "gfx/str3.png",#PB_Sprite_Texture )
LoadSprite (1004, "gfx/str4.png",#PB_Sprite_Texture )
LoadSprite (1005, "gfx/str5.png",#PB_Sprite_Texture )
LoadSprite (1006, "gfx/str6.png",#PB_Sprite_Texture )
LoadSprite (1007, "gfx/str7.png",#PB_Sprite_Texture )
LoadSprite (1008, "gfx/str8.png",#PB_Sprite_Texture )
LoadSprite (1009, "gfx/menu-rus.png",#PB_Sprite_Texture )

LoadSprite (96, "sprite/0.bmp",#PB_Sprite_Texture )
LoadSprite (97, "sprite/0.bmp",#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)

CreateSprite3D(500, 500)
CreateSprite3D(501, 501)
CreateSprite3D(502, 502)
CreateSprite3D(503, 503)
CreateSprite3D(504, 504)
CreateSprite3D(505, 505)
CreateSprite3D(506, 506)
CreateSprite3D(507, 507)
CreateSprite3D(508, 508)
CreateSprite3D(509, 509)
CreateSprite3D(510, 510)
CreateSprite3D(511, 511)
CreateSprite3D(512, 512)
CreateSprite3D(513, 513)
CreateSprite3D(514, 514)
CreateSprite3D(515, 515)

CreateSprite3D(1000, 1000)
CreateSprite3D(1001, 1001)
CreateSprite3D(1002, 1002)
CreateSprite3D(1003, 1003)
CreateSprite3D(1004, 1004)
CreateSprite3D(1005, 1005)
CreateSprite3D(1006, 1006)
CreateSprite3D(1007, 1007)
CreateSprite3D(1008, 1008)
CreateSprite3D(1009, 1009)

exitm=1

xm=0:ym=0; x y mouse
If yraz=768:razmer=128-10:EndIf ; razmer lokacii
If yraz=600:razmer=129:EndIf
If yraz=486:razmer=128+10:EndIf
c=0:d=0
obx=10
chet=0
obx2=0
   xti=0
   yti=0
   
play=1

Structure Person
    x.w
    y.w
    x2.w
    y2.w
    nom.w
    swo.w
    spid.w
    iner.w
    iner2.w
    upal.w
    gravitator.w
    wani.w
    stor.w
    name$ ;    максимум 10 букв
    energ.w
    color.l
  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 ()



player=1

  
  
  
okno=0


Gosub load:
Gosub instal:

Gosub instalp
      

        






   
ClearScreen (RGB(0, 132, 255))
Gosub animacija

Gosub print2

Gosub gravitacija

Gosub print
Gosub print4
Gosub print3
If okno=1:Gosub okno:EndIf 
Gosub ikon
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






If exitm=1:Goto exi:EndIf 

 
Gosub animacija

Gosub print2

Gosub gravitacija

Gosub print
Gosub print4
Gosub print3
Gosub ikon
Gosub mouse


FlipBuffers()

ClearScreen (RGB(0, 132, 255))


 exi:

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


   Until Quit = 1
  
  

    
EndIf

End 

;-------------animstr
animacija:
If anim2>0:Return:EndIf
anistr+1
If anistr=9:anistr=0:EndIf 
Return 



print4:

ResetList( tur() ) 

While NextElement( tur())
If tur()\nom=77:DisplayTransparentSprite( tur()\nom+anim4 , tur()\x + c, tur()\y + d):Goto suu:EndIf 
If tur()\nom=100:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=101:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=102:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=103:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=104:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=105:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=106:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
If tur()\nom=107:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+12):Goto suu:EndIf 
suu:
Wend

Return 


print:

ResetList( tur() ) 

While NextElement( tur())
If tur()\nom=500:Gosub wydra:Goto su:EndIf 
;If tur()\nom=97 Or tur()\nom=96:Goto su:EndIf 
If tur()\nom=77: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=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=253:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=254:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=255: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+4):Goto su:EndIf 
If tur()\nom=22:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=23:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):Goto su:EndIf 
If tur()\nom=24:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d+4):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=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=>123:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
  su:
  If tur()\nom=251 And tur()\swo=0:tur()\nom=252:tur()\swo=3:EndIf 
  If tur()\nom=251 And  tur()\swo>0:tur()\swo-1:EndIf 
  
  If tur()\nom=252 And tur()\swo=0:tur()\nom=253:tur()\swo=3:EndIf 
  If tur()\nom=252 And  tur()\swo>0:tur()\swo-1:EndIf 
  
  If tur()\nom=253 And tur()\swo=0:tur()\nom=254:tur()\swo=1:EndIf 
  If tur()\nom=253 And  tur()\swo>0:tur()\swo-1:EndIf
  
  If tur()\nom=254 And tur()\swo=0:tur()\nom=255:tur()\swo=1:EndIf 
  If tur()\nom=254 And  tur()\swo>0:tur()\swo-1:EndIf
  
  If tur()\nom=255 And tur()\swo=0:tur()\nom=250:tur()\swo=1:EndIf 
  If tur()\nom=255 And  tur()\swo>0:tur()\swo-1:EndIf
Wend

Return 

print2:

ResetList( tur() ) 

While NextElement( tur())

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

Return 













escc:

exitm=1:
Return 
a111:
ExamineKeyboard()
If KeyboardPushed(#PB_Key_1):
Goto a111:EndIf 
ResetList( tur() ) 

 While NextElement( tur())
If tur()\nom=97 And tur()\iner=0 And tur()\swo=play:
tur()\iner2=32
tur()\x2=tur()\x
:EndIf 
Wend
Return 

a222:

ResetList( tur() ) 
 While NextElement( tur())
If tur()\nom=97 And tur()\gravitator=0 And tur()\swo=play:
tur()\gravitator=70:
EndIf 

Wend
Return 

mouse:

ExamineKeyboard()


If KeyboardPushed(#PB_Key_Escape):Goto escc:EndIf 
If KeyboardPushed(#PB_Key_Left) And c<96:c+16::push=1:EndIf  
If KeyboardPushed(#PB_Key_Right) And c>-2300:c-16::push=1:EndIf  
If KeyboardPushed(#PB_Key_Up) And d<0:d+16::push=1:EndIf 
If KeyboardPushed(#PB_Key_Down) And d>-2200:d-16:push=1:EndIf 

If push=1:Goto susu:EndIf 
If xti>c And c<96:c+spid2:EndIf  
If xti<c And c>-2300:c-spid2:EndIf  
If yti>d And d<0:d+spid:EndIf 
If yti<d And d>-2200:d-spid:EndIf 

susu:
If KeyboardPushed(#PB_Key_Space):Gosub a222:space=1:EndIf 
If KeyboardPushed(#PB_Key_1):
Goto a111

:EndIf





ExamineMouse() 
 
 xm = MouseX()                         
 ym = MouseY() 
 


xm-c:ym-d
xm/48:xm*48
ym/48:ym*48
xm3=xm
ym3=ym






 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 
;--------------------------mouse

ExamineMouse() 
xm-c:ym-d
If MouseButton(1) 
ResetList( tur() ) 

 While NextElement( tur())
If tur()\nom=97 And tur()\swo=play:
xm/tur()\spid:xm*tur()\spid
xm33=xm
tur()\x2=xm33:
Return:EndIf 
Wend
  

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=>120 And MouseButton(1) :Goto prow3a:EndIf 
If obx=>120 And obx<123: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 

























 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 
           
           
  EndIf 
EndIf 
Return 








w1:
ExamineKeyboard()
If obx=30:obx=49:EndIf 
If KeyboardPushed(#PB_Key_W):Goto w1:EndIf 
obx+1
Return 
s1:
If obx=50:obx=31: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)
   
   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:Gosub instal2:EndIf 

If tur()\nom=10 Or tur()\nom=11 Or tur()\nom=19 Or tur()\nom=12 Or tur()\nom=17 Or tur()\nom=13  Or tur()\nom=16  Or tur()\nom=18 Or tur()\nom=21 Or tur()\nom=22 Or tur()\nom=23 Or tur()\nom=24 Or tur()\nom=25:
x=tur()\x
y=tur()\y
 AddElement( tur() )
  tur()\x = x
  tur()\y = y
  tur()\nom = 96
EndIf 

Wend
Return 

instal2:

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

aasz=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 aasz>0:aasz-1:EndIf 
    Until aasz=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 





wydra:
;--------------------wydra
Start3D()
;If tur()\upal=0 And tur()\stor=0: RotateSprite3D(tur()\nom+tur()\wani, 370, 0):EndIf 
;If tur()\upal=1 And tur()\stor=0: RotateSprite3D(tur()\nom+tur()\wani, 360, 0):EndIf 
;If tur()\upal=1 And tur()\stor=1: RotateSprite3D(tur()\nom+tur()\wani+8, 370, 0):EndIf 
;If tur()\upal=0 And tur()\stor=1: RotateSprite3D(tur()\nom+tur()\wani+8, 370, 0):EndIf 
;If tur()\gravitator>20 And space=1 And tur()\stor=0: RotateSprite3D(tur()\nom+tur()\wani, 350, 0):EndIf 
; If tur()\gravitator>20 And space=1 And tur()\stor=1: RotateSprite3D(tur()\nom+tur()\wani+8, 350, 0):EndIf 
 If tur()\stor=0: DisplaySprite3D(tur()\nom+tur()\wani , tur()\x + c, tur()\y + d,255):EndIf 
If tur()\stor=1: DisplaySprite3D(tur()\nom+tur()\wani+8 , tur()\x + c+5, tur()\y + d,255):EndIf 


a=SpriteWidth(tur()\nom+tur()\wani)
b= SpriteHeight(tur()\nom+tur()\wani)
a/2
b/2
If tur()\swo=play:
xti=-tur()\x+xraz/2-48
yti=-tur()\y+yraz/2-48
DisplaySprite3D(1000+anistr , tur()\x + c+a-8, tur()\y + d-b+18+stry,255)
EndIf 
StartDrawing( ScreenOutput())
DrawingMode(#PB_2DDrawing_Transparent )
ff=StringByteLength(tur()\name$)
DrawText(tur()\x + c+a-(ff*2)+1,tur()\y + d-b+38+stry , tur()\name$, RGB(0,0,0))
DrawText(tur()\x + c+a-(ff*2)-1,tur()\y + d-b+38+stry , tur()\name$, RGB(0,0,0))
DrawText(tur()\x + c+a-(ff*2),tur()\y + d-b+38+stry , tur()\name$, tur()\color )
    ff= tur()\energ+2
   Box(tur()\x + c+a-(ff/2), tur()\y + d-b+55+stry, tur()\energ+2,5, RGB(0, 0, 0))
   Box(tur()\x + c+a-(ff/2)+1, tur()\y + d-b+55+stry+1, tur()\energ,3, RGB(255, 0, 0))
     StopDrawing() 
 

Stop3D()

Return 



inercija:
ResetList( tur() ) 
While NextElement( tur())
If tur()\nom=97 And tur()\iner>0:
tur()\iner2=0
If tur()\iner>0:tur()\iner-1:EndIf 
iner=1
Gosub stop
iner=0

:EndIf 


If tur()\nom=97 And tur()\iner2>0 :
If tur()\iner2>0:tur()\iner2-1:EndIf 
tur()\iner=0
iner=1
Gosub stop2
iner=0
:EndIf 
Wend
Return 

gravitacija:
Gosub inercija


ResetList( tur() ) 
While NextElement( tur())
If tur()\nom=97  And tur()\upal=1:Gosub upal2:EndIf 
If tur()\nom=97  And tur()\x=tur()\x2:tur()\wani=0:Goto pokoj:EndIf 
If tur()\gravitator>0  And tur()\nom=97 And tur()\x<tur()\x2 And tur()\iner=0:Gosub stop:Gosub wani2:EndIf 
If tur()\gravitator>0  And tur()\nom=97 And tur()\x>tur()\x2 And tur()\iner2=0::Gosub stop2:Gosub wani2:EndIf
If tur()\nom=97  And tur()\x<tur()\x2 And tur()\iner=0::Gosub stop:Gosub wani2:EndIf 
If tur()\nom=97  And tur()\x>tur()\x2 And tur()\iner2=0::Gosub stop2::Gosub wani2:EndIf 
pokoj:
 If  tur()\nom=97:stor=tur()\stor:gravitator=tur()\gravitator:wani=tur()\wani:swo=tur()\swo:wyd=tur()\nom:xww=tur()\x:yww=tur()\y:upal=tur()\upal:Gosub gravitacija2:Gosub pok:ChangeCurrentElement(tur(), *Old_Element):tur()\y=yww:tur()\upal=upal:tur()\gravitator=gravitator:EndIf 
Wend



Return

pok:

ResetList( tur() ) 
While NextElement( tur())
aas=SpriteWidth(tur()\nom)
If tur()\nom=500 And tur()\swo=swo:tur()\wani=wani:tur()\stor=stor:tur()\x=xww-(aas/2)+24:tur()\y=yww-44:tur()\upal=upal:tur()\gravitator=gravitator:EndIf
If tur()\nom=97 And upal=1 And tur()\swo=play And tur()\gravitator=0 And tur()\x=tur()\x2:push=0:EndIf
If tur()\nom=97 And tur()\swo=play:
If tur()\upal=1:spid=tur()\gravitator/4:EndIf 
If tur()\upal=0:spid=asas:EndIf 
spid2=tur()\spid 
:EndIf 
Wend

Return 

stop:
push=0
aaa=0
wyd=tur()\nom:xww=tur()\x:yww=tur()\y:a2=tur()\iner:spi=tur()\spid
*Old_Element = @tur() 
ResetList( tur() )
While NextElement( tur())
If iner=1:Goto sli:EndIf 
If tur()\nom=10 Or tur()\nom=11 Or tur()\nom=12 Or tur()\nom=13  Or tur()\nom=16 Or tur()\nom=17  Or tur()\nom=18 Or tur()\nom=19 Or tur()\nom=21 Or tur()\nom=22 Or tur()\nom=23 Or tur()\nom=24:
Gosub stop3
EndIf 
sli2:
Wend 
ChangeCurrentElement(tur(), *Old_Element)

If tur()\iner>0 And iner=1 And aaa=1:
tur()\x2=tur()\x
tur()\iner2=tur()\iner/2
tur()\iner=0
Return 
EndIf

If iner=1 And aaa=0 And tur()\iner>0
tur()\x+tur()\iner/2
tur()\x2+tur()\iner/2
Return 
EndIf 


If aaa=1:tur()\x2=tur()\x:EndIf 
a=tur()\spid
Repeat
If aaa=0:tur()\x+1:tur()\stor=0:EndIf 
If tur()\x=tur()\x2:Return:Goto pokoj:EndIf 
a-1
Until a=0
Return 

sli:
If tur()\nom=10 Or tur()\nom=11 Or tur()\nom=12 Or tur()\nom=13  Or tur()\nom=16 Or tur()\nom=17  Or tur()\nom=18 Or tur()\nom=19 Or tur()\nom=21 Or tur()\nom=22 Or tur()\nom=23 Or tur()\nom=24:
Gosub stop3a
EndIf 
Goto sli2

sli3:
If tur()\nom=10 Or tur()\nom=11 Or tur()\nom=12 Or tur()\nom=13  Or tur()\nom=16 Or tur()\nom=17  Or tur()\nom=18 Or tur()\nom=19 Or tur()\nom=21 Or tur()\nom=22 Or tur()\nom=23 Or tur()\nom=24:
Gosub stop4a
EndIf 
Goto sli4

stop2:
push=0
aaa=0
wyd=tur()\nom:xww=tur()\x:yww=tur()\y:a2=tur()\iner2:spi=tur()\spid
*Old_Element = @tur() 
ResetList( tur() )
While NextElement( tur())
If iner=1:Goto sli3:EndIf 
If tur()\nom=10 Or tur()\nom=11 Or tur()\nom=12 Or tur()\nom=13  Or tur()\nom=16 Or tur()\nom=17  Or tur()\nom=18 Or tur()\nom=19 Or tur()\nom=21 Or tur()\nom=22 Or tur()\nom=23 Or tur()\nom=24:
Gosub stop4
EndIf 
sli4:
Wend 
ChangeCurrentElement(tur(), *Old_Element)

If tur()\iner2>0 And iner=1 And aaa=1
tur()\x+2
tur()\x2=tur()\x
tur()\iner=tur()\iner2/2
tur()\iner2=0
Return 
EndIf 

If iner=1 And aaa=0 And tur()\iner2>0
tur()\x-tur()\iner2/2
tur()\x2-tur()\iner2/2
Return 
EndIf 
If aaa=1:tur()\x2=tur()\x:EndIf 



a=tur()\spid
Repeat
If aaa=0:tur()\x-1:tur()\stor=1:EndIf 
If tur()\x=tur()\x2:Return:Goto pokoj:EndIf 
a-1
Until a=0


Return 


stop3a:
If SpriteCollision(97, xww, yww, tur()\nom, tur()\x-a2, tur()\y+1)=1:aaa=1:Return:EndIf 
Return 

stop4a:
If SpriteCollision(97, xww, yww, tur()\nom, tur()\x+a2, tur()\y+1)=1:tur()\x2=tur()\x:aaa=1:Return:EndIf 
Return 

stop3:
If SpriteCollision(97, xww, yww, tur()\nom, tur()\x-spi, tur()\y+1)=1:aaa=1:Return:EndIf 
Return 

stop4:
If SpriteCollision(97, xww, yww, tur()\nom, tur()\x+spi, tur()\y+1)=1:tur()\x2=tur()\x:aaa=1:Return:EndIf 
Return 

 
gravitacija2:
asas=0
*Old_Element = @tur() 

ResetList( tur() )
While NextElement( tur())
If tur()\nom=250 And SpriteCollision(97, xww, yww, tur()\nom, tur()\x, tur()\y+40)=1:upal=1:tur()\nom=251:tur()\swo=3:gravitator=200:Return:EndIf 


If tur()\nom=77 And SpriteCollision(97, xww, yww, tur()\nom, tur()\x, tur()\y+40)=1:upal=1:gravitator=0:Return:EndIf 
If tur()\nom=96 And SpriteCollision(97, xww, yww, tur()\nom, tur()\x, tur()\y)=1:upal=1:Return:EndIf 

sl:
Wend 
push=0 
If upal=0:




aaa=gravitator

If aaa>12:aaa=12:EndIf 
yww+1;aaa

asas=aaa
gravitator+1:EndIf 
Return 


;----------------------upal2
upal2: 
push=0 
tur()\gravitator-8
gravitator=tur()\gravitator
If tur()\gravitator>0:tur()\y-(gravitator/4):Return:EndIf

upal=0 
tur()\upal=0
space=0
tur()\gravitator=0
gravitator=0
Return 



wani2:
If anim2=0:Goto wani3:EndIf
If anim2=2:Goto wani3:EndIf
Return 
wani3:
tur()\wani+1
If tur()\wani=8:tur()\wani=0:EndIf 
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 



instalp:

  player-1
  a=Random(2600)
  AddElement( tur() )
  tur()\x = 200;a+64
  tur()\x2 = 200;a+64
  tur()\y = 0
  tur()\nom = 500
    tur()\swo = 1
     tur()\upal = 0
        tur()\gravitator = 0
        tur()\name$="Slip"
        tur()\energ=64
        tur()\color=RGB(255,255,255)
  AddElement( tur() )
  tur()\x = 200;a+64
  tur()\x2 = 200;a+64
  tur()\y = 0
  tur()\nom = 97
   tur()\spid =3
    tur()\swo = 1
       tur()\upal = 0
       tur()\gravitator = 0
Return 





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


load:
ResetList( tur() ) 
While NextElement( tur())
DeleteElement( tur() )
Wend
OpenFile(0,"Tur/tur1.txt")
Length = Lof(0)
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
 CloseFile(0)

Return




ikon:   
DisplayTransparentSprite (1009 , 0, yraz-124)
Return 


; IDE Options = PureBasic 4.40 (Windows - x86)
; CursorPosition = 1162
; FirstLine = 1138
; EnableXP