dofile ("lua/libFenetre.lua")

RPGdatabase ()

spr = Sprite.new("lua/images/agumon win.PNG", 32, 32, VRAM)

spr:addAnimation({0,1,2,1}, 600) -- Walk up

x = 100
y = 80

direction = 1

    file = io.open("lua/save/pv.txt", 'r')
    if file then
    heros.a.hp = file:read()
    file:close()
    else
    heros.a.hp = 125
    end
    
    file2 = io.open("lua/save/atc.txt", 'r')
    if file2 then
    heros.a.att = file2:read()
    file2:close()
    else
    heros.a.att = 5
    end
	
	file3 = io.open("lua/save/def.txt", 'r')
    if file3 then
    heros.a.def = file3:read()
    file3:close()
    else
    heros.a.def = 5
    end
	
    file4 = io.open("lua/save/mp.txt", 'r')
    if file4 then
    heros.a.mp = file4:read()
    file4:close()
    else
    heros.a.mp = 50
    end

heros.a.att = heros.a.att + math.random( 1, 3)
heros.a.def = heros.a.def + math.random( 1, 3)
heros.a.hp = heros.a.hp + math.random( 1, 5)
heros.a.mp = heros.a.mp + math.random( 1, 3)

    file = io.open("lua/save/pv.txt", 'w')
    file:write(heros.a.hp)
    file:close()
	
    file2 = io.open("lua/save/atc.txt", 'w')
    file2:write(heros.a.att)
    file2:close()
	
	file3 = io.open("lua/save/def.txt", 'w')
    file3:write(heros.a.def)
    file3:close()
	
	file4 = io.open("lua/save/mp.txt", 'w')
    file4:write(heros.a.mp)
    file4:close()


while true do
startDrawing()
	Controls.read()
	screen.print(SCREEN_UP, 75, 0, "Tu as gagné")
	screen.print(SCREEN_UP, 75, 20, "Ses Stats augmentent!")

	screen.print(SCREEN_UP, 0, 140, "Appui X pour continuer")


  screen.print(SCREEN_DOWN, 0, 50, "ATC")
  screen.print(SCREEN_DOWN, 0, 60, "DEF")
  screen.print(SCREEN_DOWN, 0, 70, "PV")
  screen.print(SCREEN_DOWN, 0, 80, "PM")

  screen.print (SCREEN_DOWN, 40, 50, heros.a.att)
  screen.print (SCREEN_DOWN, 40, 60, heros.a.def)
  screen.print (SCREEN_DOWN, 40, 70, heros.a.hp)
  screen.print (SCREEN_DOWN, 40, 80, heros.a.mp)
  
spr:playAnimation(SCREEN_UP, x, y, direction)
if Keys.held.X then
	-- Vide la mémoire
spr:destroy()
spr = nil
x = nil
y = nil
direction = nil
heros.a.att = nil
heros.a.def = nil
heros.a.hp = nil
heros.a.mp = nil

-- Retourne à l'ecran de titre

dofile("lua/Ecran de Titre.lua")
end

stopDrawing()

end



