Mp3me.stop()
Mp3me.load("data/sound/4.mp3")
Mp3me.play()
avtor= Image.load("data/img/avtor.png")
avtor2= Image.load("data/img/avtor2.png")
avtor3= Image.load("data/img/avtor3.png")
circl=Image.load("data/img/circl.png")
font3 = Font.load("data/font/qwe2.ttf")
font3:setPixelSizes(35,30)
font5 = Font.load("data/font/qwe2.ttf")
font5:setPixelSizes(10,10)
iii=216
iiii=0
qupe=0
paka=272
local mk={2}
local ml={2}
local pin={2}
file=io.open("data/makesave/save18.msn","r")
mk[1]=tonumber(file:read())
file:close()
file=io.open("data/makesave/save19.msn","r")
ml[1]=tonumber(file:read())
file:close()
file=io.open("data/makesave/save20.msn","r")
mk[2]=tonumber(file:read())
file:close()
file=io.open("data/makesave/save21.msn","r")
ml[2]=tonumber(file:read())
file:close()
file=io.open("data/makesave/save22.msn","r")
abul=file:read()
file:close()
file=io.open("data/makesave/save23.msn","r")
abutut=file:read()
file:close()
function save()
file=io.open("data/makesave/save18.msn","w")
file:write(mk[1])
file:close()
file=io.open("data/makesave/save19.msn","w")
file:write(ml[1])
file:close()
file=io.open("data/makesave/save20.msn","w")
file:write(mk[2])
file:close()
file=io.open("data/makesave/save21.msn","w")
file:write(ml[2])
file:close()
file=io.open("data/makesave/save22.msn","w")
file:write(abul)
file:close()
end

for i=1,2 do--dlia proverki stolknovenii
pin[i]=0
end

while true do
screen:clear()
pad = Controls.read()
if iii<255 and iii<255 and ii==0 then
iii=iii+1
iiii=iiii+1
else
ii=1
end
if iii>0 and iii>0 and ii==1 then
iii=iii-1
iiii=iiii-1
else
ii=0
end
rnd=Color.new(255,iii,iiii)
if c+480>=0 then
c=c-tonumber(fons)
else
c=0
end
if pad:up() then
paka=paka-2
elseif pad:down() and math.ceil(paka)<272 then
paka=paka+2
else
if math.ceil(paka)>-852 then
paka=paka-0.5
else
avtor=nil
circl=nil
avtor2=nil
avtor3=nil
Mp3me.stop()
Mp3me.load("data/sound/1.mp3")
Mp3me.play()
dofile("data/scripts/script.cpp")
end
end
screen:blit(0,0,fonmenu)
screen:blit(0,paka,avtor)
screen:blit(0,paka+282,avtor2)
screen:blit(0,paka+580,avtor3)
screen:blit(428,220,circl)
--screen:blit(c+480,0,fon)
--screen:fontPrint(font2,mk[1],ml[1],abul,rnd)
--screen:fontPrint(font3,175,220,"VITTACH",rnd)
--screen:blit(mk[2],ml[2],about)
--screen:fontPrint(font11,mk[2]+15,ml[2]+25,abutut,blue)
--screen:blit(195,220,thanks)

--menuchka

if pad:start() and oldpad:start()~=pad:start() then--vkluchenie menu
qupe=1
x = 240
y = 136
end
if qupe==1 then
if s>246 then
s=s-2
end
if ss<-1 then
ss=ss+4
end
screen:blit(0,s,menu)

