Ejemplo n.º 1
0
void update_screen(UART_instance_t * this_uart, int deg, float kp, float ki, float kd, float digit, k_value_t k_value)
{
	// Print the pendulum
	print_degrees(this_uart, deg);

	// Print the constants
	set_x(this_uart, 32);
	set_y(this_uart, 16);
	delay();
	char buffer[64];
	sprintf(buffer, "%07.3f\r\n%07.3f\r\n%07.3f", kp, ki, kd);
	UART_polled_tx_string( this_uart, (const uint8_t *)&buffer);

	// Clear the digit block
	erase_block(this_uart, 112, 16, 159, 56);

	// Print the digit increment/decrement
	set_x(this_uart, 112);
	delay();
	char digit_buffer[16];
	sprintf(digit_buffer, "%07.3f", digit);
	if (k_value == KP)
	{
		set_y(this_uart, 16);
	} else if (k_value == KI) {
		set_y(this_uart, 24);
	} else {
		set_y(this_uart, 32);
	}
	UART_polled_tx_string( this_uart, (const uint8_t *)&digit_buffer);
}
Ejemplo n.º 2
0
void SceneGraph::link(TransformInstance child, TransformInstance parent)
{
	unlink(child);

	if (!is_valid(_data.first_child[parent.i]))
	{
		_data.first_child[parent.i] = child;
		_data.parent[child.i] = parent;
	}
	else
	{
		TransformInstance prev = { UINT32_MAX };
		TransformInstance node = _data.first_child[parent.i];
		while (is_valid(node))
		{
			prev = node;
			node = _data.next_sibling[node.i];
		}

		_data.next_sibling[prev.i] = child;

		_data.first_child[child.i].i = UINT32_MAX;
		_data.next_sibling[child.i].i = UINT32_MAX;
		_data.prev_sibling[child.i] = prev;
	}

	Matrix4x4 parent_tr = _data.world[parent.i];
	Matrix4x4 child_tr = _data.world[child.i];
	const Vector3 cs = scale(child_tr);

	Vector3 px = x(parent_tr);
	Vector3 py = y(parent_tr);
	Vector3 pz = z(parent_tr);
	Vector3 cx = x(child_tr);
	Vector3 cy = y(child_tr);
	Vector3 cz = z(child_tr);

	set_x(parent_tr, normalize(px));
	set_y(parent_tr, normalize(py));
	set_z(parent_tr, normalize(pz));
	set_x(child_tr, normalize(cx));
	set_y(child_tr, normalize(cy));
	set_z(child_tr, normalize(cz));

	const Matrix4x4 rel_tr = child_tr * get_inverted(parent_tr);

	_data.local[child.i].position = translation(rel_tr);
	_data.local[child.i].rotation = to_matrix3x3(rel_tr);
	_data.local[child.i].scale = cs;
	_data.parent[child.i] = parent;

	transform(parent_tr, child);
}
Ejemplo n.º 3
0
void setup_screen(UART_instance_t * this_uart)
{
	set_x(this_uart, 128);
	set_y(this_uart, 8);
	delay();
	uint8_t header_buff[] = {"+/-\0"};
	UART_polled_tx_string( this_uart,(const uint8_t *)&header_buff);

	set_x(this_uart, 8);
	set_y(this_uart, 16);
	delay();
	uint8_t label_buff[] = {"Kp: \r\nKi: \r\nKd: \0"};
	UART_polled_tx_string( this_uart,(const uint8_t *)&label_buff);
}
Ejemplo n.º 4
0
void placerBateaux(JOU joueur){
	int tailles_bateaux[5]={1,2,3,3,4};
	int i=0;
	for(i=0;i<5;i++){
		BAT bateau=creerBateau(tailles_bateaux[i]);
		int n_position=0;
		for(n_position=0;n_position<tailles_bateaux[i];n_position++){
				int abscisse=0;
				int ordonnee=0;
				printf("Entrez l'abscisse de la position %d du bateau %d:\n",i+1,n_position+1);
				scanf("%d",&abscisse);
				printf("Entrez l'abscisse de la position %d du bateau %d:\n",i+1,n_position+1);
				scanf("%d",&abscisse);
				POS position=creerPosition(abscisse, ordonnee);
				while(!coordonneeValide(position)){
					printf("Coordonnees invalide...");
					printf("Entrez l'abscisse de la position %d du bateau %d:\n",i+1,n_position+1);
					scanf("%d",&abscisse);
					printf("Entrez l'ordonnee de la position %d du bateau %d:\n",i+1,n_position+1);
					scanf("%d",&ordonnee);
					set_x(position,abscisse);
					set_y(position,ordonnee);
				}/*end while*/
				ajouterPosition(bateau,position);
		}/*end for*/
	ajouterBateau(joueur,bateau);
	}/*end for*/
}
Ejemplo n.º 5
0
// Movimiento de la partida de caza hacia el patch destino
int move_hunters ()
{
	int x = get_x(), y = get_y(), guanacos;

	// Si estoy cazando no me muevo del patch
	if (get_start() == 1)
		return 0;

	// Change the patch
	// Avanzar en x
	if (x != DESTINY[0])
		x = (x>DESTINY[0]) ? x-1:x+1;
	// Avanzar en y
	else if (y != DESTINY[1])
		y = (y>DESTINY[1]) ? y-1:y+1;
	// Llegada al objetivo
	else
		set_arrive(1);
	// Asks guanacos number to the new patch
	add_numGuanacos_message (x,y);
/*	// Recive num of guanacos
	START_INFOGUANACOS_MESSAGE_LOOP
		guanacos = infoGuanacos_message->amount;
	FINISH_INFOGUANACOS_MESSAGE_LOOP
	// si hay guanacos comenzar la caza
	if (guanacos > 0)
		set_start(1);
	// Sino y se ha llegado al destino, acabar la caza
	else if (get_arrive() == 1 )
		set_end(1);*/
	set_x(x);
	set_y(y);
	printf("movido\n");
	return 0;
}
Ejemplo n.º 6
0
void ObjectManager::create_ships(PlayerState& player_state)
{
    for (int i = 1; i <= NUM_OF_POSSIBLE_PLAYERS; i++) {
        if (player_state.energy_max(i)) {

            std::string name = "Player " + std::to_string(i);

            int s = player_state.score(i);
            int e = player_state.energy_max(i);
            player_state.set_energy(i, e);  // reset energy to max

            ObjIndex player_index = Object::parse_player_index(i);
            sdlc::Surface& gfx = obj[player_index];
            sdlc::Surface& hit_gfx = obj_hit[player_index];

            auto w1 = create_main_weapon(i, player_state);
            auto w2 = create_extra_weapon(i, player_state);

            KeySet keyset(i);   // For now we don't set custom keys

            auto new_ship = std::make_shared<Ship>(name, e, s, gfx, hit_gfx, w1, w2, keyset);

            new_ship->set_locked_to_screen(false);
            new_ship->set_x((float)(213 * i - new_ship->width()));
            new_ship->set_y(480);
            new_ship->set_vel(0, -200.0f);
            queue.push_back(new_ship);
        }
    }
}
Ejemplo n.º 7
0
 // reset vector from rectangular coordinates if form is
 // RECT (the default) or else from polar coordinates if
 // form is POL
 void Vector:: reset(double n1, double n2, Mode form)
 {
     mode = form;
     if (form == RECT)
      {
          x = n1;
          y = n2;
          //set_mag();
          //set_ang();
     }
     else if (form == POL)
     {
          double mag = n1;
          double ang = n2 / Rad_to_deg;
          set_x(mag,ang);
          set_y(mag,ang);
     }
     else
     {
          cout << "Incorrect 3rd argument to Vector() -- ";
          cout << "vector set to 0\n";
          x = y = 0.0;
          mode = RECT;
     }
 }
