FirstLevel::FirstLevel(sf::RenderWindow* a) : GameState(a), enemy_time_delay(10.00f)
{
    //create the factory
    factory = new GameFactory(a);
    world = factory->get_world();
    
    //create walls
    //Wall* left_wall = factory->create_wall(0, 0, 10, 150);
    //add_model(left_wall);
        
    //create the main player
    current_player = factory->create_player();
    add_model(current_player);
    
    //create the controller
    player_controller = new Controller(current_player, factory, &models);
    
    //add the music
    MusicTrack* music_track = factory->create_music_track();
    add_model(music_track);
    
    //create the world
    World* w = factory->create_world();
    add_model(w);
    
    //now add a powerup
    PowerUp* pu = factory->create_powerup();
    add_model(pu);
}
static void
handle_new_source_plugin (MexTrackerPlugin *self, GrlMediaPlugin *plugin)
{
  GrlSupportedOps ops;
  GrlMetadataSource *meta = GRL_METADATA_SOURCE (plugin);
  const char *id;

  id = grl_media_plugin_get_id (plugin);
  if (g_strcmp0 (id,"grl-tracker") != 0)
    {
      MEX_DEBUG ("Attempting to use the media explorer tracker plugin "
                 "but grilo tracker plugin not loaded. "
                 "You may not see any content!");
      return;
    }

  ops = grl_metadata_source_supported_operations (meta);
  if ((ops & GRL_OP_QUERY) == 0)
    return;

  grl_media_source_notify_change_start (GRL_MEDIA_SOURCE (plugin), NULL);

  add_model (self, plugin, MEX_TRACKER_CATEGORY_VIDEO);
  add_model (self, plugin, MEX_TRACKER_CATEGORY_IMAGE);
  add_model (self, plugin, MEX_TRACKER_CATEGORY_MUSIC);
}
static void
tree_selection_model_set_property (GObject *object,
                                   guint property_id,
                                   const GValue *value,
                                   GParamSpec *pspec)
{
	ESelectionModel *esm = E_SELECTION_MODEL (object);
	ETreeSelectionModel *etsm = E_TREE_SELECTION_MODEL (object);

	switch (property_id) {
	case PROP_CURSOR_ROW:
		e_selection_model_do_something (
			esm, g_value_get_int (value),
			etsm->priv->cursor_col, 0);
		break;

	case PROP_CURSOR_COL:
		e_selection_model_do_something (
			esm, get_cursor_row (etsm),
			g_value_get_int (value), 0);
		break;

	case PROP_MODEL:
		drop_model (etsm);
		add_model (etsm, E_TREE_MODEL (g_value_get_object (value)));
		break;

	case PROP_ETTA:
		etsm->priv->etta =
			E_TREE_TABLE_ADAPTER (g_value_get_object (value));
		break;
	}
}
  DynamicRegressionStateModel::DynamicRegressionStateModel(
      const DynamicRegressionStateModel &rhs)
      : StateModel(rhs),
        CompositeParamPolicy(rhs),
        NullDataPolicy(rhs),
        PriorPolicy(rhs),
        xdim_(rhs.xdim_),
        initial_state_mean_(rhs.initial_state_mean_),
        initial_state_variance_(rhs.initial_state_variance_),
        X_(rhs.X_),
        transition_matrix_(rhs.transition_matrix_)
  {
    coefficient_transition_model_.reserve(xdim_);
    std::vector<Ptr<UnivParams> > diagonal_variances_;
    diagonal_variances_.reserve(xdim_);
    for(int i = 0; i < xdim_; ++i){
      coefficient_transition_model_.push_back(
          rhs.coefficient_transition_model_[i]->clone());
      add_model(coefficient_transition_model_.back());
      diagonal_variances_.push_back(
          coefficient_transition_model_.back()->Sigsq_prm());
    }

    transition_variance_matrix_.reset(new UpperLeftDiagonalMatrix(
        diagonal_variances_,
        diagonal_variances_.size()));
  }
Exemple #5
0
void stage4_start() {
	init_stage3d(&bgcontext);
	
	bgcontext.cx[2] = -10000;
	bgcontext.cv[2] = 19.7;
	bgcontext.crot[0] = 80;
	
	// for testing
// 	bgcontext.cx[1] = 2000;
// 	bgcontext.cx[2] = 130;
// 	bgcontext.cv[1] = 10;
// 	bgcontext.crot[0] = 80;
	
	add_model(&bgcontext, stage4_lake_draw, stage4_lake_pos);
	add_model(&bgcontext, stage4_fountain_draw, stage4_fountain_pos);
	add_model(&bgcontext, stage4_corridor_draw, stage4_corridor_pos);
}
Exemple #6
0
/**
 * Add a model, the corresponding model constraints and the matching
 * condition to the next model.
 *
 * @param model model
 * @param mc matching condition to the next higher model
 * @param constraints vector of model constraints
 */
