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

  If OpenWindow(0, 0, 0, 1024, 768, "Выдры против хорьков.", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)

  ;
  ; 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), 0, 0, 1024, 768, 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 (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 (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" )

;-----------------------------------задний план


exitm=0

xm=0:ym=0; x y mouse
razmer=128-16; razmer lokacii
c=0:d=0
obx=10
chet=0
obx2=0

Structure Person
    x.w
    y.w
    nom.w
    swo.w
  EndStructure

  NewList tur.Person ()
okno=1







Gosub load:



  Repeat
  



  
   Event = WaitWindowEvent()
  
  
    







 
  




Gosub print

Gosub wydra
Gosub mouse

Gosub print2

FlipBuffers()
ClearScreen (0)





   Until Quit = 1 Or KeyboardPushed(#PB_Key_Escape)
  
  

    
EndIf

End 





wydra:
Return 















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=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=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 
  su:
Wend

Return 

print2:

ResetList( tur() ) 

While NextElement( tur())

  If tur()\nom=>110:DisplayTransparentSprite( tur()\nom , tur()\x + c, tur()\y + d):EndIf 
  
Wend

Return 















escc:

exitm=1:
Return 


mouse:

ExamineKeyboard()


If KeyboardPushed(#PB_Key_Escape):Goto escc:EndIf 
If KeyboardPushed(#PB_Key_Left) And korx>0: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:kory-1:d+16:yf+4:EndIf 
If KeyboardPushed(#PB_Key_Down) And kory<razmer:kory+1:d-16:yf-4:EndIf 


 

ExamineMouse() 
 



 xm = MouseX()                         
 ym = MouseY() 

DisplayTransparentSprite(1, xm, ym)

anim2+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 






Return  















































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

      
   StopDrawing()


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

; IDE Options = PureBasic 4.40 (Windows - x86)
; CursorPosition = 217
; FirstLine = 204
; EnableXP