Ejemplo n.º 8
0
Surface& Surface::operator=(const Surface& rSurf)
{
    _pMaterialNext=0;
    _pMaterialPrev=0;

    set_type(rSurf.type());
    set_conic(rSurf.conic());
    set_radius_curvature(rSurf.radius_curvature());

    set_R4(rSurf.R4());
    set_R6(rSurf.R6());
    set_R8(rSurf.R8());
    set_R10(rSurf.R10());

    set_comment(rSurf.comment());

    set_x(rSurf.x());
    set_y(rSurf.y());
    set_z(rSurf.z());

    set_diameter(rSurf.diameter());
    set_auto_diameter(rSurf.get_auto_diameter());

    set_inner_diameter(rSurf.inner_diameter());
    set_auto_inner_diameter(rSurf.get_auto_inner_diameter());

    return *this;
}
Ejemplo n.º 9
0
  Thyra::ModelEvaluatorBase::InArgs<double>
  init_nominal_values_(
      const std::shared_ptr<const Tpetra::Vector<double,int,int>> & x
      )
  {
    const auto f_params = f_->get_scalar_parameters();
    const auto jac_params = jac_->get_scalar_parameters();
    const auto dfdp_params = dfdp_->get_scalar_parameters();

    std::map<std::string, double> all_params;
    all_params.insert(f_params.begin(), f_params.end());
    all_params.insert(jac_params.begin(), jac_params.end());
    all_params.insert(dfdp_params.begin(), dfdp_params.end());

    auto p_init = Thyra::createMember(this->get_p_space(0));
    int k = 0;
    for (auto it = all_params.begin(); it != all_params.end(); ++it) {
      Thyra::set_ele(k, it->second, p_init());
      k++;
    }

    auto nominal_values = this->createInArgs();
    const Teuchos::RCP<const Tpetra::Vector<double,int,int>> initial_x =
      Teuchos::rcp(x);
    const auto xxx = Thyra::createConstVector(initial_x, space_);
    nominal_values.set_p(0, p_init);
    nominal_values.set_x(xxx);

    return nominal_values;
  }