if x>=mk[1] and x<=mk[1]+100 and y>=ml[1]-50 and y<=ml[1] then
if pad:square() then--pereimenovka
abul= System.startOSK(abul,"Vvedite")
file=io.open("data/makesave/save22.msn","w")
file:write(abul)
file:close()
end
if pad:circle() and pin[2]==0 then
pin[1]=1
if x>=0 and x<=27 and y>=248 and y<=270 then--udalenie
mk[1]=500
ml[1]=300
save()
else -- inache peremeshenie
mk[1]=math.ceil(x-20)--80
ml[1]=math.ceil(y+20)--13
screen:fontPrint(font11,200,264,"x= " .. mk[1],blue)
screen:fontPrint(font11,280,264,"y= " .. ml[1],blue)
end
end
else
pin[1]=0
end
if x>=mk[2] and x<=mk[2]+233 and y>=ml[2] and y<=ml[2]+117 then
if pad:square() then--pereimenovka
abutut= System.startOSK(abutut,"Vvedite")
file=io.open("data/makesave/save23.msn","w")
file:write(abutut)
file:close()
end
if pad:circle() and pin[1]==0 then
pin[2]=1
if x>=0 and x<=27 and y>=248 and y<=270 then--udalenie
mk[2]=500
ml[2]=300
save()
else -- inache peremeshenie
mk[2]=math.ceil(x-20)--80
ml[2]=math.ceil(y-20)--13
screen:fontPrint(font11,200,264,"x= " .. mk[2],blue)
screen:fontPrint(font11,280,264,"y= " .. ml[2],blue)
end
end
else
pin[2]=0
end
if System.powerIsPowerOnline() then 
zaradbat=zaradbat+1
if zaradbat>=1 then screen:blit(430,s+2,bat14) end
if zaradbat>=10 then screen:blit(430,s+2,bat15) end
if zaradbat>=20 then screen:blit(430,s+2,bat16) end
if zaradbat>=30 then screen:blit(430,s+2,bat17) end
if zaradbat>=40 then screen:blit(430,s+2,bat18) end
if zaradbat>=50 then screen:blit(430,s+2,bat19) end
if zaradbat>=60 then screen:blit(430,s+2,bat20) end
if zaradbat>=70 then screen:blit(430,s+2,bat21) end
if zaradbat>=80 then screen:blit(430,s+2,bat22) end
if zaradbat>=90 then screen:blit(430,s+2,bat23) end
if zaradbat>=100 then screen:blit(430,s+2,bat24) end
if zaradbat>=110 then screen:blit(430,s+2,bat25) end
if zaradbat>=120 then screen:blit(430,s+2,bat26) end
if zaradbat>=130 then zaradbat=1 end
else
zaradbat=1
if System.powerGetBatteryLifePercent() >= 0 and System.powerGetBatteryLifePercent() <=4 then screen:blit(430,s+2,bat0) end
if System.powerGetBatteryLifePercent() > 4 then screen:blit(432,s+2,bat1) end
if System.powerGetBatteryLifePercent() > 8 then screen:blit(432,s+2,bat2) end
if System.powerGetBatteryLifePercent() > 16 then screen:blit(432,s+2,bat3) end
if System.powerGetBatteryLifePercent() > 24 then screen:blit(432,s+2,bat4) end
if System.powerGetBatteryLifePercent() > 32 then screen:blit(432,s+2,bat5) end
if System.powerGetBatteryLifePercent() > 40 then screen:blit(432,s+2,bat6) end
if System.powerGetBatteryLifePercent() > 48 then screen:blit(432,s+2,bat7) end
if System.powerGetBatteryLifePercent() > 56 then screen:blit(432,s+2,bat8) end
if System.powerGetBatteryLifePercent() > 64 then screen:blit(432,s+2,bat9) end
if System.powerGetBatteryLifePercent() > 72 then screen:blit(432,s+2,bat10) end
if System.powerGetBatteryLifePercent() > 80 then screen:blit(432,s+2,bat11) end
if System.powerGetBatteryLifePercent() > 88 then screen:blit(432,s+2,bat12) end
if System.powerGetBatteryLifePercent() > 96 then screen:blit(432,s+2,bat13) end
end
screen:fontPrint(font10,365,s+22,System.getTime(1).." : "..System.getTime(2),blue)
screen:blit(x,y,souris)
if x>=450 and x<=471 and y>=248 and y<=269 then--vikluchenie menu
screen:blit(x,y,souris2)
if lang==2 then
screen:fontPrint(font11,200,266,"otkluchenie",blue)
else
screen:fontPrint(font11,200,266,"disconnection",blue)
end
if pad:circle() then
s=272
ss=-61
qupe=0
end
end
if pad:select() and qupe==1 then
s=272
ss=-61
qupe=0
end
if x>=51 and x<=72 and y>=248 and y<=269 then--sohranenie
screen:blit(x,y,souris2)
if lang==2 then
screen:fontPrint(font11,200,266,"sohranenie",blue)
else
screen:fontPrint(font11,200,266,"save",blue)
end
if pad:circle() and qupe==1 then 
save()
end
end
if x>=143 and x<=163 and y>=248 and y<=269 then--otmena
screen:blit(x,y,souris2)
if lang==2 then
screen:fontPrint(font11,200,266,"otmena",blue)
else
screen:fontPrint(font11,200,266,"cancel",blue)
end
if pad:circle() and qupe==1 then
mk[1]=175
ml[1]=70
mk[2]=125
ml[2]=76
save()
end
end
if x>=90 and x<=118 and y>=248 and y<=269 then--notepad
screen:blit(x,y,souris2)
screen:fontPrint(font11,200,266,"lua edit",blue)
if pad:circle() and qupe==1 then
dofile("data/Notepad/Notepad.dat")
end
end
screen:blit(0,ss,gm)--raspechatka kruzka GM
if x>=0 and x<=60 and y>=0 and y<=61 then
screen:blit(x,y,souris2)
end
if pad:circle() and x>=0 and x<=60 and y>=0 and y<=61 then
avtor=nil
circl=nil
avtor2=nil
avtor3=nil
dofile("data/scripts/gm.ttf")
end
end
if pad:circle() and qupe==0 then
avtor=nil
avtor2=nil
Mp3me.stop()
Mp3me.load("data/sound/1.mp3")
Mp3me.play()
dofile("data/scripts/script.cpp")
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()
if math.abs(pad:analogY()) > 32 then
y = y + pad:analogY() / 32;
end
if math.abs(pad:analogX()) > 32 then
x = x + pad:analogX() / 32;
end
if x < 0 then x = 0 elseif x + souris:width() > 480 then x = 480 -  souris:width() end
if y < 0 then y = 0 elseif y + souris:height() > 272 then y = 268 -  souris:width() end
oldpad=pad
end