--[[
earth by Samy Pessé
Jeu programmé en une journée
]]--

--Load the engine graphics and controls :
dofile("arch/psp.lua")
EarthEngine.init()

dofile("lib/animation.lua")
dofile("lib/player.lua")
dofile("lib/tileset.lua")
dofile("lib/map.lua")
dofile("lib/cursor.lua")
dofile("lib/skill.lua")
dofile("lib/playeria.lua")
dofile("lib/mapobject.lua")
dofile("lib/meteore.lua")
dofile("lib/menu.lua")


--[[
Load data and music and play menu :
]]--
while true do
 Menu.playIntro()
dofile("lib/musique.lua")
to_use=Menu.play()


--Map of the game
GameMap=Map.new(to_use.m,40,30)

--Player
GamePlayer=Player.new(to_use.p,1,2,0,24)
GameCursor=Cursor.new(1500,"data/image/curseur.png")



setCpuSpeed(333)

oldpad=Controls.read()
while GameCursor.continue do
     screen:clear(Color.new(111,146,227))
	 pad=Controls.read()
	 if fond~=nil then screen:blit(0,0,fond) end
	 
	 if EarthEngine.type=="psp" then
	     GameCursor:playMousePSP(pad)
	 elseif EarthEngine.type=="ds" then
	     GameCursor:playMouseDS(pad)
	 end
	    --Map :
	  GameMap:position()
	  GameMap:refresh()
	  
	    --Player
	  GamePlayer:clear()
	  GamePlayer:reality()
	  GamePlayer:play()
	  GamePlayer:blit()
	  GamePlayer:controls(pad)
	  GamePlayer:stopGravity()
       --ia
	   PlayerIA.play()
	  
	   --Object in the map
	   MapObject.play()
	   
	   --Meteore
	   GameMeteore.play()
	   GlobalAnim.play()
	   
	   GlobalAnim.playEnd()
	   
	   --Cursor
	  GameCursor:play(pad)
	  GameCursor:seeInfo(0)
	  
     screen.waitVblankStart()
     screen.flip()
	 oldpad=pad
end
end
