void Line::SetY(double y) { SetPosition(GetX(), y); }
/// Recalculate when each unit will arrive at the current army position, whatever that is void CvArmyAI::UpdateCheckpointTurnsAndRemoveBadUnits() { CvAIOperation* pOperation = GET_PLAYER(GetOwner()).getAIOperation(GetOperationID()); //should be updated before calling this ... CvPlot* pCurrentArmyPlot = GC.getMap().plot(GetX(), GetY()); //kick out damaged units, but if we're defending or escorting, no point in running away if (pOperation->IsOffensive()) { for (unsigned int iI = 0; iI < m_FormationEntries.size(); iI++) { if (!m_FormationEntries[iI].IsUsed()) continue; CvUnit* pUnit = GET_PLAYER(m_eOwner).getUnit(m_FormationEntries[iI].m_iUnitID); if (pUnit == NULL) continue; //failsafe - make sure the army ID is set if (pUnit->getArmyID() != GetID()) pUnit->setArmyID(GetID()); //let tactical AI handle those if (pUnit->GetCurrHitPoints() < pUnit->GetMaxHitPoints() / 3) RemoveUnit(m_FormationEntries[iI].GetUnitID()); } } //update for all units in this army. ignore the ones still being built int iGatherTolerance = pOperation->GetGatherTolerance(this, pCurrentArmyPlot); for(unsigned int iI = 0; iI < m_FormationEntries.size(); iI++) { if (!m_FormationEntries[iI].IsUsed()) continue; CvUnit* pUnit = GET_PLAYER(m_eOwner).getUnit(m_FormationEntries[iI].GetUnitID()); if(pUnit && pCurrentArmyPlot) { if(plotDistance(*pUnit->plot(),*pCurrentArmyPlot)<iGatherTolerance) { m_FormationEntries[iI].SetTurnsToCheckpoint(0); } else { //be generous with the flags here, for some ops the muster point may be far away and intermittendly occupied by foreign units ... int iFlags = CvUnit::MOVEFLAG_APPROX_TARGET_RING2 | CvUnit::MOVEFLAG_IGNORE_STACKING | CvUnit::MOVEFLAG_IGNORE_ZOC; int iTurnsToReachCheckpoint = pUnit->TurnsToReachTarget(pCurrentArmyPlot, iFlags, pOperation->GetMaximumRecruitTurns()); //if we're already moving to target, the current army plot is moving, so we cannot check progress against ... if ( iTurnsToReachCheckpoint==INT_MAX || (GetArmyAIState()==ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP && !m_FormationEntries[iI].IsMakingProgressTowardsCheckpoint(iTurnsToReachCheckpoint)) ) { CvString strMsg; strMsg.Format("Removing %s %d from army %d because no progress to checkpoint (%d:%d). ETA %d, previously %d.", pUnit->getName().c_str(), m_FormationEntries[iI].GetUnitID(), GetID(), pCurrentArmyPlot->getX(), pCurrentArmyPlot->getY(), iTurnsToReachCheckpoint, m_FormationEntries[iI].m_iPrevEstimatedTurnsToCheckpoint); pOperation->LogOperationSpecialMessage(strMsg); RemoveUnit(m_FormationEntries[iI].GetUnitID()); } else m_FormationEntries[iI].SetTurnsToCheckpoint(iTurnsToReachCheckpoint); } } } }
void Sprite::ScaleToClipped( float fWidth, float fHeight ) { m_fRememberedClipWidth = fWidth; m_fRememberedClipHeight = fHeight; if( !m_pTexture ) return; int iSourceWidth = m_pTexture->GetSourceWidth(); int iSourceHeight = m_pTexture->GetSourceHeight(); // save the original X&Y. We're going to resore them later. float fOriginalX = GetX(); float fOriginalY = GetY(); if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite { float fCustomImageCoords[8] = { 0.02f, 0.78f, // top left 0.22f, 0.98f, // bottom left 0.98f, 0.22f, // bottom right 0.78f, 0.02f, // top right }; Sprite::SetCustomImageCoords( fCustomImageCoords ); if( fWidth != -1 && fHeight != -1) m_size = RageVector2( fWidth, fHeight ); else { /* If no crop size is set, then we're only being used to crop diagonal * banners so they look like regular ones. We don't actually care about * the size of the image, only that it has an aspect ratio of 4:1. */ m_size = RageVector2(256, 64); } SetZoom( 1 ); } else if( m_pTexture->GetID().filename.find( "(was rotated)" ) != m_pTexture->GetID().filename.npos && fWidth != -1 && fHeight != -1 ) { /* Dumb hack. Normally, we crop all sprites except for diagonal banners, * which are stretched. Low-res versions of banners need to do the same * thing as their full resolution counterpart, so the crossfade looks right. * However, low-res diagonal banners are un-rotated, to save space. BannerCache * drops the above text into the "filename" (which is otherwise unused for * these banners) to tell us this. */ Sprite::StopUsingCustomCoords(); m_size = RageVector2( fWidth, fHeight ); SetZoom( 1 ); } else if( fWidth != -1 && fHeight != -1 ) { // this is probably a background graphic or something not intended to be a CroppedSprite Sprite::StopUsingCustomCoords(); // first find the correct zoom Sprite::ScaleToCover( RectF(0,0,fWidth,fHeight) ); // find which dimension is larger bool bXDimNeedsToBeCropped = GetZoomedWidth() > fWidth+0.01; if( bXDimNeedsToBeCropped ) // crop X { float fPercentageToCutOff = (this->GetZoomedWidth() - fWidth) / this->GetZoomedWidth(); float fPercentageToCutOffEachSide = fPercentageToCutOff / 2; // generate a rectangle with new texture coordinates RectF fCustomImageRect( fPercentageToCutOffEachSide, 0, 1 - fPercentageToCutOffEachSide, 1 ); SetCustomImageRect( fCustomImageRect ); } else // crop Y { float fPercentageToCutOff = (this->GetZoomedHeight() - fHeight) / this->GetZoomedHeight(); float fPercentageToCutOffEachSide = fPercentageToCutOff / 2; // generate a rectangle with new texture coordinates RectF fCustomImageRect( 0, fPercentageToCutOffEachSide, 1, 1 - fPercentageToCutOffEachSide ); SetCustomImageRect( fCustomImageRect ); } m_size = RageVector2( fWidth, fHeight ); SetZoom( 1 ); } // restore original XY SetXY( fOriginalX, fOriginalY ); }
/************************************************************************ Function: void AnimateText(BYTE mov) Overview: Routine to move or animate the text. Input: mov - number of pixels the text will be moved Output: none ************************************************************************/ void AnimateText(BYTE mov) { static SHORT xPos = STXXPOS, yPos = STXYPOS; static SHORT x, y; SHORT width; SHORT height; SHORT newX, newY, oldX, oldY; XCHAR NewChar, *pString; // set the clipping region SetClip(CLIP_ENABLE); SetClipRgn(STXXPOS + 2, STXYPOS + 2, STXXPOS + STXWIDTH - 2, STXYPOS + STXHEIGHT - 2); // set the font SetFont(pHWData->pHWFont); // calculate string width & height width = GetTextWidth((XCHAR *)pHWData->pHWStr, pHWData->pHWFont); height = GetTextHeight(pHWData->pHWFont); //----------------------------------------------------------------- // interlace the erasing and printing of characters // check first if we need to move in the positive or negative direction if((xPos + width) >= (STXXPOS + STXWIDTH)) x = -(mov); if(xPos <= (STXXPOS)) x = (mov); if((yPos + height) >= (STXYPOS + STXHEIGHT)) y = -(mov); if(yPos <= (STXYPOS)) y = (mov); pString = pHWData->pHWStr; oldX = xPos; oldY = yPos; newX = xPos + x; newY = yPos + y; while((XCHAR)15 < (XCHAR)(NewChar = *pString++)) { // remove the old position of the character SetColor(FontScheme2->CommonBkColor); MoveTo(oldX, oldY); WAIT_UNTIL_FINISH(OutChar(NewChar)); oldX = GetX(); oldY = GetY(); // display the character in the new position SetColor(BRIGHTBLUE); MoveTo(newX, newY); WAIT_UNTIL_FINISH(OutChar(NewChar)); newX = GetX(); newY = GetY(); } xPos += x; yPos += y; // disable the clipping SetClip(CLIP_DISABLE); }
// solar: if lifetime is 0 this is a permanent beacon.. not sure if that'll be // useful for anything Beacon::Beacon(Mob *at_mob, int lifetime) :Mob ( nullptr, nullptr, 0, 0, 0, INVISIBLE_MAN, 0, BT_NoTarget, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ), remove_timer(lifetime), spell_timer(0) { remove_timer.Disable(); spell_timer.Disable(); remove_me = false; spell_id = 0xFFFF; resist_adjust = 0; spell_iterations = 0; caster_id = 0; // copy location x_pos = at_mob->GetX(); y_pos = at_mob->GetY(); z_pos = at_mob->GetZ(); heading = at_mob->GetHeading(); if(lifetime) { remove_timer.Start(); } #ifdef SOLAR entity_list.Message(0, 0, "Beacon being created at %0.2f %0.2f %0.2f heading %0.2f lifetime %d", GetX(), GetY(), GetZ(), GetHeading(), lifetime); #endif }
/***************************************** *int main (void) *****************************************/ int main (void) { InitializeHardware(); HardwareButtonInit(); InitAllLEDs(); #ifdef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH GFX_DRIVER_AutoUpdPart(); // Turn on widget auto update, partial update for less flashing #endif InitTick(); GOLInit(); SetColor(WHITE); ClearDevice(); // Set proper display rotation #if(DISP_ORIENTATION == 90) GFX_DRIVER_InitRotmode(ROTATE_90); #else #error "This PICTail display orientation must be 90." #endif // make sure that the correct hex file is loaded CheckExternalFlashHex(); // Create cursor in GFX_CURSOR_LAYER with Alpha Color = 0xA GFX_DRIVER_CreateLayer( GFX_CURSOR_LAYER, GFX_LAYER_TRANS_EN | 0xA, GetX(), GetY(), GetX() + 31, GetY() + 31 ); GFX_DRIVER_ActivateLayer( GFX_CURSOR_LAYER ); PutImage(0, 0, (void *)&mouse_cursor_icon_270, IMAGE_NORMAL); GFX_DRIVER_ActivateLayer( GFX_MAIN_LAYER ); // Start demo screen demoScreens = DEMO_INTRO_SCREEN_CREATE; while(1) { GOLDraw(); #ifndef USE_BISTABLE_DISPLAY_GOL_AUTO_REFRESH #if defined( ONE_CYCLE_DRAWING ) // The screen drawing starts and completes during one while(1) cycle loop in main(). // This Demo is one cycle drawing application. if ( GFX_DRIVER_IsUpdateRequested() || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) ) { GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED; } #else // This way can be used when drawing may take few or more cycles of while(1) loop in main(). // See "tick.c" file for details. if ( g_UpdateNow || (g_UPDATE_FLAGS == GFX_UPDATE_AS_IT_DRAWS) ) { g_UpdateNow = 0; GFX_DRIVER_UpdateEpd( g_UPDATE_FLAGS, 0, 0, GetMaxX(), GetMaxY() ); g_UPDATE_FLAGS = GFX_UPDATE_NO_FLASH | GFX_WAIT_IMAGE_DISPLAYED; } #endif #endif } return (-1); }
/**\brief Slider mouse down call back. */ bool Slider::MouseLUp( int xi, int yi ){ this->SetVal(this->PixelToVal(xi - GetX())); Widget::MouseLDown( xi, yi );; if(OPTION(int, "options/sound/buttons")) UI::beep->Play(); return true; }
void CGSH_Direct3D9::SetRenderingContext(uint64 primReg) { auto prim = make_convertible<PRMODE>(primReg); unsigned int context = prim.nContext; uint64 testReg = m_nReg[GS_REG_TEST_1 + context]; uint64 frameReg = m_nReg[GS_REG_FRAME_1 + context]; uint64 alphaReg = m_nReg[GS_REG_ALPHA_1 + context]; uint64 zbufReg = m_nReg[GS_REG_ZBUF_1 + context]; uint64 tex0Reg = m_nReg[GS_REG_TEX0_1 + context]; uint64 tex1Reg = m_nReg[GS_REG_TEX1_1 + context]; uint64 clampReg = m_nReg[GS_REG_CLAMP_1 + context]; uint64 scissorReg = m_nReg[GS_REG_SCISSOR_1 + context]; if(!m_renderState.isValid || (m_renderState.primReg != primReg)) { m_device->SetRenderState(D3DRS_ALPHABLENDENABLE, ((prim.nAlpha != 0) && m_alphaBlendingEnabled) ? TRUE : FALSE); } if(!m_renderState.isValid || (m_renderState.alphaReg != alphaReg)) { SetupBlendingFunction(alphaReg); } if(!m_renderState.isValid || (m_renderState.testReg != testReg)) { SetupTestFunctions(testReg); } if(!m_renderState.isValid || (m_renderState.zbufReg != zbufReg) || (m_renderState.frameReg != frameReg)) { SetupDepthBuffer(zbufReg, frameReg); } if(!m_renderState.isValid || (m_renderState.frameReg != frameReg) || (m_renderState.scissorReg != scissorReg)) { SetupFramebuffer(frameReg, scissorReg); } if(!m_renderState.isValid || (m_renderState.tex0Reg != tex0Reg) || (m_renderState.tex1Reg != tex1Reg) || (m_renderState.clampReg != clampReg)) { SetupTexture(tex0Reg, tex1Reg, clampReg); } m_renderState.isValid = true; m_renderState.primReg = primReg; m_renderState.alphaReg = alphaReg; m_renderState.testReg = testReg; m_renderState.zbufReg = zbufReg; m_renderState.frameReg = frameReg; m_renderState.tex0Reg = tex0Reg; m_renderState.tex1Reg = tex1Reg; m_renderState.clampReg = clampReg; m_renderState.scissorReg = scissorReg; auto offset = make_convertible<XYOFFSET>(m_nReg[GS_REG_XYOFFSET_1 + context]); m_nPrimOfsX = offset.GetX(); m_nPrimOfsY = offset.GetY(); if(GetCrtIsInterlaced() && GetCrtIsFrameMode()) { if(m_nCSR & CSR_FIELD) { m_nPrimOfsY += 0.5; } } }
Point Tile::GetPoint() const { return Point(GetX(), GetY()); }
void CFish::BreedingUpdate(double elapsed) { CAquarium *aquarium = GetAquarium(); //fish logic for breeding if (mCanBreed == true && mAge >= MaxAge) { if (mInterestTime >= InterestTimePreBreed) { mIsInterested = true; } else if (mIsGestating == false) mInterestTime++; if (mIsGestating == true) mGestatingTime++; if (mIsInterested == true) { CBreedVisitor visitor(mIsMale, GetType()); aquarium->Accept(&visitor); if (visitor.IsInterested()) { // Compute a vector from (x1,y1) to (x2,y2) double dx = visitor.GetX() - GetX(); double dy = visitor.GetY() - GetY(); // How long is that vector? double len = sqrt(dx * dx + dy * dy); if (len > 0) { // Normalize the vector dx /= len; dy /= len; } // Update the location if (GetType() == "beta") { mSpeedX = dx * (MaxSpeedX - BetaSpeed) * BreedMultuplier * elapsed; mSpeedY = dy * (MaxSpeedY - BetaSpeed) * BreedMultuplier * elapsed; } if (GetType() == "bubbles") { mSpeedX = dx * (MaxSpeedX - BubblesSpeed) * BreedMultuplier * elapsed; mSpeedY = dy * (MaxSpeedY - BubblesSpeed) * BreedMultuplier * elapsed; } if (GetType() == "dory") { mSpeedX = dx * (DorySpeed - MaxSpeedX) * BreedMultuplier * elapsed; mSpeedY = dy * (DorySpeed - MaxSpeedY) * BreedMultuplier * elapsed; } // check if the visited fish overlaps this one if (OverlapTest(visitor.GetX(), visitor.GetY())) { if (mIsMale == 0) { mIsGestating = true; } else { visitor.SetGestating(); } mIsInterested = false; mInterestTime = 0; visitor.SetUninterested(); if (GetType() == "beta") { mSpeedX = ((double)rand() / RAND_MAX) * (MaxSpeedX - BetaSpeed); mSpeedY = ((double)rand() / RAND_MAX) * (MaxSpeedY - BetaSpeed); } else if (GetType() == "bubbles") { mSpeedX = ((double)rand() / RAND_MAX) * (MaxSpeedX - BubblesSpeed); mSpeedY = ((double)rand() / RAND_MAX) * (MaxSpeedY - BubblesSpeed); } else if (GetType() == "dory") { mSpeedX = ((double)rand() / RAND_MAX) * (DorySpeed- MaxSpeedX); mSpeedY = ((double)rand() / RAND_MAX) * (DorySpeed- MaxSpeedY); } } } } if (mGestatingTime >= GestatingTime) { mIsGestating = false; mGestatingTime = 0; if (GetType() == "beta") { auto fish = make_shared<CFishBeta>(aquarium); fish->SetLocation(GetX(), GetY()); aquarium->AddTempItem(fish); } if (GetType() == "bubbles") { auto fish = make_shared<CFishBubbles>(aquarium); fish->SetLocation(GetX(), GetY()); aquarium->AddTempItem(fish); } if (GetType() == "dory") { auto fish = make_shared<CFishDory>(aquarium); fish->SetLocation(GetX(), GetY()); aquarium->AddTempItem(fish); } } if (mSpeedX < 0) SetMirror(true); if (mSpeedX > 0) SetMirror(false); } }
bool Player::IsPointWithin(int x, int y) { return (x > (GetX()) && GetX() + GetWidth() > x) && (y > GetY() && GetY() + GetWidth() > y); }
void Sprite::MoveLeft(Dim x) { if(GetX() > x) SetX(GetX() - x); }
void Sprite::Move(int x, int y){ SetX(GetX() + x); SetY(GetY() + y); return ; }
void Sprite::Move (Dim x,Dim y) { SetX(GetX() + x); SetY(GetY() + y); return ; }
wxRealPoint ExplainShape::GetEndPoint(int kidNo) { wxRealPoint rp(GetX() - GetBitmap().GetWidth() / 2.0 - ARROWMARGIN, GetY() - (GetHeight()-GetBitmap().GetHeight()) / 2. + (kidCount>1 ? GetBitmap().GetHeight() * 2. /3. * kidNo / (2*kidCount-2) : 0 )); return rp; }
WorldPacket Creature::PackData() { WorldPacket Packet((uint16)MSG_ADD_OBJECT); Packet << ObjID << pTemplate->Tileset << pTemplate->Name << GetX() << GetY() << pTemplate->tx << pTemplate->ty; return Packet; }
struct Cluster* Calculate(struct Points* Field, int Height, int Width, int* Num, int NumOfPoints) { struct Cluster *Clusters; int i,j,k,NumOfClusters; int n; double Min; /*int Min_x; int Min_y; int Max_x; int Max_y;*/ double New_Cluster_X; double New_Cluster_Y; int Min_cluster; double Distance; double Point_X, Point_Y; int Flag = 1; int New_Flag; printf("Enter number of clusters: "); scanf("%d",&NumOfClusters); Clusters = (struct Cluster*)malloc(NumOfClusters * sizeof(struct Cluster)); Init_Clusters(Clusters, NumOfClusters); srand(time(NULL)); for(i = 0; i< NumOfClusters; i++) { Clusters[i].x = (double)(rand()%Width); Clusters[i].y = (double)(rand()%Height); } #pragma omp parallel for private(i, Min) for(i = 0;i<NumOfPoints;i++) { Min = (double)(Height + Width); for(k = 0; k<NumOfClusters; k++) { Distance = Dist(Field[i].x,Field[i].y,Clusters[k].x,Clusters[k].y); if(Distance < Min) { Min = Distance; Min_cluster = k; } } Field[i].cluster = Min_cluster; Clusters[Min_cluster] = AddIndex(Clusters[Min_cluster], i); } while(Flag == 1) { Flag = 0; #pragma omp parallel for private(k) for(k=0; k<NumOfClusters; k++) { n = GetClusterNumOfPoints(Clusters[k]); New_Cluster_X = 0; New_Cluster_Y = 0; /*for(i = 0; i < n; i++) { Point_X = GetX(Field, Clusters[k],i); Point_Y = GetY(Field, Clusters[k],i); New_Cluster_X = (i*New_Cluster_X + Point_X)/(i+1);//vot on obhod perepolneniya New_Cluster_Y = (i*New_Cluster_Y + Point_Y)/(i+1); }*/ #pragma omp parallel for private(i) reduction(+:New_Cluster_X, New_Cluster_Y) for(i = 0; i < n; i++) { New_Cluster_X += GetX(Field, Clusters[k],i)/n; New_Cluster_Y += GetY(Field, Clusters[k],i)/n; } Clusters[k].x = New_Cluster_X; Clusters[k].y = New_Cluster_Y; } Clear_Points(Clusters, NumOfClusters); #pragma omp parallel for private(i, Min) for(i = 0;i<NumOfPoints;i++) { Min = (double)(Height + Width); for(k = 0; k<NumOfClusters; k++) { Distance = Dist(Field[i].x,Field[i].y,Clusters[k].x,Clusters[k].y); if(Distance < Min) { Min = Distance; Min_cluster = k; } } if(Field[i].cluster != Min_cluster) Flag = 1; Field[i].cluster = Min_cluster; Clusters[Min_cluster] = AddIndex(Clusters[Min_cluster], i); } } *Num = NumOfClusters; return Clusters; }
void GCDCGraphs::DrawGraph(wxGraphicsContext &dc, Draw* d) { static const int ellipse_size = 5; if (d->GetEnable() == false) return; DrawInfo *di = d->GetDrawInfo(); bool double_cursor = d->GetSelected() && d->GetDoubleCursor(); wxGraphicsPath path1 = dc.CreatePath(); wxGraphicsPath path2 = dc.CreatePath(); wxGraphicsPath *path = &path1; const wxColour &wc = di->GetDrawColor(); dc.SetPen(wxPen(wc, double_cursor ? 4 : 2, wxSOLID)); int pc = d->GetValuesTable().size(); bool prev_data = false; bool switched_to_alternate = false; bool switched_back = false; int dcs = -1, dce = -1; if (double_cursor) { dcs = d->GetValuesTable().m_stats.Start() - d->GetValuesTable().m_view.Start(); dce = d->GetValuesTable().m_stats.End() - d->GetValuesTable().m_view.Start(); } std::vector<std::pair<double,double> > p1circles; std::vector<std::pair<double,double> > p2circles; std::vector<std::pair<double,double> >* pcircles = &p1circles; bool draw_circle = d->GetPeriod() != PERIOD_T_DAY && d->GetPeriod() != PERIOD_T_30MINUTE && d->GetPeriod() != PERIOD_T_5MINUTE && d->GetPeriod() != PERIOD_T_MINUTE && d->GetPeriod() != PERIOD_T_30SEC; for (int i = 0; i < pc; i++) { if (!d->GetValuesTable().at(i).IsData()) { prev_data = false; continue; } double x = GetX(i); double y = GetY(d->GetValuesTable().at(i).val, di); bool drawn = false; if (i >= dcs && i <= dce && !switched_to_alternate) { if (prev_data) path->AddLineToPoint(x, y); path = &path2; pcircles = &p2circles; if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) pcircles->push_back(std::make_pair(x, y)); path->MoveToPoint(x, y); switched_to_alternate = true; drawn = true; } if (i >= dce && switched_to_alternate && !switched_back) { if (prev_data) path->AddLineToPoint(x, y); std::vector<std::pair<double, double> > *p; if (i == dce) p = &p2circles; else p = &p1circles; if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) p->push_back(std::make_pair(x, y)); path = &path1; pcircles = &p1circles; path->MoveToPoint(x, y); switched_back = true; drawn = true; } if (!drawn) { if (prev_data) path->AddLineToPoint(x, y); else path->MoveToPoint(x, y); if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) pcircles->push_back(std::make_pair(x, y)); } prev_data = true; } for (std::vector<std::pair<double, double> >::iterator i = p1circles.begin(); i != p1circles.end(); i++) if (draw_circle) path1.AddEllipse(i->first - ellipse_size / 2, i->second - ellipse_size / 2, ellipse_size, ellipse_size); else path1.AddCircle(i->first, i->second, 1); dc.StrokePath(path1); if (double_cursor) { dc.SetPen(wxPen(*wxWHITE, 4, wxSOLID)); for (std::vector<std::pair<double, double> >::iterator i = p2circles.begin(); i != p2circles.end(); i++) if (draw_circle) path2.AddEllipse(i->first - ellipse_size / 2, i->second - ellipse_size / 2, ellipse_size, ellipse_size); else path2.AddCircle(i->first, i->second, 1); dc.StrokePath(path2); } }
void ribi::con3::ConnectThreeWidget::DoComputerMove() noexcept { const auto move = SuggestMove(); assert(CanDoMove(move.GetX(),move.GetY())); DoMove(move.GetX(),move.GetY()); }
void GCDCGraphs::DrawSeasonLimitInfo(wxGraphicsContext &dc, int i, int month, int day, bool summer) { const double stripe_width = 2; double x1 = GetX(i); double x2 = GetX(i + 1); double x = (x1 + x2) / 2; int w, h; GetClientSize(&w, &h); wxColour color = summer ? *wxBLUE : *wxRED; dc.SetFont(GetFont(), color); dc.SetPen(wxPen(color, 1, wxSOLID)); wxBrush brush(color); dc.SetBrush(brush); dc.DrawRectangle(x + 1, m_screen_margins.topmargin, stripe_width, w - m_screen_margins.topmargin - m_screen_margins.bottommargin); wxString str; if (summer) str = wxString(_("summer season")); else str = wxString(_("winter season")); str += wxString::Format(_T(" %d "), day); switch (month) { case 1: str += _("january"); break; case 2: str += _("february"); break; case 3: str += _("march"); break; case 4: str += _("april"); break; case 5: str += _("may"); break; case 6: str += _("june"); break; case 7: str += _("july"); break; case 8: str += _("august"); break; case 9: str += _("septermber"); break; case 10: str += _("october"); break; case 11: str += _("november"); break; case 12: str += _("december"); break; default: assert(false); } double tw, th, td, tsel; dc.GetTextExtent(_T("W"), &tw, &th, &td, &tsel); int ty = m_screen_margins.topmargin + 1; for (size_t i = 0; i < str.Len(); ++i) { double lw, lh, ld, lsel; wxString letter = str.Mid(i, 1); dc.GetTextExtent(letter, &lw, &lh, &ld, &lsel); dc.DrawText(letter, x + stripe_width + 2 + (tw - lw) / 2, ty); ty += th + 2; } }
/**\brief Slider mouse down call back. */ bool Slider::MouseLDown( int xi, int yi ){ this->SetVal(this->PixelToVal(xi - GetX())); Widget::MouseLDown( xi, yi ); return true; }
void NPC::AI_SetRoambox(float iDist, float iRoamDist, uint32 iDelay, uint32 iMinDelay) { AI_SetRoambox(iDist, GetX()+iRoamDist, GetX()-iRoamDist, GetY()+iRoamDist, GetY()-iRoamDist, iDelay, iMinDelay); }
func Choose() { aTrans[GetLength(aTrans)] = FindObject2(Find_ID(ASTE),Find_Distance(100,GetX(User)-GetX(),GetY(User)-GetY()),Sort_Distance()); CallMessageBoard(0,false,"Bitte geben Sie eine passende Beschreibung ein:",GetOwner(User)); }
int Api::_GetX(Object* target){ return GetX(target); }
Beacon::~Beacon() { #ifdef SOLAR entity_list.Message(0, 0, "Beacon %d being removed at %0.2f %0.2f %0.2f heading %0.2f", GetID(), GetX(), GetY(), GetZ(), GetHeading()); #endif }
void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) { // Old, but in some ways better (drawing opaque tabs) #ifndef wxUSE_NEW_METHOD if (!m_view) return; // Top-left of tab view area int viewX = m_view->GetViewRect().x; int viewY = m_view->GetViewRect().y; // Top-left of tab control int tabX = GetX() + viewX; int tabY = GetY() + viewY; int tabHeightInc = 0; if (m_isSelected) { tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); tabY -= tabHeightInc; } dc.SetPen(*wxTRANSPARENT_PEN); // Draw grey background if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR) { if(m_view->GetBackgroundBrush()) dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. #ifdef __WXMOTIF__ dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); #else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); #endif } // Draw highlight and shadow dc.SetPen(*m_view->GetHighlightPen()); // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition()); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); // Vertical highlight: if first tab, draw to bottom of view if (tabX == m_view->GetViewRect().x && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y + m_view->GetViewRect().height)); else if (tabX == m_view->GetViewRect().x) // Not box drawing, just to top of view. dc.DrawLine(tabX, tabY, tabX, (m_view->GetViewRect().y)); else dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis)); dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY); dc.SetPen(*m_view->GetShadowPen()); // Test if we're outside the right-hand edge of the view area if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX)) { int bottomY = m_view->GetViewRect().y + m_view->GetViewRect().height + GetY() + m_view->GetTabHeight() + m_view->GetTopMargin(); // Add a tab height since we wish to draw to the bottom of the view. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), bottomY); // Calculate the far-right of the view, since we don't wish to // draw inside that int rightOfView = m_view->GetViewRect().x + m_view->GetViewRect().width + 1; // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY-1), (tabX + GetWidth()), (bottomY-1)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), bottomY); // Draw the horizontal bit to connect to the view rectangle dc.DrawLine((wxMax((tabX + GetWidth() - m_view->GetHorizontalTabOffset()), rightOfView)), (bottomY), (tabX + GetWidth() + 1), (bottomY)); } else { if (lastInRow) { // 25/5/97 UNLESS it's less than the max number of positions in this row int topY = m_view->GetViewRect().y - m_view->GetTopMargin(); int maxPositions = ((wxTabLayer *)m_view->GetLayers().Item(0)->GetData())->GetCount(); // Only down to the bottom of the tab, not to the top of the view if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; #ifdef __WXMOTIF__ topY -= 1; #endif // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), topY); } else { // Calculate the top of the tab beneath. It's the height of the tab, MINUS // a bit if the tab below (and next col along) happens to be selected. Check. wxTabControl *tabBeneath = NULL; int subtractThis = 0; if (GetColPosition() > 0) tabBeneath = m_view->FindTabControlForPosition(GetColPosition() - 1, GetRowPosition() + 1); if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); #ifdef __WXMOTIF__ subtractThis += 1; #endif // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); // Draw black line to emphasize shadow dc.SetPen(*wxBLACK_PEN); dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1), (tabY + GetHeight() + tabHeightInc - subtractThis)); } } // Draw centered text int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) dc.SetFont(* m_view->GetSelectedTabFont()); else dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); wxCoord textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); int textX = (int)(tabX + (GetWidth() - textWidth)/2.0); if (textX < (tabX + 2)) textX = (tabX + 2); dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight()); dc.DrawText(GetLabel(), textX, textY); dc.DestroyClippingRegion(); if (m_isSelected) { dc.SetPen(*m_view->GetHighlightPen()); // Draw white highlight from the tab's left side to the left hand edge of the view dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc), tabX, (tabY + GetHeight() + tabHeightInc)); // Draw white highlight from the tab's right side to the right hand edge of the view dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc), m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc)); } #else // New HEL version with rounder tabs if (!m_view) return; int tabInc = 0; if (m_isSelected) { tabInc = m_view->GetTabSelectionHeight() - m_view->GetTabHeight(); } int tabLeft = GetX() + m_view->GetViewRect().x; int tabTop = GetY() + m_view->GetViewRect().y - tabInc; int tabRight = tabLeft + m_view->GetTabWidth(); int left = m_view->GetViewRect().x; int top = tabTop + m_view->GetTabHeight() + tabInc; int right = left + m_view->GetViewRect().width; int bottom = top + m_view->GetViewRect().height; if (m_isSelected) { // TAB is selected - draw TAB and the View's full outline dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = left; pnts[n++].y = bottom; pnts[n].x = left; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = top; pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); if (!lastInRow) { dc.DrawLine( (tabRight + 2), top, right, top ); } dc.SetPen(*(m_view->GetShadowPen())); dc.DrawLine( tabRight, tabTop + 2, tabRight, top ); dc.DrawLine( right, top, right, bottom ); dc.DrawLine( right, bottom, left, bottom ); dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (lastInRow) { dc.DrawLine( tabRight + 1, bottom, tabRight + 1, tabTop + 1 ); } else { dc.DrawLine( tabRight + 1, tabTop + 2, tabRight + 1, top ); dc.DrawLine( right + 1, top, right + 1, bottom + 1 ); } dc.DrawLine( right + 1, bottom + 1, left + 1, bottom + 1 ); } else { // TAB is not selected - just draw TAB outline and RH edge // if the TAB is the last in the row int maxPositions = ((wxTabLayer*)m_view->GetLayers().Item(0)->GetData())->GetCount(); wxTabControl* tabBelow = 0; wxTabControl* tabBelowRight = 0; if (GetColPosition() > 0) { tabBelow = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() ); } if (!lastInRow && GetColPosition() > 0) { tabBelowRight = m_view->FindTabControlForPosition( GetColPosition() - 1, GetRowPosition() + 1 ); } float raisedTop = top - m_view->GetTabSelectionHeight() + m_view->GetTabHeight(); dc.SetPen(*(m_view->GetHighlightPen())); wxPoint pnts[10]; int n = 0; pnts[n].x = tabLeft; if (tabBelow && tabBelow->IsSelected()) { pnts[n++].y = (long)raisedTop; } else { pnts[n++].y = top; } pnts[n].x = tabLeft; pnts[n++].y = tabTop + 2; pnts[n].x = tabLeft + 2; pnts[n++].y = tabTop; pnts[n].x = tabRight - 1; pnts[n++].y = tabTop; dc.DrawLines(n, pnts); dc.SetPen(*(m_view->GetShadowPen())); if (GetRowPosition() >= maxPositions - 1) { dc.DrawLine( tabRight, (tabTop + 2), tabRight, bottom ); dc.DrawLine( tabRight, bottom, (tabRight - m_view->GetHorizontalTabOffset()), bottom ); } else { if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight, (long)raisedTop, tabRight, tabTop + 1 ); } else { dc.DrawLine( tabRight, top - 1, tabRight, tabTop + 1 ); } } dc.SetPen(*wxBLACK_PEN); dc.DrawPoint( tabRight, tabTop + 1 ); dc.DrawPoint( tabRight + 1, tabTop + 2 ); if (GetRowPosition() >= maxPositions - 1) { // draw right hand edge to bottom of view dc.DrawLine( tabRight + 1, bottom + 1, tabRight + 1, tabTop + 2 ); dc.DrawLine( tabRight + 1, bottom + 1, (tabRight - m_view->GetHorizontalTabOffset()), bottom + 1 ); } else { // draw right hand edge of TAB if (tabBelowRight && tabBelowRight->IsSelected()) { dc.DrawLine( tabRight + 1, (long)(raisedTop - 1), tabRight + 1, tabTop + 2 ); } else { dc.DrawLine( tabRight + 1, top - 1, tabRight + 1, tabTop + 2 ); } } } // Draw centered text dc.SetPen(*wxBLACK_PEN); if (m_isSelected) { dc.SetFont(*(m_view->GetSelectedTabFont())); } else { dc.SetFont(*(GetFont())); } wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); dc.SetBackgroundMode(wxTRANSPARENT); long textWidth, textHeight; dc.GetTextExtent(GetLabel(), &textWidth, &textHeight); float textX = (tabLeft + tabRight - textWidth) / 2; float textY = (tabInc + tabTop + m_view->GetVerticalTabTextSpacing()); dc.DrawText(GetLabel(), (long)textX, (long)textY); #endif }
void Polecat::Refresh() { if (m_energy == 0) { Explosion(); return; } int tmp = GetMSSinceTimeoutStart(); if (cfg.timeout && tmp > 1000 * (GetTotalTimeout())) { if (!last_fart_time) { std::string txt = Format(_("%s has done something for the environment, he has not ordered the polecat to fart."), ActiveCharacter().GetName().c_str()); Weapon::Message(txt); } SignalTimeout(); } Double norm, angle; if (last_fart_time && last_fart_time + TIME_BETWEEN_FART < GameTime::GetInstance()->Read()) { Fart(); } //When we hit the ground, jump ! if(!IsMoving() && !FootsInVacuum()) { // Limiting number of rebound to avoid desync if(last_rebound_time + TIME_BETWEEN_REBOUND > GameTime::GetInstance()->Read()) { image->SetRotation_rad(0.0); return; } last_rebound_time = GameTime::GetInstance()->Read(); MSG_DEBUG("weapon.polecat", "Jump ! (time = %d)", last_rebound_time); //If the GNU is stuck in ground -> change direction int x = GetX(); int y = GetY(); if(x == save_x && y == save_y) m_sens = -m_sens; save_x = x; save_y = y; //Do the jump norm = RandomSync().GetDouble(1.0, 2.0); PutOutOfGround(); SetSpeedXY(Point2d(m_sens * norm , -norm * THREE)); } //Due to a bug in the physic engine //sometimes, angle==infinite (according to gdb) ?? GetSpeed(norm, angle); angle = RestrictAngle(angle) * ONE_HALF; bool flipped = m_sens == -1; if (flipped) { if (angle > 0) angle -= HALF_PI; else angle += HALF_PI; } image->SetRotation_rad(angle); image->SetFlipped(flipped); image->Scale(ONE, ONE); image->Update(); }
wxRealPoint ExplainShape::GetStartPoint() { wxRealPoint rp(GetX() + GetBitmap().GetWidth() / 2.0 + ARROWMARGIN, GetY() - (GetHeight()-GetBitmap().GetHeight()) / 2.); return rp; }
void nsSVGTextFrame::UpdateGlyphPositioning(PRBool aForceGlobalTransform) { if (mMetricsState == suspended || !mPositioningDirty) return; SetWhitespaceHandling(); nsISVGGlyphFragmentNode* node = GetFirstGlyphFragmentChildNode(); if (!node) return; mPositioningDirty = PR_FALSE; nsISVGGlyphFragmentLeaf *fragment, *firstFragment; firstFragment = node->GetFirstGlyphFragment(); if (!firstFragment) { return; } float x = 0, y = 0; { nsCOMPtr<nsIDOMSVGLengthList> list = GetX(); GetSingleValue(list, &x); } { nsCOMPtr<nsIDOMSVGLengthList> list = GetY(); GetSingleValue(list, &y); } // loop over chunks while (firstFragment) { { nsCOMPtr<nsIDOMSVGLengthList> list = firstFragment->GetX(); GetSingleValue(list, &x); } { nsCOMPtr<nsIDOMSVGLengthList> list = firstFragment->GetY(); GetSingleValue(list, &y); } // check for startOffset on textPath nsSVGTextPathFrame *textPath = firstFragment->FindTextPathParent(); if (textPath) { if (!textPath->GetPathFrame()) { // invalid text path, give up return; } x = textPath->GetStartOffset(); } // determine x offset based on text_anchor: PRUint8 anchor = firstFragment->GetTextAnchor(); float chunkLength = 0.0f; if (anchor != NS_STYLE_TEXT_ANCHOR_START) { // need to get the total chunk length fragment = firstFragment; while (fragment) { float dx = 0.0f; nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDx(); GetSingleValue(list, &dx); chunkLength += dx + fragment->GetAdvance(aForceGlobalTransform); fragment = fragment->GetNextGlyphFragment(); if (fragment && fragment->IsAbsolutelyPositioned()) break; } } if (anchor == NS_STYLE_TEXT_ANCHOR_MIDDLE) x -= chunkLength/2.0f; else if (anchor == NS_STYLE_TEXT_ANCHOR_END) x -= chunkLength; // set position of each fragment in this chunk: fragment = firstFragment; while (fragment) { float dx = 0.0f, dy = 0.0f; { nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDx(); GetSingleValue(list, &dx); } { nsCOMPtr<nsIDOMSVGLengthList> list = fragment->GetDy(); GetSingleValue(list, &dy); } fragment->SetGlyphPosition(x + dx, y + dy, aForceGlobalTransform); x += dx + fragment->GetAdvance(aForceGlobalTransform); y += dy; fragment = fragment->GetNextGlyphFragment(); if (fragment && fragment->IsAbsolutelyPositioned()) break; } firstFragment = fragment; } }
void Sprite::Update(double elapsed, const Map* map) { // Informacion inicial de colision colSprite = NULL; collided = false; // Actualizar animacion this->currentFrame += GetFPS() * elapsed; if (this->currentFrame > this->lastFrame) { this->currentFrame -= (this->lastFrame - this->firstFrame); } else if (this->currentFrame < this->firstFrame) { this->currentFrame += (this->lastFrame - this->firstFrame); } // Actualizar rotacion animada if (IsRotating()) { double rot = elapsed * this->rotatingSpeed; if (rot < this->degreesToRotate) { SetAngle(this->angle + rot); this->degreesToRotate -= rot; } else { SetAngle(this->toAngle); } } // Actualizar movimiento animado if (IsMoving()) { prevX = GetX(); prevY = GetY(); double despX = this->x + elapsed * this->movingSpeedX; double despY = this->y + elapsed * this->movingSpeedY; // x if(this->x - this->toX != 0){ if (this->x < this->toX) { // Right if (despX > this->toX) despX = this->toX; } else if (this->x > this->toX) { // Left if (despX < this->toX) despX = this->toX; } SetX(despX); UpdateCollisionBox(); if (CheckCollision(map)) { SetX(prevX); } } // y if (this->y - this->toY != 0) { if (this->y < this->toY) { // Down if (despY > this->toY) { despY = this->toY; } } else if (this->y > this->toY) { // Up if (despY < this->toY){ despY = this->toY; } } SetY(despY); UpdateCollisionBox(); if (CheckCollision(map)) { SetY(prevY); } } //SetPosition(despX, despY); if (this->x - this->toX == 0 && this->y - this->toY == 0) this->moving = false; } // Informacion final de colision UpdateCollisionBox(); }