Ejemplo n.º 10
0
	void Vector::set(double n1, double n2, char form)
	{
		mode = form;
		if ( form == 'r')
		{
			x = n1;
			y = n2;
			set_mag();
			set_ang();
		}
		else if (form = 'p')
		{
			mag = n1;
			ang = n2 / Rad_to_deg;
			set_x();
			set_y();
		}
		else
		{
			cout << "Incorrect form\n";
			cout << "vector set to 0\n";
			x = y = mag = ang = 0.0;
			mode = 'r';
		}
	}
 //! Wipe out stored data.
 void clear()
 {
    set_x(Teuchos::null);
    set_dxdt(Teuchos::null);
    set_f(Teuchos::null);
    set_A(Teuchos::null);
 }
Ejemplo n.º 12
0
// construct vector from rectangular coordinates if form is r
// (the default) or else from polar coordinates if form is p
Vector::Vector(double n1, double n2, Mode form)
{
    mode = form;
    if (form == RECT)
    {
        x = n1;
        y = n2;
        set_mag();
        set_ang();
    }
    else if (form == POL)
    {
        mag = n1;
        ang = n2 / Rad_to_deg;
        set_x();
        set_y();
    }
    else
    {
        cout << "Incorrect 3rd argument to Vector() -- ";
        cout << "vector set to 0\n";
        x = y = mag = ang = 0.0;
        mode = RECT;
    }
}
Ejemplo n.º 13
0
void BolsaDinero::hit(Actor *who, int damage)
{
	switch (who->get_team())
	{
	    case TEAM_OSO:
	    	am->del(this);
	    	break;
	    case TEAM_COMIDA:
	    case TEAM_AGUA:
	    case TEAM_VENENO:
	    case TEAM_HORMIGAS_ROJAS:
		case TEAM_HORMIGAS_VERDES:
		case TEAM_RANA:
		case TEAM_SCORE:
		case TEAM_BOLSA_DINERO:
		case TEAM_HORMIGUERO:
			set_x(Game::rnd(0,Game::gfx_w-get_w()));
            set_y(Game::rnd(0,Game::gfx_h-get_h()));
		  	break;

		default:
			break;
	}

}
Ejemplo n.º 14
0
bool GuiWindow::mousemove(int x, int y) {
    if (mouse_is_down && moving_valid) {
        set_x(x - distance_x);
        set_y(y - distance_y);
    }

    return true;
}
Ejemplo n.º 15
0
vector::Vector::Vector(double n1, double n2, Mode form)
{
	Vector::mode = form;
	if (form == RECT) {
		set_x(n1);
		set_y(n2);
	} else if (form == POL) {
		int x_ = n1 * cos (n2);
		int y_ = n1 * sin (n2);
		set_x(x_);
		set_y(y_);
	} else {
		std::cout << "Incorrect 3d arg param" << std::endl;
		vector::Vector();
	}

}
Ejemplo n.º 16
0
circle::circle(pos p, double radius, double radiussize, gradient grad, int bt)
    : shape(bt), gradient_(grad)
{
    set_x(p.get_x());
    set_y(p.get_y());
    set_z(p.get_z());
    set_radius(radius);
    set_radiussize(radiussize);
}
Ejemplo n.º 17
0
void Particle::update(const Timer& timer)
{
    // Update position
    set_x(x() + (x_vel()  * timer.frame_time()));
    set_y(y() + (y_vel()  * timer.frame_time()));

    // Update alpha
    set_alpha(alpha() - (fade_speed() * timer.frame_time()));
}
Ejemplo n.º 18
0
void TMaps::SerialiseRespPoints(Epsilon5::World& world) {
    for (auto i = RespPoints.begin(); i != RespPoints.end(); i++) {
        auto point = world.add_resp_points();
        point->set_x(i->X);
        point->set_y(i->Y);
        point->set_is_main(i->IsMain);
        point->set_team(i->Team);
    }
}
Ejemplo n.º 19
0
void CreateBuildingCommand::setParams()
{
    auto request = m_requestMessage->MutableExtension(CreateBuildingRequest::id);
    
    request->set_instanceid(m_instanceId);
    request->set_buildingid(m_buildingId);
    request->set_x(m_x);
    request->set_y(m_y);
}
Ejemplo n.º 20
0
Paleta::Paleta (Almacen &almacen)
{
  piel = new Suelo (this, almacen, 2);
  set_actor_graphic (piel);
  setCodigo (Nombres::paleta);
  set_x (0);
  set_y (SCREEN_H - 70);
  set_is_detected (true);
  set_collision_method (CollisionManager::PP_COLLISION);
};
Ejemplo n.º 21
0
Loro::Loro (Almacen &almacen):
ControllableActor (),
kboard (new Keyboard())
{
    // ¡Cuidado! Esto falla si en el almacén no existe el bitmap que se pide.
    // Animación de la derecha.
    izquierda = new Sprite(this);
    izquierda->add_frame(almacen.get_bitmap("sprite_042"), 0, 13, 10);
    izquierda->add_frame(almacen.get_bitmap("sprite_043"), 0,  0, 10);
    izquierda->add_frame(almacen.get_bitmap("sprite_044"), 0,  3, 10);
    izquierda->setMirror(true);

    // Animación de la izquierda.
    derecha = new Sprite(this);
    derecha->add_frame(almacen.get_bitmap("sprite_042"), 0, 13, 10);
    derecha->add_frame(almacen.get_bitmap("sprite_043"), 0,  0, 10);
    derecha->add_frame(almacen.get_bitmap("sprite_044"), 0,  3, 10);
    derecha->setMirror(false);

    // Animación de giro.
    giro_der = new Sprite(this);
    giro_der->add_frame(almacen.get_bitmap("pre2_338"), 10, 0, 5);
    giro_der->setMirror (true);

    giro_izq = new Sprite(this);
    giro_izq->add_frame(almacen.get_bitmap("pre2_338"), 10, 0, 5);
    giro_izq->setMirror (false);

    setCodigo (Nombres::herny);
    set_x(SCREEN_W/2);
    set_y(SCREEN_H/2);
    set_is_detected (true);
    set_collision_method(CollisionManager::PP_COLLISION);
    set_wh (36,26);

    // Animación de inicio.
    estado = FLOTANDO_DER;
    set_actor_graphic (derecha);

    // Se crea el control necesario para las acciones del loro.
    control = new Control ();
    control->add_action_name (LEFT,  "Izquierda");
    control->add_action_name (RIGHT, "Derecha");
    control->add_action_name (UP,    "Arriba");
    control->add_action_name (DOWN,  "Abajo");
    control->add_action_name (JUMP,  "Saltar");
    control->set_owner(this);

    // Se va a usar el teclado como único periférico para el loro.
    control->set_actionperipheral (UP,    kboard,  KEY_UP,    Peripheral::ON_PRESSING);
    control->set_actionperipheral (DOWN,  kboard,  KEY_DOWN,  Peripheral::ON_PRESSING);
    control->set_actionperipheral (LEFT,  kboard,  KEY_LEFT,  Peripheral::ON_PRESSING);
    control->set_actionperipheral (RIGHT, kboard,  KEY_RIGHT, Peripheral::ON_PRESSING);
    control->set_actionperipheral (JUMP,  kboard,  KEY_A,     Peripheral::ON_PRESS);
};
Ejemplo n.º 22
0
void CVector::set_item(int iIndex, float fValue)
{
	if (iIndex == 0)
		return set_x(fValue);
	else if (iIndex == 1)
		return set_y(fValue);
	else if (iIndex == 2)
		return set_z(fValue);

	BOOST_RAISE_EXCEPTION(PyExc_IndexError, "Index out of range.")
}
Ejemplo n.º 23
0
line::line(pos p, pos p2, double size, gradient grad, int blending_type)
    : shape(blending_type)
{
    set_x(p.get_x());
    set_y(p.get_y());
    set_z(p.get_z());
    set_x2(p2.get_x());
    set_y2(p2.get_y());
    set_z2(p2.get_z());
    set_size(size);
    set_gradient(grad);
}
Ejemplo n.º 24
0
/**
 * \brief Updates the position.
 */
