Newer
Older
Import / applications / HighwayDash / ports / Game / Scene.cpp
#include "Scene.h"
#include "Debug.h"


void Scene::reset(const std::vector<Game::GameObjectList*>& a_objectLists)
{
  // pre-process and split out objects by type
  m_trucks.clear();
  m_cars.clear();
  m_vans.clear();
  m_bikes.clear();
  m_trains.clear();
  m_road.clear();
  m_water.clear();
  m_tracks.clear();
  m_trees.clear();

  m_shrubs.clear();
  m_buildings.clear();
  m_rocks.clear();
  m_logs.clear();
  m_boats.clear();
  m_crocs.clear();

  m_rest.clear();
  for (Game::GameObjectList* objList : a_objectLists)
  {
    if (objList->size() && objList->back().m_type != Game::Player)
      for (unsigned i = 0; i < objList->size(); i++)
      {
        const Game::GameObject& obj = objList->at(i);

        // TODO: switch to a switch

        if (obj.m_type == Game::Truck)
          m_trucks.push_back(obj);
        else if (obj.m_type == Game::Car)
          m_cars.push_back(obj);
        else if (obj.m_type == Game::Van)
          m_vans.push_back(obj);
        else if (obj.m_type == Game::Bike)
          m_bikes.push_back(obj);
        else if (obj.m_type == Game::Train1)
          m_trains.push_back(obj);
        else if (obj.m_type == Game::Train2)
          m_trains.push_back(obj);
        else if (obj.m_type == Game::Train3)
          m_trains.push_back(obj);
        else if (obj.m_type == Game::Train4)
          m_trains.push_back(obj);


        else if (obj.m_type == Game::Road)
          m_road.push_back(obj);
        else if (obj.m_type == Game::Rail)
          m_tracks.push_back(obj);
        else if (obj.m_type == Game::Water)
          m_water.push_back(obj);
        else if (obj.m_type == Game::WaterLane)
          m_water.push_back(obj);


        else if (obj.m_type == Game::Tree)
          m_trees.push_back(obj);


        else if (obj.m_type == Game::Shrub)
          m_shrubs.push_back(obj);
        else if (obj.m_type == Game::Building)
          m_buildings.push_back(obj);
        else if (obj.m_type == Game::Rocks)
          m_rocks.push_back(obj);
        else if (obj.m_type == Game::Log)
          m_logs.push_back(obj);
        else if (obj.m_type == Game::Boat)
          m_boats.push_back(obj);
        else if (obj.m_type == Game::Crocodile)
          m_crocs.push_back(obj);

        /*
    case Game::Ground:        color = 0x47bd37; break;
    case Game::LilyPad:       color = 0x71df1f; break;
    case Game::SteppingStone: color = 0x71df1f; break;
        */

        else
          m_rest.push_back(obj);
      }
  }
  /*
     for (const Game::GameObject& obj : a_carModels)
     {
     m_cars.push_back(obj);
     }
   */


  setDebugValue("cars:",   int(m_cars.size()));
  setDebugValue("bikes:",  int(m_bikes.size()));
  setDebugValue("trucks:", int(m_trucks.size()));
  setDebugValue("vans:",   int(m_vans.size()));
  setDebugValue("trains:", int(m_trains.size()));
  setDebugValue("road:",   int(m_road.size()));
  setDebugValue("tracks:", int(m_tracks.size()));
  setDebugValue("water:",  int(m_water.size()));
  setDebugValue("trees:",  int(m_trees.size()));


}