Example #1
0
void Game_Vehicle::LoadSystemSettings() {
	switch (type) {
		case None:
			break;
		case Boat:
			SetSpriteName(Data::system.boat_name);
			SetSpriteIndex(Data::system.boat_index);
			bgm = Data::system.boat_music;
			SetMapId(Data::treemap.start.boat_map_id);
			SetX(Data::treemap.start.boat_x);
			SetY(Data::treemap.start.boat_y);
			break;
		case Ship:
			SetSpriteName(Data::system.ship_name);
			SetSpriteIndex(Data::system.ship_index);
			bgm = Data::system.ship_music;
			SetMapId(Data::treemap.start.ship_map_id);
			SetX(Data::treemap.start.ship_x);
			SetY(Data::treemap.start.ship_y);
			break;
		case Airship:
			SetSpriteName(Data::system.airship_name);
			SetSpriteIndex(Data::system.airship_index);
			bgm = Data::system.airship_music;
			SetMapId(Data::treemap.start.airship_map_id);
			SetX(Data::treemap.start.airship_x);
			SetY(Data::treemap.start.airship_y);
			break;
	}
}
Example #2
0
void Plane::Shoot(Double speed, const Point2i& target)
{
  MSG_DEBUG("weapon.shoot", "Plane Shoot");
  nb_dropped_bombs = 0;
  last_dropped_bomb = NULL;

  cible_x = target.x;
  SetY(0);
  distance_to_release = (int)(speed * sqrt(TWO * (GetY() + target.y)));

  Point2d speed_vector;
  if (ActiveCharacter().GetDirection() == DIRECTION_RIGHT) {
    image->SetFlipped(false);
    speed_vector.SetValues(speed, 0);
    SetX(ONE - Double(image->GetWidth()));
    //distance_to_release -= obus_dx;
   if (distance_to_release > cible_x)
     distance_to_release = 0;

  } else {
    image->SetFlipped(true);
    speed_vector.SetValues(-speed, 0) ;
    SetX(Double(GetWorld().GetWidth() - 1));
    //distance_to_release += obus_dx;
    if (distance_to_release > GetWorld().GetWidth()-cible_x - obus_dx)
      distance_to_release = 0;
  }

  SetSpeedXY(speed_vector);

  Camera::GetInstance()->FollowObject(this);

  ObjectsList::GetRef().AddObject(this);
}
Example #3
0
NTL_START_IMPL


