include ("render")
include ("units")
include ("interp")

include ("roadseg")
include ("roadstream")
include ("road")
include ("car")
include ("roadstream")
include ("node")
include ("traffic")

include ("play")
include ("hud")
include ("adventure")
include ("adlib")

render_list = {}

cur_hud = nil
cur_play = nil
cur_adventure = nil

function new_game ()

   cur_hud = hud ()

   cur_play = play ()

   local InitRoadstream = roadstream ()
   InitRoadstream:init (1, 1, RN_get_seed ())

   local PlayerCar = car ()

   cur_adventure = adventure ()
   cur_adventure:set_node (node_intro ())

   cur_play:set_car (PlayerCar)
   cur_play:set_roadstream (InitRoadstream)
   cur_play:set_adventure (node_intro ())
end

function update (T)

   -- update gameplay model
   cur_play:update (T)
   cur_hud:update (T)

   -- render everything
   local R = render ()
   render_list = {}

   -- the play field; could be "adventure" mode
   table.insert (render_list, cur_play:render (R))

   -- draw the interface
   table.insert (render_list, R:camera (0, 0))
   table.insert (render_list, cur_hud:render (R))
end

function keypress (K)

   cur_play:keypress (K)
end

new_game ()
