Meteore={}
function Meteore.new(x,y,x1,y2,t)
     local meteore={x=x,
	                y=y,
					dx=x1,
					dy=y2,
					pic=Animation.new("data/image/4.png",4,0,0,60,13,1),
					etat=true,
					anim=GlobalAnim.new("data/image/boom2.png",4,0,0,280,70,2),
					t=t or 0}
					
					
					
	 function meteore:play()
	     if meteore.etat then
	         if GameMap:getRm((meteore.x+meteore.dx),(meteore.y+meteore.dy))==1 then
		         meteore.x=meteore.x+meteore.dx
			     meteore.y=meteore.y+meteore.dy
			     meteore.pic:play(screen,GameMap.xr+meteore.x*20,GameMap.yr+meteore.y*20)
			 elseif GameMap:getRm((meteore.x+meteore.dx),(meteore.y+meteore.dy))==2 then
			     meteore.etat=false
				 GlobalAnim.run(meteore.anim,GameMap.xr+meteore.x*20-15,GameMap.yr+meteore.y*20)
				 PlayerIA.destroy(meteore.x+meteore.dx,meteore.y+meteore.dy)
				 PlayerIA.destroy(meteore.x+meteore.dx-1,meteore.y+meteore.dy)
				 PlayerIA.destroy(meteore.x+meteore.dx,meteore.y+meteore.dy-1)
				 PlayerIA.destroy(meteore.x+meteore.dx-1,meteore.y+meteore.dy-1)
				 
				 GamePlayer:killXY(meteore.x+meteore.dx,meteore.y+meteore.dy)
				 GamePlayer:killXY(meteore.x+meteore.dx-1,meteore.y+meteore.dy)
				 GamePlayer:killXY(meteore.x+meteore.dx,meteore.y+meteore.dy-1)
				 GamePlayer:killXY(meteore.x+meteore.dx-1,meteore.y+meteore.dy-1)
				 
		     else
		         meteore.etat=false
				 GlobalAnim.run(meteore.anim,GameMap.xr+meteore.x*20-20,GameMap.yr+meteore.y*20)
				 GameMap:set(meteore.x+meteore.dx,meteore.y+meteore.dy,"0")
				 GameMap:set(meteore.x+meteore.dx-1,meteore.y+meteore.dy,"0")
				 GameMap:set(meteore.x+meteore.dx-1,meteore.y+meteore.dy-1,"0")
				 GameMap:set(meteore.x+meteore.dx,meteore.y+meteore.dy-1,"0")
				 
				 PlayerIA.destroy(meteore.x+meteore.dx,meteore.y+meteore.dy)
				 PlayerIA.destroy(meteore.x+meteore.dx-1,meteore.y+meteore.dy)
				 PlayerIA.destroy(meteore.x+meteore.dx,meteore.y+meteore.dy-1)
				 PlayerIA.destroy(meteore.x+meteore.dx-1,meteore.y+meteore.dy-1)
				 
				 GamePlayer:killXY(meteore.x+meteore.dx,meteore.y+meteore.dy)
				 GamePlayer:killXY(meteore.x+meteore.dx-1,meteore.y+meteore.dy)
				 GamePlayer:killXY(meteore.x+meteore.dx,meteore.y+meteore.dy-1)
				 GamePlayer:killXY(meteore.x+meteore.dx-1,meteore.y+meteore.dy-1)
		     end
		 end
	 end

     return meteore
end


GameMeteore={n=0}
function GameMeteore.new(x,y,dx,dy,t)
     GameMeteore.n=GameMeteore.n+1
	 GameMeteore[GameMeteore.n]=Meteore.new(x,y,dx,dy,t)
end

function GameMeteore.play()
     if GameMeteore.n>0 then
         for i=1,GameMeteore.n do
		     if GameMeteore[i].t<=GameCursor.t then
	             GameMeteore[i]:play()
			 end
	     end
	 end
end