long IterIrredTest(const GF2X& f)
{
   long df = deg(f);

   if (df <= 0) return 0;
   if (df == 1) return 1;

   GF2XModulus F;

   build(F, f);
   
   GF2X h;
   SetX(h);
   SqrMod(h, h, F);

   long i, d, limit, limit_sqr;
   GF2X g, X, t, prod;


   SetX(X);

   i = 0;
   g = h;
   d = 1;
   limit = 2;
   limit_sqr = limit*limit;

   set(prod);

   while (2*d <= df) {
      add(t, g, X);
      MulMod(prod, prod, t, F);
      i++;
      if (i == limit_sqr) {
         GCD(t, f, prod);
         if (!IsOne(t)) return 0;

         set(prod);
         limit++;
         limit_sqr = limit*limit;
         i = 0;
      }

      d = d + 1;
      if (2*d <= deg(f)) {
         SqrMod(g, g, F);
      }
   }

   if (i > 0) {
      GCD(t, f, prod);
      if (!IsOne(t)) return 0;
   }

   return 1;
}
Example #4
0
void Window_Base::UpdateMovement() {
	if (!IsMovementActive()) {
		return;
	}
	current_frame++;
	if (IsMovementActive()) {
		SetX(old_position[0] + (new_position[0] - old_position[0]) * current_frame / total_frames);
		SetY(old_position[1] + (new_position[1] - old_position[1]) * current_frame / total_frames);
	} else {
		SetX(new_position[0]);
		SetY(new_position[1]);
	}
}
Example #5
0
void NaGeVector3D::operator /= (const double &scalar)
{
	if(!IsNull())
	{
		SetX(GetX()/scalar);
		SetY(GetY()/scalar);
		SetZ(GetZ()/scalar);
	}
	else
	{
		SetX(0);
		SetY(0);
		SetZ(0);
	}
}
Example #6
0
void Game_Character::MoveDownLeft() {
	if (!IsDirectionFixed()) {
		if (GetDirection() % 2) {
			TurnLeft();
		} else {
			TurnDown();
		}
	}

	if (jumping) {
		jump_plus_x--;
		jump_plus_y++;
		return;
	}

	if ((IsPassable(GetX(), GetY(), RPG::EventPage::Direction_left)
		&& IsPassable(GetX() - 1, GetY(), RPG::EventPage::Direction_down))
		|| (IsPassable(GetX(), GetY(), RPG::EventPage::Direction_down)
		&& IsPassable(GetX(), GetY() + 1, RPG::EventPage::Direction_left))) {
			SetX(GetX() - 1);
			SetY(GetY() + 1);
			BeginMove();
			stop_count = 0;
			move_failed = false;
	}
}
Example #7
0
int Game_Character::EndJump(const RPG::MoveRoute* current_route, int current_index) {
	jumping = false;

	if (!IsLandable(jump_x + jump_plus_x, jump_y + jump_plus_y)) {
		// Reset to begin jump command and try again...
		move_failed = true;

		if (current_route->skippable) {
			return current_index;
		}

		return jump_index;
	}

	SetX(jump_x + jump_plus_x);
	SetY(jump_y + jump_plus_y);

	//TODO: C++11 got round() function defined in math.h
	float distance = sqrt((float)(jump_plus_x * jump_plus_x + jump_plus_y * jump_plus_y));
	if (distance >= floor(distance) + 0.5) distance = ceil(distance);
	else distance = floor(distance);

	jump_peak = 10 + (int)distance - GetMoveSpeed();
	move_count = jump_peak * 2;

	stop_count = 0;
	move_failed = false;

	return current_index;
}
bool
ThreeSliceAttributes::CopyAttributes(const AttributeGroup *atts)
{
    if(atts->TypeName() == "PointAttributes")
    {
        if (interactive)
        {
            const PointAttributes *tmp = (const PointAttributes *)atts;
            const double *xyz = tmp->GetPoint();
            SetX(xyz[0]);
            SetY(xyz[1]);
            SetZ(xyz[2]);
            return true;
        }
    }

    if(TypeName() != atts->TypeName())
        return false;

    // Call assignment operator.
    const ThreeSliceAttributes *tmp = (const ThreeSliceAttributes *)atts;
    *this = *tmp;

    return true;
}
Example #9
0
//Update event
void testEntity::OnUpdate()
{
    sinVal+= sinSpeed;
    SetX(startX+sin(sinVal)*100);
    SetY(startY);
    angle+=3;
}
Example #10
0
OpponentMisterKuba::OpponentMisterKuba( int x_, int y_ )
    : Opponent( "misterkuba" )
    , ti( 1 ) {

    SetX( x_ );
    SetY( y_ );
}
Example #11
0
void OpponentMisterKuba::Update() {
    if( ti.GetTime() ) {
        SetX( GetX() + 10 );

        ti.Update();
    }
}
Character::Character(std::string fromString) {
    std::vector<std::string> tokens = utils::Tokenfy(fromString, '|');
    if (tokens[0] == "PLAYER_OBJECT") {
        SetName(tokens[57]);
        SetLastname(tokens[58]);
        SetRace(tokens[59]);
        SetGender(tokens[60]);
        SetFace(tokens[61]);
        SetSkin(tokens[62]);
        SetZone(tokens[63]);
        SetLevel(std::stoi(tokens[64]));
        SetHp(std::stoi(tokens[65]));
        SetMaxHp(std::stoi(tokens[66]));
        SetBp(std::stoi(tokens[67]));
        SetMaxBp(std::stoi(tokens[68]));
        SetMp(std::stoi(tokens[69]));
        SetMaxMp(std::stoi(tokens[70]));
        SetEp(std::stoi(tokens[71]));
        SetMaxEp(std::stoi(tokens[72]));
        SetStrength(std::stoi(tokens[73]));
        SetConstitution(std::stoi(tokens[74]));
        SetIntelligence(std::stoi(tokens[75]));
        SetDexterity(std::stoi(tokens[76]));
        SetX(std::stof(tokens[77]));
        SetY(std::stof(tokens[78]));
        SetZ(std::stof(tokens[79]));
        SetPitch(std::stof(tokens[80]));
        SetYaw(std::stof(tokens[81]));
    }
    // if (tokens[0] == "NPC_OBJECT") {
    //    
    // }
}
Example #13
0
void Game_Vehicle::SyncWithPlayer() {
    SetX(Main_Data::game_player->GetX());
    SetY(Main_Data::game_player->GetY());
    remaining_step = Main_Data::game_player->GetRemainingStep();
    SetDirection(Main_Data::game_player->GetDirection());
    SetSpriteDirection(Main_Data::game_player->GetSpriteDirection());
}
void Fire::Initialize(byte* screenPtr, byte screenWidth, byte screenHeight)
{
	// fire properties
	SetX(0);
	SetY(0);
	
	SetHDir(0);
	SetVDir(1);
	SetSpeed(8);
	SetLastUpdate(0);
	SetEnabled(false);
	
	Canvas *canvas = GetCanvas();
	canvas->SetWidth(1);
	canvas->SetHeight(1);
	canvas->SetImage(fire);
	canvas->SetScreenWidth(screenWidth);
	canvas->SetScreenHeight(screenHeight);
	canvas->SetScreen(screenPtr);

	/*
	if ((canvas->GetScreen()) != screenPtr)
	{
		Serial.println(" test 1 - pointers diferentes");
	}
	if (*(canvas->GetScreen()) != *screenPtr)
	{
		Serial.println(" test 2 - valores de pointers diferentes");
	}
	Serial.println("fim fire init");
	*/
}
Example #15
0
void Game_Character::MoveUpRight() {
	if (!IsDirectionFixed()) {
		if (GetDirection() % 2) {
			TurnRight();
		} else {
			TurnUp();
		}
	}

	if (jumping) {
		jump_plus_x++;
		jump_plus_y--;
		return;
	}

	if ((IsPassable(GetX(), GetY(), RPG::EventPage::Direction_right)
		&& IsPassable(GetX() + 1, GetY(), RPG::EventPage::Direction_up))
		|| (IsPassable(GetX(), GetY(), RPG::EventPage::Direction_up)
		&& IsPassable(GetX(), GetY() - 1, RPG::EventPage::Direction_right))) {
			SetX(GetX() + 1);
			SetY(GetY() - 1);
			BeginMove();
			stop_count = 0;
			move_failed = false;
	}
}
Example #16
0
void Game_Vehicle::SyncWithPlayer() {
	SetX(Main_Data::game_player->GetX());
	SetY(Main_Data::game_player->GetY());
	real_x = Main_Data::game_player->GetRealX();
	real_y = Main_Data::game_player->GetRealY();
	SetDirection(Main_Data::game_player->GetDirection());
}
Example #17
0
Window::Window( int x, int y, int w, int h, string caption ) {
    SetX( x );
    SetY( y );

    this->w = w;
    this->h = h;

    this->caption = caption;

    Debug::Set();
    Debug::Print("new window (%d,%d,%d,%d,%s)\n", x, y, w, h, caption.c_str());
    Debug::Unset();

    // Load the bitmaps needed for drawing
    bitmaps[0] = new Image( "Resources/Graphics/ui_wnd_up_left.png" );
    bitmaps[1] = new Image( "Resources/Graphics/ui_wnd_up.png" );
    bitmaps[2] = new Image( "Resources/Graphics/ui_wnd_up_right.png" );
    bitmaps[3] = new Image( "Resources/Graphics/ui_wnd_left.png" );
    bitmaps[4] = new Image( "Resources/Graphics/ui_wnd_right.png" );
    bitmaps[5] = new Image( "Resources/Graphics/ui_wnd_low_left.png" );
    bitmaps[6] = new Image( "Resources/Graphics/ui_wnd_low.png" );
    bitmaps[7] = new Image( "Resources/Graphics/ui_wnd_low_right.png" );
    bitmaps[8] = new Image( "Resources/Graphics/ui_wnd_back.png" );

    //inner_top = bitmaps[0]->GetHeight();
    //inner_left = bitmaps[0]->GetWidth();
    //inner_right = w - bitmaps[7]->GetWidth();
    //inner_low = h - bitmaps[7]->GetHeight();
}
void Sprite_Battler::CreateSprite() {
	sprite_name = battler->GetSpriteName();
	hue = battler->GetHue();

	SetX(battler->GetBattleX());
	SetY(battler->GetBattleY());
	SetZ(battler->GetBattleY()); // Not a typo

	// Not animated -> Monster
	if (battler->GetBattleAnimationId() == 0) {
		if (sprite_name.empty()) {
			graphic = Bitmap::Create(0, 0);
			SetOx(graphic->GetWidth() / 2);
			SetOy(graphic->GetHeight() / 2);
			SetBitmap(graphic);
		}
		else {
			FileRequestAsync* request = AsyncHandler::RequestFile("Monster", sprite_name);
			request_id = request->Bind(&Sprite_Battler::OnMonsterSpriteReady, this);
			request->Start();
		}
	}
	else { // animated
		SetOx(24);
		SetOy(24);
		SetAnimationState(anim_state);
		idling = true;
	}

	SetVisible(!battler->IsHidden());
}
Example #19
0
void Game_Vehicle::SetPosition(int _map_id, int _x, int _y) {
	SetMapId(_map_id);
	SetX(_x);
	SetY(_y);
	real_x = _x * SCREEN_TILE_WIDTH;
	real_y = _y * SCREEN_TILE_WIDTH;
}
Example #20
0
void BuildSparseIrred(GF2X& f, long n)
{
   if (n <= 0) Error("SparseIrred: n <= 0");

   if (NTL_OVERFLOW(n, 1, 0)) 
      Error("overflow in BuildSparseIrred");

   if (n == 1) {
      SetX(f);
      return;
   }

   if (n <= 2048) {
      if (GF2X_irred_tab[n][1] == 0) {
         clear(f);
         SetCoeff(f, n);
         SetCoeff(f, GF2X_irred_tab[n][0]);
         SetCoeff(f, 0);
      }
      else {
         clear(f);
         SetCoeff(f, n);
         SetCoeff(f, GF2X_irred_tab[n][0]);
         SetCoeff(f, GF2X_irred_tab[n][1]);
         SetCoeff(f, GF2X_irred_tab[n][2]);
         SetCoeff(f, 0);
      }

      return;
   }

   long k3, k2, k1;

   k3 = FindTrinom(n);
   if (k3) {
      clear(f);
      SetCoeff(f, n);
      SetCoeff(f, k3);
      SetCoeff(f, 0);
      return;
   }

   k3 = FindPent(n, k2, k1);
   if (k3) {
      clear(f);
      SetCoeff(f, n);
      SetCoeff(f, k3);
      SetCoeff(f, k2);
      SetCoeff(f, k1);
      SetCoeff(f, 0);
      return;
   }

   // the following is probably of only theoretical value...
   // it is reasonable to conjecture that for all n >= 2,
   // there is either an irreducible trinomial or pentanomial
   // of degree n.

   BuildIrred(f, n);
}
Example #21
0
void BuildIrred(GF2X& f, long n)
{
   if (n <= 0)
      Error("BuildIrred: n must be positive");

   if (NTL_OVERFLOW(n, 1, 0)) Error("overflow in BuildIrred");

   if (n == 1) {
      SetX(f);
      return;
   }

   GF2X g;

   _ntl_ulong i;

   i = 0;
   do {
      ConvertBits(g, 2*i+1);
      SetCoeff(g, n);
      i++;
   } while (!IterIrredTest(g));

   f = g;

}
Example #22
0
void Game_Character::Move(int dir) {
	int dx = (dir == Right || dir == UpRight || dir == DownRight) - (dir == Left || dir == DownLeft || dir == UpLeft);
	int dy = (dir == Down || dir == DownRight || dir == DownLeft) - (dir == Up || dir == UpRight || dir == UpLeft);

	SetDirection(dir);
	if (!(IsDirectionFixed() || IsFacingLocked())) {
		if (dir > 3) // Diagonal
			SetSpriteDirection(GetSpriteDirection() % 2 ? -dx + 2 : dy + 1);
		else
			SetSpriteDirection(dir);
	}

	if (jumping) {
		jump_plus_x += dx;
		jump_plus_y += dy;
		return;
	}

	move_failed = !IsPassable(GetX(), GetY(), dir);
	if (move_failed) {
		if (!CheckEventTriggerTouch(Game_Map::RoundX(GetX() + dx), Game_Map::RoundY(GetY() + dy)))
			return;
	} else {
		SetX(Game_Map::RoundX(GetX() + dx));
		SetY(Game_Map::RoundY(GetY() + dy));
		remaining_step = SCREEN_TILE_WIDTH;
		BeginMove();
	}

	stop_count = 0;
	max_stop_count = (GetMoveFrequency() > 7) ? 0 : pow(2.0, 9 - GetMoveFrequency());
}
Example #23
0
void bot::Draw()
{
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
    glTranslatef(GetX(), GetY(), 0.0);
    glRotatef(m_angle, 0.0f, 0.0f, 1.0f);
    glTranslatef(m_speed, 0, 0);
    glColor3f(m_bColor[0], m_bColor[1], m_bColor[2]);
    glBegin(GL_POLYGON);
    glVertex2i(m_vertices[0], m_vertices[1]);
    glVertex2i(m_vertices[2], m_vertices[3]);
    glVertex2i(m_vertices[4], m_vertices[5]);
    glVertex2i(m_vertices[6], m_vertices[7]);
    glVertex2i(m_vertices[8], m_vertices[9]);
    glVertex2i(m_vertices[10], m_vertices[11]);
    glVertex2i(m_vertices[12], m_vertices[13]);
    glVertex2i(m_vertices[14], m_vertices[15]);
    glEnd();
    /*   glEnableClientState(GL_VERTEX_ARRAY);
       glVertexPointer(2, GL_INT, 0, m_vertices);
       glDrawArrays(GL_LINE_LOOP, 0, 16);
       glDisableClientState(GL_VERTEX_ARRAY);*/
    glPopMatrix();
    SetX(GetX()+(GLint)m_deltaX);
    SetY(GetY()+(GLint)m_deltaY);
}
void CtfSoldierSpawnPointMapElement::Load( Json::Value& setters )
{
    MapElement::Load( setters );
    Json::Value const& position = setters["position"];
    if( !position.isObject() )
    {
        return;
    }
    int32_t x;
    if ( !Json::GetInt( position["x"], x ) )
    {
        return;
    }
    SetX( x );
    int32_t y;
    if ( !Json::GetInt( position["y"], y ) )
    {
        return;
    }
    SetY( y );
    std::string teamStr;
    if ( !Json::GetStr( setters["team"], teamStr ) )
    {
        return;
    }
    SetTeam( Team::Get()( AutoId( teamStr ) ) );

}
Example #25
0
void PAlgebraModDerived<type>::mapToFt(RX& w,
			     const RX& G,unsigned long t,const RX* rF1) const
{
  if (isDryRun()) {
    w = RX::zero();
    return;
  }
  long i = zMStar.indexOfRep(t);
  if (i < 0) { clear(w); return; }


  if (rF1==NULL) {               // Compute the representation "from scratch"
    // special case
    if (G == factors[i]) {
      SetX(w);
      return;
    }

    //special case
    if (deg(G) == 1) {
      w = -ConstTerm(G);
      return;
    }

    // the general case: currently only works when r == 1
    assert(r == 1);  

    REBak bak; bak.save();
    RE::init(factors[i]);        // work with the extension field GF_p[X]/Ft(X)
    REX Ga;
    conv(Ga, G);                 // G as a polynomial over the extension field

    vec_RE roots;
    FindRoots(roots, Ga);        // Find roots of G in this field
    RE* first = &roots[0];
    RE* last = first + roots.length();
    RE* smallest = min_element(first, last);
                                // make a canonical choice
    w=rep(*smallest);         
    return;
  }
  // if rF1 is set, then use it instead, setting w = rF1(X^t) mod Ft(X)
  RXModulus Ft(factors[i]);
  //  long tInv = InvMod(t,m);
  RX X2t = PowerXMod(t,Ft);    // X2t = X^t mod Ft
  w = CompMod(*rF1,X2t,Ft);      // w = F1(X2t) mod Ft

  /* Debugging sanity-check: G(w)=0 in the extension field (Z/2Z)[X]/Ft(X)
  RE::init(factors[i]);
  REX Ga;
  conv(Ga, G); // G as a polynomial over the extension field
  RE ra;
  conv(ra, w);         // w is an element in the extension field
  eval(ra,Ga,ra);  // ra = Ga(ra)
  if (!IsZero(ra)) {// check that Ga(w)=0 in this extension field
    cout << "rF1(X^t) mod Ft(X) != root of G mod Ft, t=" << t << endl;
    exit(0);    
  }*******************************************************************/
}
	/*************************************************************
	 * Função responsavel por atualizar a posição da nave em 
	 * relação a tela
	 *
	 *************************************************************/
	void SpaceShip1::Update(void) 
	{
		if(GetX() + offsetX < width) {
			Move(offsetX, 0);
		} else {
			SetX(-GetWidthFrame());
		}
	}
Example #27
0
CNCPoint & CNCPoint::operator+= ( const CNCPoint & rhs )
{
    SetX( X() + rhs.X() );
    SetY( Y() + rhs.Y() );
    SetZ( Z() + rhs.Z() );

    return(*this);
}
Example #28
0
SimplifySketchTool::SortPoint & SimplifySketchTool::SortPoint::operator+= ( const SortPoint & rhs )
{
    SetX( X() + rhs.X() );
    SetY( Y() + rhs.Y() );
    SetZ( Z() + rhs.Z() );

    return(*this);
}
Example #29
0
Player::Player(){
        SetX(360);
        SetY(360);       
        m_iLives = 3;
        m_iScore = 0;
        m_iDots = 0;
        m_bDeath = false;
}
Tile::Tile(const Tile & src)
{
	m_ShipType = src.m_ShipType;
	m_ShipId = src.m_ShipId;
	m_TileState = src.m_TileState;
	SetX(src.GetX());
	SetY(src.GetY());
}