void RGFlow<Two_scale>::add_model(Two_scale_model* model,
                                  Matching<Two_scale>* mc,
                                  const std::vector<Constraint<Two_scale>*>& constraints)
{
   // create vector of downward constraints
   std::vector<Constraint<Two_scale>*> downward_constraints;
   std::reverse_copy(constraints.begin(), constraints.end(),
                     std::back_inserter(downward_constraints));

   add_model(model, mc, constraints, downward_constraints);
}
static void
handle_new_source (MexBliptvPlugin *self, GrlSource *source)
{
  const char *id;

  id = grl_source_get_id (source);
  if (g_strcmp0 (id,"grl-bliptv") != 0)
    return;

  add_model (self, source);
}
Exemple #8
0
int ColInfo::add_joint_pair(Joint* j1, Joint* j2, SceneGraph* sg)
{
    if(Pair(j1, j2)) return 0;
    ColModel* m1, *m2;
    m1 = Model(j1);
    if(!m1)
    {
        m1 = new ColModel(j1, sg);
        add_model(m1);
    }
    m2 = Model(j2);
    if(!m2)
    {
        m2 = new ColModel(j2, sg);
        add_model(m2);
    }
    if(m1->n_triangle == 0 || m2->n_triangle == 0) return -1;
    if( (j1->parent == j2 && j1->n_dof == 0) || (j2->parent == j1 && j2->n_dof == 0) )
        return 0;
    cerr << "add joint pair: " << j1->name << ", " << j2->name << endl;
    ColPair* p = new ColPair(m1, m2);
    add_pair(p);
    return 0;
}
Exemple #9
0
ColModel* ColInfo::AddModel(Joint* jref, SceneGraph* sg)
{
    ColModel* ret = Model(jref);
    if(!ret)
    {
        ret = new ColModel(jref, sg);
        if(ret->n_triangle > 0)
            add_model(ret);
        else
        {
            delete ret;
            ret = 0;
        }
    }
    return ret;
}
static void
etsm_set_property (GObject *object,
                   guint property_id,
                   const GValue *value,
                   GParamSpec *pspec)
{
	ETableSelectionModel *etsm = E_TABLE_SELECTION_MODEL (object);

	switch (property_id) {
	case PROP_MODEL:
		drop_model (etsm);
		add_model (etsm, g_value_get_object (value) ? E_TABLE_MODEL (g_value_get_object (value)) : NULL);
		break;
	case PROP_HEADER:
		etsm->eth = E_TABLE_HEADER (g_value_get_object (value));
		break;
	}
}
void FirstLevel::handle_step()
{
    if(current_player->is_dead())
        finished();
    
    if(enemy_time_delay < new_enemy_timer.GetElapsedTime())
    {
        Enemy* enemy;
        enemy = factory->create_enemy();
        enemy->set_target(current_player);
        add_model(enemy);
        new_enemy_timer.Reset();
        if(enemy_time_delay > 1.00f)
            enemy_time_delay = enemy_time_delay - 1.00f;
        
    }
    GameState::handle_step();
}
Exemple #12
0
/**
 * Add a model and the corresponding model constraints.  With this
 * function the user can use different contraints for the up and down
 * running of the model tower.
 *
 * @param model model
 * @param upwards_constraints model constraints for running up
 * @param downwards_constraints model constraints for running down
 */
void RGFlow<Two_scale>::add_model(Two_scale_model* model,
                                  const std::vector<Constraint<Two_scale>*>& upwards_constraints,
                                  const std::vector<Constraint<Two_scale>*>& downwards_constraints)
{
   add_model(model, NULL, upwards_constraints, downwards_constraints);
}
Exemple #13
0
/**
 * Add a model and the corresponding model constraints.  Note that the
 * order of the model registration is important: Models that are added
 * later are assumed to be valid at a higher scale.  The same is true
 * for the constraints: they are assumed to be ordered from low to
 * high energies.
 *
 * @param model model
 * @param constraints vector of model constraints
 */
