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; } }
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]); } }
void NaGeVector3D::operator /= (const double &scalar) { if(!IsNull()) { SetX(GetX()/scalar); SetY(GetY()/scalar); SetZ(GetZ()/scalar); } else { SetX(0); SetY(0); SetZ(0); } }
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") { // // } }
void TrPdf::Subtract(TrPdf* that, bool logx, bool logy) { for (int i=0; i<GetN(); i++) { double y0 = GetY(i); double y1 = that->Eval(GetX(i),logx,logy); SetY(i,y0-y1); } }
void TrPdf::Multiply(TrPdf* that, bool logx, bool logy) { for (int i=0; i<GetN(); i++) { double y0 = GetY(i); double y1 = that->Eval(GetX(i),logx,logy); SetY(i,y0*y1); } }
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::Update() { if (GetEnabled() && (millis() - GetLastUpdate()) > 1000 / GetSpeed()) { if (GetLastUpdate() != 0) GetCanvas()->InvalidateRect(GetX(), GetY()); SetY(GetY() + GetVDir()); if ((GetY() + GetHeight() - 1) > GetCanvas()->GetScreenHeight() - 1) { SetEnabled(false); SetLastUpdate(0); } else if (GetY() < 0) { SetEnabled(false); SetLastUpdate(0); } if (GetEnabled()) { /* Serial.print(GetX()); Serial.print(","); Serial.print(GetY()); */ GetCanvas()->Paint(GetX(), GetY()); SetLastUpdate(millis()); } } }
OpponentMisterKuba::OpponentMisterKuba( int x_, int y_ ) : Opponent( "misterkuba" ) , ti( 1 ) { SetX( x_ ); SetY( y_ ); }
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; }
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()); }
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()); }
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); }
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()); }
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; }
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; } }
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 ) ) ); }
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; } }
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"); */ }
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; }
//Update event void testEntity::OnUpdate() { sinVal+= sinSpeed; SetX(startX+sin(sinVal)*100); SetY(startY); angle+=3; }
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); }
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(); }
CNCPoint & CNCPoint::operator+= ( const CNCPoint & rhs ) { SetX( X() + rhs.X() ); SetY( Y() + rhs.Y() ); SetZ( Z() + rhs.Z() ); return(*this); }
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()); }
Player::Player(){ SetX(360); SetY(360); m_iLives = 3; m_iScore = 0; m_iDots = 0; m_bDeath = false; }
SimplifySketchTool::SortPoint & SimplifySketchTool::SortPoint::operator+= ( const SortPoint & rhs ) { SetX( X() + rhs.X() ); SetY( Y() + rhs.Y() ); SetZ( Z() + rhs.Z() ); return(*this); }
void Sprite_Character::Update() { Sprite::Update(); Rect r; if (tile_id != character->GetTileId() || character_name != character->GetCharacterName() || character_index != character->GetCharacterIndex()) { tile_id = character->GetTileId(); character_name = character->GetCharacterName(); character_index = character->GetCharacterIndex(); if (tile_id > 0) { BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id); SetBitmap(tile); r.Set(0, 0, 16, 16); SetSrcRect(r); SetOx(8); SetOy(16); } else { if (character_name.empty()) { SetBitmap(BitmapRef()); } else { SetBitmap(Cache::Charset(character_name)); chara_width = GetBitmap()->GetWidth() / 4 / 3; chara_height = GetBitmap()->GetHeight() / 2 / 4; SetOx(chara_width / 2); SetOy(chara_height); int sx = (character_index % 4) * chara_width * 3; int sy = (character_index / 4) * chara_height * 4; r.Set(sx, sy, chara_width * 3, chara_height * 4); SetSpriteRect(r); } } } if (tile_id == 0) { int row = character->GetDirection(); r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height); SetSrcRect(r); } if (character->IsFlashPending()) { Color col; int dur; character->GetFlashParameters(col, dur); Flash(col, dur); } SetVisible(character->GetVisible()); if (GetVisible()) { SetOpacity(character->GetOpacity()); } SetX(character->GetScreenX()); SetY(character->GetScreenY()); SetZ(character->GetScreenZ(chara_height)); //SetBlendType(character->GetBlendType()); //SetBushDepth(character->GetBushDepth()); }
void AnimationSprite::SetTexture(ID2D1Bitmap* pTexture) { this->pBitmapBrush = NULL; this->pTexture = pTexture; SetWidth(width); SetHeight(height); SetX(x); SetY(y); }
void Sprite_Character::Update() { Sprite::Update(); Rect r; if (tile_id != character->GetTileId() || character_name != character->GetSpriteName() || character_index != character->GetSpriteIndex()) { tile_id = character->GetTileId(); character_name = character->GetSpriteName(); character_index = character->GetSpriteIndex(); if (tile_id > 0) { BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id); SetBitmap(tile); r.Set(0, 0, TILE_SIZE, TILE_SIZE); SetSrcRect(r); SetOx(8); SetOy(16); } else { if (character_name.empty()) { SetBitmap(BitmapRef()); } else { SetBitmap(Cache::Charset(character_name)); SetOx(chara_width / 2); SetOy(chara_height); int sx = (character_index % 4) * chara_width * 3; int sy = (character_index / 4) * chara_height * 4; r.Set(sx, sy, chara_width * 3, chara_height * 4); SetSpriteRect(r); } } } if (tile_id == 0) { int row = (character->IsSpinning() ? character->GetPrelockDirection() : character->GetDirection()); r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height); SetSrcRect(r); } if (character->IsFlashPending()) { Color col = character->GetFlashColor(); int dur = character->GetFlashTimeLeft(); Flash(col, dur); // TODO: Gradual decrease of Flash Time Left character->SetFlashTimeLeft(0); } SetVisible(character->GetVisible()); if (GetVisible()) { SetOpacity(character->GetOpacity()); } SetX(character->GetScreenX()); SetY(character->GetScreenY()); SetZ(character->GetScreenZ(chara_height)); //SetBlendType(character->GetBlendType()); //SetBushDepth(character->GetBushDepth()); }