dofile ("lua/libFenetre.lua")

RPGdatabase ()


back = Image.load("lua/images/panorama.png", 0, 0, VRAM)
canvas2 = Canvas.new()
obj2 = Canvas.newImage(math.random(0, 0), math.random(0, 0), back)
Canvas.add(canvas2, obj2)
spr = Sprite.new("lua/images/agumon run.PNG", 27, 32, VRAM)

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


spr2 = Sprite.new("lua/images/veemon run.PNG", 27, 32, VRAM)

spr2:addAnimation({0,1,2,1}, 300) -- Walk up

x = 0
y = 80
xj = 0
yj = 80
		
direction = 1
direction2 = 1


Sound.loadBank("lua/son/soundbank.bin")
Sound.loadMod(2)
Sound.startMod(2, PLAY_LOOP)

while true do
startDrawing()
	Controls.read()
	Canvas.draw(SCREEN_DOWN, canvas2, 0, 0)
	Canvas.draw(SCREEN_UP, canvas2, 0, 0)
	spr:playAnimation(SCREEN_DOWN, x, y, direction)
    spr2:playAnimation(SCREEN_UP, xj, yj, direction2)
	xj = xj + 0.5
if Stylus.released then
direction = 1
x = x + 3
end

if x > 225 then

spr:destroy()
spr = nil
x = nil
y = nil
direction = nil

spr2:destroy()
spr2 = nil
xj = nil
yj = nil
direction2 = nil

Sound.unloadMod(2)
Sound.unloadBank()
dofile("lua/Win.lua")
end

if xj > 225 then

spr:destroy()
spr = nil
x = nil
y = nil
direction = nil

spr2:destroy()
spr2 = nil
xj = nil
yj = nil
direction2 = nil

Sound.unloadMod(2)
Sound.unloadBank()
dofile("lua/lose.lua")
end
stopDrawing()

end


spr:destroy()
spr = nil
x = nil
y = nil
direction = nil

spr2:destroy()
spr2 = nil
xj = nil
yj = nil
direction2 = nil


Sound.unloadMod(2)
Sound.unloadBank()