void RGFlow<Two_scale>::add_model(Two_scale_model* model,
                                  const std::vector<Constraint<Two_scale>*>& constraints)
{
   add_model(model, NULL, constraints);
}
Exemple #14
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowSmd)
{
	FileSystem fileSystem("../../Resources");
	Console console(fileSystem, false);
	
	ResourceManager resourceManager(fileSystem, console);

	InputDevice input(console);

	Window window("Void", console, input, resourceManager, fileSystem, 1280, 720, true, false);
	//Window window("Void", console, input, resourceManager, fileSystem);
	if(window.Initialise()) return 0;

	ConsoleEvent shouldQuitConsole(console, input, "Game.Quit");
	input.addDefaultBinding(Key::Q, shouldQuitConsole);
	input.addDefaultBinding(Key::Escape, shouldQuitConsole);

	ConsoleEvent cameraForward(console, input, "Camera.Move.Forward");
	input.addDefaultBinding(Key::W, cameraForward);
	ConsoleEvent cameraBackward(console, input, "Camera.Move.Backward");
	input.addDefaultBinding(Key::S, cameraBackward);
	ConsoleEvent cameraLeft(console, input, "Camera.Move.Left");
	input.addDefaultBinding(Key::A, cameraLeft);
	ConsoleEvent cameraRight(console, input, "Camera.Move.Right");
	input.addDefaultBinding(Key::D, cameraRight);
	ConsoleEvent cameraUp(console, input, "Camera.Move.Up");
	input.addDefaultBinding(Key::Space, cameraUp);
	ConsoleEvent cameraDown(console, input, "Camera.Move.Down");
	input.addDefaultBinding(Key::LCtrl, cameraDown);
	ConsoleEvent cameraSprint(console, input, "Camera.Move.Sprint");
	input.addDefaultBinding(Key::LShift, cameraSprint);

	window.GetGraphicsDevice().getRenderer3D().setSkybox(resourceManager.getResourceReference<TextureResource>("[Texture] Clouds.dds"));

	Camera &camera = window.GetGraphicsDevice().getRenderer3D().getCamera();
	camera.rotateY(Math::DegreesToRadians(90));
	camera.setPosition(-1100.0f, -170.0f, 0.0f);

	std::vector<PointLight> lights;

	ResourceReference<ModelResource> visibleLion = resourceManager.getResourceReference<ModelResource>("[Model] Lion.smdf");

	std::vector<ResourceReference<MaterialResource>> materials;
#define add_model(x) materials.push_back(resourceManager.getResourceReference<MaterialResource>("[Material] " x ".smtf"))
	add_model("Lion");add_model("Lionbackground"); add_model("VaseRound"); add_model("Ceiling");
	add_model("ColumnA"); add_model("ColumnB"); add_model("ColumnC"); add_model("Floor"); add_model("FabricGreen");
	add_model("FabricBlue"); add_model("FabricRed"); add_model("CurtainBlue"); add_model("CurtainRed");
	add_model("CurtainGreen"); add_model("VaseHanging"); add_model("Vase"); add_model("Bricks");
	add_model("Arch"); add_model("Details"); add_model("Roof");	add_model("VasePlant");
	add_model("Chain"); add_model("Thorn");add_model("Vase");

	Timer gameTime;

	bool isMousePressed = false;
	int oldMouseX = 0;
	int oldMouseY = 0;

	for(;;)
	{
		uint64 frameTime = gameTime.getElapsedReset();
		float frameSeconds = frameTime / 1000.0f;

		resourceManager.Update();
		console.update();

		if(window.Update()) break;
		input.Update();

		if(shouldQuitConsole.isPress()) break;

		if(isMousePressed != input.IsKeyDown(Key::LButton))
		{
			isMousePressed = !isMousePressed;
			if(isMousePressed)
			{
				window.setMouseClipping(true);
				oldMouseX = input.GetMouseXPositionAbsolute();
				oldMouseY = input.GetMouseYPositionAbsolute();
				window.setMouseVisibility(true);
			}
			else
			{
				window.setMouseClipping(false);
				window.SetMousePosition(oldMouseX, oldMouseY);
				window.setMouseVisibility(false);
			}
		}

		if(isMousePressed)
		{
			camera.rotateY(Math::DegreesToRadians(input.GetMouseXPositionRelative()));
			camera.rotateX(Math::DegreesToRadians(input.GetMouseYPositionRelative()));
		}

		float distance = 100.0f * frameSeconds;
		if(cameraSprint.isHeld()) distance *= 6;

		if(cameraForward.isHeld()) camera.moveX(distance);
		if(cameraBackward.isHeld()) camera.moveX(-distance);
		if(cameraRight.isHeld()) camera.moveZ(distance);
		if(cameraLeft.isHeld()) camera.moveZ(-distance);
		if(cameraUp.isHeld()) camera.moveY(distance);
		if(cameraDown.isHeld()) camera.moveY(-distance);

		visibleLion->Render();

		if(resourceManager.isLoading())
		{
			if(lights.empty())
				fillLightsGrid(lights, window);
		}
		else if(!lights.empty())
			lights.clear();

		if(input.IsKeyPress(Key::Num1))
			fillLightsGrid(lights, window);

		Vector3 lightChange;
		if(input.IsKeyDown(Key::Up)) lightChange.y += distance;
		if(input.IsKeyDown(Key::Down)) lightChange.y -= distance;
		if(input.IsKeyDown(Key::Left)) lightChange.x += distance;
		if(input.IsKeyDown(Key::Right)) lightChange.x -= distance;

		if(lightChange != Vector3::Zero)
		{
			for(PointLight &light : lights)
				light.setPosition(light.getPosition() + lightChange);
		}
			
		if(window.Render()) break;
	}

	return 0;
}