void FollowMovement::update() {

  if (entity_followed == NULL) {
    finished = true;
    return;
  }

  if (entity_followed->is_being_removed()) {
    finished = true;
    RefCountable::unref(entity_followed);
    entity_followed = NULL;
  }
  else {

    int next_x = entity_followed->get_x() + x;
    int next_y = entity_followed->get_y() + y;

    int dx = next_x - get_x();
    int dy = next_y - get_y();

    if (!are_obstacles_ignored()) {

      if (!finished && (dx != 0 || dy != 0)) {

        if (!test_collision_with_obstacles(dx, dy)) {
          set_x(next_x);
          set_y(next_y);
        }
        else {
          finished = true;
          notify_obstacle_reached();
        }
      }
    }
    else {
      set_x(next_x);
      set_y(next_y);
    }
  }
}
Ejemplo n.º 25
0
void Point_3D::move(Point_3D* origin)
{
	//Mise à jour de l'abcisse
	set_x(get_x()-origin->get_x());
	//Mise à jour de l'ordonnée
	set_y(get_y()-origin->get_y());
	//Mise à jour de la profondeur
	set_z(get_z()-origin->get_z());
	//Mise à jour de l'abcisse d'origine
	dbl_x_origin-=origin->get_x();
	//Mise à jour de l'ordonnée d'origine
	dbl_y_origin-=origin->get_y();
	//Mise à jour de la profondeur d'origin
	dbl_z_origin-=origin->get_z();
}
Ejemplo n.º 26
0
void Point_3D::scale(int coef)
{
	//Mise à jour de l'abcisse
	set_x(coef*get_x());
	//Mise à jour de l'ordonnée
	set_y(coef*get_y());
	//Mise à jour de la profondeur
	set_z(coef*get_z());
	//Mise à jour de l'abcisse d'origine
	dbl_x_origin=dbl_x_origin*coef;
	//Mise à jour de l'ordonnée d'origine
	dbl_y_origin=dbl_y_origin*coef;
	//Mise à jour de la profondeur d'origin
	dbl_z_origin=dbl_z_origin*coef;
}
Ejemplo n.º 27
0
  Thyra::ModelEvaluatorBase::InArgs<double>
  init_nominal_values_(
      const Teuchos::RCP<const Tpetra::Vector<double,int,int>> & x,
      const double alpha0
      )
  {
    auto p_init = Thyra::createMember(this->get_p_space(0));
    Thyra::set_ele(0, alpha0, p_init());

    const auto xxx = Thyra::createConstVector(x, space_);

    auto nominal_values = this->createInArgs();
    nominal_values.set_p(0, p_init);
    nominal_values.set_x(xxx);

    return nominal_values;
  }
