std.include("scripts/common.lua")

function init_level()
   -----------------------------------
   -- Spawn old man
   local player=get_player()
   set_frame(player,frame_north)
   set_inertia(player,1)
   enable_input(player,false)
   enable_anim(player,false)
   enable_movement(player,false)

   local p=add_vec3(get_object_world_pos(player),{ 2,0,8 })
   local old_man=instance_game_sprite("old_man","old_man",p)
   set_frame(old_man,frame_death)
   wait_time(1000)
   -----------------------------------
   -- Speech part
   local text_id
   text_id=say(player,"!",3000,{ 0.2,1.0,0.1,1 });
   set_movement_vector(player,{0,0,1})
   enable_movement(player,true)
   enable_anim(player,true)
   wait_time(600)
   set_movement_vector(player,{0,0,0})
   enable_movement(player,false)
   enable_anim(player,false)
   text_id=say(player,"What happened?!",2000,{ 0.2,1.0,0.1,1 }); wait_text(text_id)
   text_id=say(player,"What do I do now?!",3000,{ 0.2,1.0,0.1,1 }); wait_text(text_id)
   text_id=say(player,"No portal in sight...\nMaybe carry on?",3000,{ 0.2,1.0,0.1,1 }); wait_text(text_id)
   set_movement_vector(player,{0,0,1})
   enable_movement(player,true)
   enable_anim(player,true)
   wait_time(2000)
   text_id=say(nil,"To be continued...",5000,{ 1,1,1,1 }); wait_text(text_id)
   wait_time(1000)
   next_level("main_menu")
end
