
arial = Font.load("drawn.ttf")
arial:setPixelSizes(0,30)
vert =Color.new(0,255,0)
blanc = Color.new(255,255,255)

player1 = Image.load("sprites.png")

sol = nil 
sky = nil 
menu = nil 



sky  =           Image.load("fond.png")
sol =            Image.load("sol.png")
menu =           Image.load("tableau.png") 

sol = nil 
sky = nil 
menu = nil  


  ecran=Image.createEmpty(480,272)
player = {}
gravity_max=272
player.gravity = gravity_max
player.y = gravity_max
player.x = 0
player.jumpspeed = 20
player.jumpstate = "sol"
player.jumpstate = "sol"
dofile("objet.lua")
dofile("jeu.lua")
dofile("dialogue.lua")
larg = math.floor(player1:width()/ 12) ---Largeur
hau = math.floor(player1:height())---Hauteur

statut_standing = {}
statut_standing[1] = {xs=0, y=0, lg=larg, h=hau, n=1}

statut_right = {}-- Si situation right
statut_right[1] = {xs=larg*1, y=0, lg=larg, h=hau, n=3}
statut_right[2] = {xs=larg*2, y=0, lg=larg, h=hau, n=3}
statut_right[3] = {xs=larg*3, y=0, lg=larg, h=hau, n=3}

statut_left = {}--Situation left
statut_left[1] = {xs=larg*6, y=0, lg=larg, h=hau, n=3}
statut_left[2] = {xs=larg*5, y=0, lg=larg, h=hau, n=3}
statut_left[3] = {xs=larg*4, y=0, lg=larg, h=hau, n=3}

statut_up = {}-- Situation haut
statut_up[1] = {xs=larg*7, y=0, lg=larg, h=hau, n=3}
statut_up[2] = {xs=larg*8, y=0, lg=larg, h=hau, n=3}
statut_up[3] = {xs=larg*9, y=0, lg=larg, h=hau, n=3}

statut_sot = {}-- Situation saut 
statut_sot[1] = {xs=larg*10, y=0, lg=larg, h=hau, n=2}
statut_sot[2] = {xs=larg*11+2, y=0, lg=larg, h=hau, n=2}


statut_arret = 2
statut_player1 = 1
compteur_statut = 1






player.jumpspeed = 20
player.jumpstate = "sol"
statutt=0
balle_nb=100
vitesse=10
game_menu()
compteur_anime2=1
while true do
dialogue_init=false
game_over()
statut_player1 = 1
pad = Controls.read()
screen:clear()
ecran:clear(blanc)
if pad:left() then 
direction = "left"
statut_player1 = 3
player.x = player.x - vitesse
end
if pad:right() then
direction = "right"
statut_player1 = 2
player.x = player.x + vitesse
end

if pad:cross() and player.jumpstate == "sol" and direction == "right" and balle_nb>0 and pad~=oldpad then
if not pad:right() and not pad:circle() and not pad:left() then
balle_nb=balle_nb-1
bulletSetup()
statut_player1 = 5
end
end

if pad:circle() and player.jumpstate == "sol" then player.jumpstate = "en saut" player.gravity=player.gravity-1 end 

if player.jumpstate == "en saut" and player.gravity ~= gravity_max then 
statut_player1 = 4
player.jumpspeed = player.jumpspeed - 1
player.gravity = player.gravity - player.jumpspeed
end

if player.jumpspeed<=0 then 
player.jumpstate = "retombe"
end

if player.gravity < gravity_max and player.jumpstate == "retombe" then 
statut_player1 = 4
player.jumpspeed = player.jumpspeed + 1
player.gravity = player.gravity + (player.jumpspeed + 3) 
end

if player.gravity == gravity_max then 
player.jumpspeed = 6
player.jumpstate = "sol"
end

if player.gravity > gravity_max then 
player.gravity = gravity_max 
end

if lastgravitymax~=gravity_max then
player.gravity=gravity_max
end

player.y = player.gravity
lastgravitymax=gravity_max
gravity_max=(262-hau)+1

game_aff()
if pad:start() then menu_() end
game_stat_write()
screen:blit(0,0,ecran)
screen.waitVblankStart()
screen.flip()
oldpad=pad
end 