Ejemplo n.º 28
0
void vector::Vector::reset(double n1, double n2, Mode form)
{
	mode = form;
	if (form == RECT) {
		x = n1;
		y = n2;
	} else if (form == POL){
		int x_ = n1 * cos (n2);
		int y_ = n1 * sin (n2);
		set_x(x_);
		set_y(y_);
	} else {
		std::cout << "Incorrect 3d arg" << std::endl;
		x = y = 0.0;
		mode = RECT;
	}
}
GuiFPSWidget::GuiFPSWidget() : GuiContext(0,0)
{
    label = new GuiLabel(FontManager::font("small"),"100 FPS",0,0,1.0,true);
    background = new GuiColorRect(0,0,label->get_width()+10,label->get_height()+10);
    background->set_rgba(0.0,0.0,0.0,0.6);

    add(background);
    add(label);

    set_width(background->get_width());
    set_height(background->get_height());

    set_x(SCREEN_WIDTH/2-width/2);
    set_y(-SCREEN_HEIGHT/2+height/2);

    this->ticksTillUpdate = 0;
    this->className = "GuiFPSWidget";
}
Ejemplo n.º 30
0
int main(void) {
    char tictactoe[SIZE][SIZE];
    for(int i=0;i<SIZE; ++i)
        for(int j=0; j<SIZE; ++j)
            tictactoe[i][j] = NO_GLYPH;
    
    set_x(tictactoe, 1, 1);
    set_o(tictactoe, 2, 1);

    for(int i=0; i < SIZE; ++i) {
        for(int j=0; j < SIZE; ++j)
            printf("%c ", tictactoe[i][j]);
        printf("\n");
    }


    return 0;
}