room=Image.load("data/img/room.png")--zagruzka kartinki na vremennuu peremennuu
perso=Image.load("data/pers/perso.png")--zagruzka kartinki na vremennuu peremennuu
perso2=Image.load("data/pers/perso2.png")--zagruzka kartinki na vremennuu peremennuu
m19=Image.load("data/img/m1911.png")--zagruzka kartinki na vremennuu peremennuu
goout=Image.load("data/img/goout.png")--zagruzka kartinki na vremennuu peremennuu
hper=Image.load("data/img/hp.png")--zagruzka kartinki na vremennuu peremennuu
hper2=Image.load("data/img/hp2.png")--zagruzka kartinki na vremennuu peremennuu
hp01=Image.load("data/img/hp/hp01.png")--zagruzka kartinki na vremennuu peremennuu
hp02=Image.load("data/img/hp/hp02.png")--zagruzka kartinki na vremennuu peremennuu
hp03=Image.load("data/img/hp/hp03.png")--zagruzka kartinki na vremennuu peremennuu
hp04=Image.load("data/img/hp/hp04.png")--zagruzka kartinki na vremennuu peremennuu
hp05=Image.load("data/img/hp/hp05.png")--zagruzka kartinki na vremennuu peremennuu
hp06=Image.load("data/img/hp/hp06.png")--zagruzka kartinki na vremennuu peremennuu
hp07=Image.load("data/img/hp/hp07.png")--zagruzka kartinki na vremennuu peremennuu
hp08=Image.load("data/img/hp/hp08.png")--zagruzka kartinki na vremennuu peremennuu
hp09=Image.load("data/img/hp/hp09.png")--zagruzka kartinki na vremennuu peremennuu
hp10=Image.load("data/img/hp/hp10.png")--zagruzka kartinki na vremennuu peremennuu
hp11=Image.load("data/img/hp/hp11.png")--zagruzka kartinki na vremennuu peremennuu
hp12=Image.load("data/img/hp/hp12.png")--zagruzka kartinki na vremennuu peremennuu
hp13=Image.load("data/img/hp/hp13.png")--zagruzka kartinki na vremennuu peremennuu
hp14=Image.load("data/img/hp/hp14.png")--zagruzka kartinki na vremennuu peremennuu
hp15=Image.load("data/img/hp/hp15.png")--zagruzka kartinki na vremennuu peremennuu
hp16=Image.load("data/img/hp/hp16.png")--zagruzka kartinki na vremennuu peremennuu

function nill()
goout=nil
room=nil
m19=nil
perso=nil
perso2=nil
end

zizn=17
x=240--prisvaivanie elementam ih znachenii
y=180--prisvaivanie elementam ih znachenii
tz=0--prisvaivanie elementam ih znachenii
ttz=0--prisvaivanie elementam ih znachenii

while true do
screen:clear()--ochistka ekrana
pad = Controls.read()--podgruzka knopok psp
screen:blit(0,0,room)

if tz==1 then--raspechatka hodbi persa
ttz=ttz+1
end
if ttz>10 then
tz=0
ttz=0
end
if ttz>=5 and ttz<=10 then
screen:blit(x,y,perso2)
else
screen:blit(x,y,perso)
end
if zizn==17 then
screen:blit(x+4,y+55,hper)
elseif zizn>=16 then
screen:blit(x+4,y+55,hp01)
elseif zizn>=15 then
screen:blit(x+4,y+55,hp02)
elseif zizn>=14 then
screen:blit(x+4,y+55,hp03)
elseif zizn>=13 then
screen:blit(x+4,y+55,hp04)
elseif zizn>=12 then
screen:blit(x+4,y+55,hp05)
elseif zizn>=11 then
screen:blit(x+4,y+55,hp06)
elseif zizn>=10 then
screen:blit(x+4,y+55,hp07)
elseif zizn>=9 then
screen:blit(x+4,y+55,hp08)
elseif zizn>=8 then
screen:blit(x+4,y+55,hp09)
elseif zizn>=7 then
screen:blit(x+4,y+55,hp10)
elseif zizn>=6 then
screen:blit(x+4,y+55,hp11)
elseif zizn>=5 then
screen:blit(x+4,y+55,hp12)
elseif zizn>=4 then
screen:blit(x+4,y+55,hp13)
elseif zizn>=3 then
screen:blit(x+4,y+55,hp14)
elseif zizn>=2 then
screen:blit(x+4,y+55,hp15)
elseif zizn>=1 then
screen:blit(x+4,y+55,hp16)
end
screen:blit(x+12,y-8,m19)--pistolet

if pad:up() then
tz=1
y =y-8
elseif pad:down() then
tz=1
y =y+5
elseif pad:left() then
tz=1
x =x-5
elseif pad:right() then
t=1
x =x+5
elseif math.abs(pad:analogY()) > 32 then
tz=1
y = y + pad:analogY() / 64;
elseif math.abs(pad:analogX()) > 32 then
tz=1
x = x + pad:analogX() / 64;
else
tz=0
ttz=0
end

if x>=220 and x<=240 and y>160 then
screen:blit(185,235,goout)
if pad:circle() and oldpad:circle()~=pad:circle() then
nill()
y=163
break
end
end

if pad:select() then
file=io.open("data/makesave/screenshoter.msn","r")
nscreen=tonumber(file:read())
file:close()
screen:save("data/screenshot/SHOT"..nscreen..".png")
nscreen=nscreen+1
file=io.open("data/makesave/screenshoter.msn","w")
file:write(math.ceil(nscreen))
file:close()
end
screen:flip()
oldpad=pad
if x < 40 then x = 40 elseif x + souris:width() > 424 then x = 424 -  souris:width() end
if y < 90 then y = 90 elseif y + souris:height() > 190 then y = 190 -  souris:width() end
end