function LevelSave(filename$)
file = OpenToWrite(filename$,0)
Writeline(file,"Level Ball Labyrinth")
WriteInteger ( file, Level.color )
WriteInteger ( file, Level.style )
//Hole x,y
WriteInteger ( file, Level.holes )
for i=1 to Level.holes
WriteFloat(file,getspritexbyoffset(Level_Hole[i].spr))
WriteFloat(file,getspriteybyoffset(Level_Hole[i].spr))
next
//Start x,y
WriteFloat(file,getspritexbyoffset(Level.Start.spr))
WriteFloat(file,getspriteybyoffset(Level.Start.spr))
//Ende x,y
WriteFloat(file,getspritexbyoffset(Level.Goal.spr))
WriteFloat(file,getspriteybyoffset(Level.Goal.spr))
//Block x,y,a
WriteInteger ( file, Level.blocks )
for i=1 to Level.blocks
WriteFloat(file,getspritexbyoffset(Level_Block[i].spr))
WriteFloat(file,getspriteybyoffset(Level_Block[i].spr))
WriteFloat(file,getspriteangle(Level_Block[i].spr))
next
//Pin x,y,a
WriteInteger ( file, Level.pins )
for i=1 to Level.pins
WriteFloat(file,getspritexbyoffset(Level_Pin[i].spr))
WriteFloat(file,getspriteybyoffset(Level_Pin[i].spr))
WriteFloat(file,getspriteangle(Level_Pin[i].spr))
next
//Wall x,y,a
WriteInteger ( file, Level.walls )
for i=1 to Level.walls
WriteFloat(file,getspritexbyoffset(Level_Wall[i].spr))
WriteFloat(file,getspriteybyoffset(Level_Wall[i].spr))
WriteFloat(file,getspriteangle(Level_Wall[i].spr))
next
//Way x,y,a
WriteInteger ( file, Level.waypoints )
for i=1 to Level.waypoints
WriteFloat(file,getspritexbyoffset(Level_WayPoint[i].spr))
WriteFloat(file,getspriteybyoffset(Level_WayPoint[i].spr))
WriteFloat(file,getspriteangle(Level_WayPoint[i].spr))
next
CloseFile ( file )
endfunction