print("Loading Bricktown Level")
saveSlot();
clear();

--LEVEL SETUP

--set Background
--texture, width, height, position X, position Y
--setBackGround(map_BackGround, 200, 200, 0, 0);
setBackGround("map_bricktown.dds", 200, 200, 0, 0);
setTerrainMap("terraininfo_bricktown.tga");
setGameMode(3);
gofile("setViewDistance.lua");

--set Sun
--distance X, distance Y
setSunDist(-0.55, 1.0);

--set Dust visual element
setDustElement(vel_dust);
setSkidElement(vel_skid);

--set Borders
--position X, position Y, direction, elasticity
addBorder(0, 100, PI, 0.7);
addBorder(100, 0, HALFPI, 0.7);
addBorder(0, -100, 0, 0.7);
addBorder(-100, 0, THREEHALFPI, 0.7);

--setWaypoints
--position X, position Y
addWaypoint(-60, 65);
addWaypoint(50, 65);
addWaypoint(40, -25);
addWaypoint(-60, -30);

--setLinkPoints
--position X, position Y, radius, clearlevel?(never use), mustStop?, dofile
addLinkPoint(-11, -100, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(15.6, 100, 14, false, false, "saveTown(); gofile(\"control.lua\")");
addLinkPoint(-35, -53, 7, false, true, "gofile(\"store/store_dealer.lua\")");
addLinkPoint(35, 49, 7, false, true, "gofile(\"store/store_gunsBrickTown.lua\")");
addLinkPoint(-24, 45, 7, false, true, "gofile(\"store/store_trader.lua\")");
addLinkPoint(30.5, -5, 7, false, true, "gofile(\"store/store_missions.lua\")");

addBaseSprite(vel_baseArrow, -11, -94, PI * 0.97);
addBaseSprite(vel_baseArrow, 15.6, 94, PI * 1.97);
addBaseSprite(vel_baseCars, -35, -53, PI * 0.00);
addBaseSprite(vel_baseGuns, 35, 49, PI * 0.00);
addBaseSprite(vel_baseTrade, -24, 45, PI * 0.00);
addBaseSprite(vel_baseJobs, 30.5, -5, PI * 0.00);

--set Camera Extents
--max X, min X, max Y, min Y
--setCameraExtents(50.0, -50.0, 62.5, -62.5);
autoCameraExtents();

--set Obstacles
--texture, size X, size Y, position X, position Y, direction 
addObstacleBox(map_Building, 24, 60, -54, 56, PI * -0.05);
addObstacleBox(map_Building, 16, 35, 68, 47.5, PI * -0.05);
addObstacleBox(map_Building, 16, 35, 53.8, -57.5, PI * -0.05);
addObstacleBox(map_Building, 30, 36, 64.5, -7.5, PI * -0.05);

--misc Mobs
--texture, size X, size Y, position X, position Y, mass, elastic, friction, round, dir 
addGroundMob(map_tireutil,    4,      4,      -37,     -15,      6,      0.9,   0.1,    true, 0.1);
addGroundMob(map_tireold,     3,      3,      -40,     -20,      6,      0.9,   0.1,    true, 0.2);

--texture, size X, size Y, position X, position Y, mass, elastic, friction, round, dir
addGroundMobq(map_barrelblue, 3, 5, -32, -10, 2, 0.9, 0.1, false, 0.5);

--set Waves
--line1 return handle> min Enemies
--lines wave handel, being handle, pos X, pos Y, team, tatic
--wave_1 = addWave(0);
--setWaveEntry(wave_1, car_camino, 60, -220, 2, 0);

loadTown(townbrick);

--dealership
car1 = addBeing(dealerCar1, -60.5, -22, PI * -0.6, 1);
car2 = addBeing(dealerCar2, -60.5, -35, PI * -0.6, 1);
addToDealer(car1);
addToDealer(car2);

--setup Player: Car, audio listener, and camera follow
player = addBeing(playerCar, -2.0, -54.0, PI * -0.15, 1);
setPlayerBeing(player);
setMobHealth(player, getPlayerHealth());
setWeapon(player, 1, playerWeapon1);
setWeapon(player, 2, playerWeapon2);

saveSlot();
