/* ======================== idMenuScreen_Shell_Playstation::Update ======================== */ void idMenuScreen_Shell_Playstation::Update() { if( menuData != NULL ) { idMenuWidget_CommandBar* cmdBar = menuData->GetCmdBar(); if( cmdBar != NULL ) { cmdBar->ClearAllButtons(); idMenuWidget_CommandBar::buttonInfo_t* buttonInfo; buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 ); if( menuData->GetPlatform() != 2 ) { buttonInfo->label = "#str_00395"; } buttonInfo->action.Set( WIDGET_ACTION_GO_BACK ); buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 ); if( menuData->GetPlatform() != 2 ) { buttonInfo->label = "#str_SWF_SELECT"; } buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED ); } } idSWFScriptObject& root = GetSWFObject()->GetRootObject(); if( BindSprite( root ) ) { idSWFTextInstance* heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" ); if( heading != NULL ) { heading->SetText( "#str_swf_playstation" ); heading->SetStrokeInfo( true, 0.75f, 1.75f ); } idSWFSpriteInstance* gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" ); if( gradient != NULL && heading != NULL ) { gradient->SetXPos( heading->GetTextLength() ); } } if( btnBack != NULL ) { btnBack->BindSprite( root ); } idMenuScreen::Update(); }
CTextInputWidget::CTextInputWidget( CWidget* parent, const types::rect& rect, bool relative , const types::id& id , const std::string& img_file, const std::string& cursor_img_file, bool single_line ) : CWidget( parent, rect, relative, id, img_file ), myText(), myCursorImageFile( cursor_img_file ), myCursorSprite(), myCursorPosition( 0 ), myFocus( false ), myIsPassword( false ) { Initialize( this, single_line ); if( GetSprite() ) mySpriteHandler->SetTextSingleLine( GetSprite(), single_line ); }
// Render // - draw the entity's image at its position /*virtual*/ void Entity::Render( void ) { // Verify the image //assert( m_hImage != SGD::INVALID_HANDLE && "Entity::Render - image was not set!" ); SGD::GraphicsManager* pGraphics = SGD::GraphicsManager::GetInstance(); // Get the current frame int frame = GetSprite()->GetCurrFrame(); // Find the center of the image SGD::Vector center; center.x = GetSprite()->GetFrame(frame).GetFrameRect().right - GetSprite()->GetFrame(frame).GetFrameRect().left; center.y = GetSprite()->GetFrame(frame).GetFrameRect().bottom - GetSprite()->GetFrame(frame).GetFrameRect().top; center.x /= 2; center.y /= 2; // Calculate the rotation SGD::Vector rotate = m_vtVelocity; rotate.Normalize(); float rot = SGD::Vector(0.0f, -1.0f).ComputeSteering(rotate); float rotation = 0; if(rot > 0) rotation = SGD::Vector(0.0f, -1.0f).ComputeAngle(rotate); else rotation = -SGD::Vector(0.0f, -1.0f).ComputeAngle(rotate); // Render AnimationManager::GetInstance()->Render(m_antsAnimation, m_ptPosition.x - Camera::x, m_ptPosition.y - Camera::y, rotation, center); // Why is this here? SGD::Rectangle drawRect = GetRect(); drawRect.left -= Camera::x; drawRect.right -= Camera::x; drawRect.top -= Camera::y; drawRect.bottom -= Camera::y; // HACK: Modify the rotation //m_fRotation += 0.01f; // Draw the image // -- Debugging Mode -- Game* pGame = Game::GetInstance(); if (pGame->IsShowingRects()) SGD::GraphicsManager::GetInstance()->DrawRectangle(drawRect, SGD::Color(128, 255, 0, 0)); }
void HermiteSpline::Destroy() { DestroySprite(GetSprite("start")->ID);//little ones DestroySprite(GetSprite("player")->ID);//player for (int i = 0; i < objectList.size(); i++) { delete objectList[i]; } for (int i = 0; i < curvePoints.size(); i++) { delete curvePoints[i]; } }
void Bullet::Update(float frametime) { if(GetPosition().x < 0) { alive = false; } if(GetPosition().y < 0) { alive = false; } if(GetPosition().x > _state->getApp()->GetWidth()) { alive = false; } if(GetPosition().y > _state->getApp()->GetHeight()) { alive = false; } double radian = GetSprite().getRotation() * (pi / 180); sf::Vector2f direction = sf::Vector2f((float)cos(radian), (float)sin(radian)); GetSprite().move(direction * speed * frametime); }
/* ======================== idMenuWidget_MenuBar::Update ======================== */ void idMenuWidget_MenuBar::Update() { if ( GetSWFObject() == NULL ) { return; } idSWFScriptObject & root = GetSWFObject()->GetRootObject(); if ( !BindSprite( root ) ) { return; } totalWidth = 0.0f; buttonPos = 0.0f; for ( int index = 0; index < GetNumVisibleOptions(); ++index ) { if ( index >= children.Num() ) { break; } if ( index != 0 ) { totalWidth += rightSpacer; } idMenuWidget & child = GetChildByIndex( index ); child.SetSpritePath( GetSpritePath(), va( "btn%d", index ) ); if ( child.BindSprite( root ) ) { PrepareListElement( child, index ); child.Update(); } } // 640 is half the size of our flash files width float xPos = 640.0f - ( totalWidth / 2.0f ); GetSprite()->SetXPos( xPos ); idSWFSpriteInstance * backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" ); if ( backing != NULL ) { if ( menuData != NULL && menuData->GetPlatform() != 2 ) { backing->SetVisible( false ); } else { backing->SetVisible( true ); backing->SetXPos( totalWidth / 2.0f ); } } }
/** Get the size of the sprite of a ship sprite heading west (used for lists) * @param engine The engine to get the sprite from * @param width The width of the sprite * @param height The height of the sprite */ void GetShipSpriteSize(EngineID engine, uint &width, uint &height) { const Sprite *spr = GetSprite(GetShipIcon(engine), ST_NORMAL); width = spr->width; height = spr->height; }
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal) { SpriteID sprite = GetShipIcon(engine); const Sprite *real_sprite = GetSprite(sprite, ST_NORMAL); preferred_x = Clamp(preferred_x, left - real_sprite->x_offs, right - real_sprite->width - real_sprite->x_offs); DrawSprite(sprite, pal, preferred_x, y); }
void Grenade::Render() { // Get the current frame int frame = GetSprite()->GetCurrFrame(); // Find the center of the image SGD::Vector center; center.x = GetSprite()->GetFrame(frame).GetFrameRect().right - GetSprite()->GetFrame(frame).GetFrameRect().left; center.y = GetSprite()->GetFrame(frame).GetFrameRect().bottom - GetSprite()->GetFrame(frame).GetFrameRect().top; center.x /= 2; center.y /= 2; // Render AnimationManager::GetInstance()->Render(m_antsAnimation, m_ptPosition.x - Camera::x, m_ptPosition.y - Camera::y, m_fRotation, center); }
//prints a number in sprite format //must be manually updated with sprite information //0 to 999999 void CGraphics::PrintSpriteNumber(int x, int y, long num){ if (num < 0 || num > 999999) return; GRAPHIC_IMAGE gi; int posX = x; int posY = y; std::string sRef = "0123456789"; std::ostringstream oss; oss << num; std::string sNum = oss.str(); std::string sPrefix; if(sNum.length() < 6) sPrefix.append(6 - sNum.length(), '0'); std::string sScore = sPrefix + sNum; for(int i = 0; i < sScore.size();++i){ for(int j = 0; j < sRef.size(); ++j){ if(sScore.at(i) == sRef.at(j)){ gi = GetSprite(1200 + j); RenderGraphicModulate(gi, posX, posY, 255, 255, 255); posX += gi.width; break; } } } }
void ADefyingGravityCharacter::UpdateAnimation() { const FVector PlayerVelocity = GetVelocity(); const float PlayerSpeed = PlayerVelocity.Size(); // Are we moving or standing still? UPaperFlipbook* DesiredAnimation = (PlayerSpeed > 0.0f) ? catWalkAnimation : idleCatAnimation; if (GetCharacterMovement()->IsFalling()) { DesiredAnimation = JumpCatAnimation; } if( GetSprite()->GetFlipbook() != DesiredAnimation ) { GetSprite()->SetFlipbook(DesiredAnimation); } }
TaskPtr BombGem::explosion() { CCSprite* medium = GetSprite("fuze_1.png"); auto size = this->root->getContentSize(); medium->setAnchorPoint(ccp(0.5f, 0.5f)); //CCPoint pos = g2w_center(this->position); medium->setPosition(ccp(Gem::kGemWidthPixel/2, Gem::kGemHeightPixel/2)); medium->setOpacity(0); this->root->addChild(medium); auto anim = CCAnimationCache::sharedAnimationCache()->animationByName("skill_explosion"); auto hack = this->shared_from_this(); TaskSequencePtr seq = TaskSequence::make(); seq << TaskLambda::make([=]() { medium->setOpacity(255); }) << TaskBatch::make(TaskAnim::make(medium, CCAnimate::create(anim)), TaskAnim::make(this->root, CCFadeOut::create(0.3f))) << TaskLambda::make([=]() { auto self = hack; }); return seq; }
void TToweredTrainUnit::GetDrawRect(TRect *r) { TRect r1; TField *f = GetField(X, Y); TSprite *s = GetSprite(); int rrx = GetRelX(X), rry = GetRelY(Y); int drawx = 28 * (rrx - rry) + LittleX + 28; int drawy = 14 * (rrx + rry - (f->Height)) + LittleY + 14; r->x1 = drawx - s->dx, r->y1 = drawy - s->dy; r->x2 = r->x1 + s->w, r->y2 = r->y1 + s->h; s = UnitsSprites[Type][40 + WpnOrient]; r1.x1 = drawx + SpriteLocators[Type][SpriteOrient*2] - s->dx, r1.y1 = drawy + SpriteLocators[Type][SpriteOrient*2+1] - s->dy; r1.x2 = r1.x1 + s->w, r1.y2 = r1.y1 + s->h; Union(r, &r1); s = GetSmoke(); if (s) { r1.x1 = drawx - s->dx, r1.y1 = drawy - s->dy; r1.x2 = r1.x1 + s->w, r1.y2 = r1.y1 + s->h; Union(r, &r1); } }
GameBall::GameBall() { Load("Resources/Images/Ball.png"); assert(IsLoaded()); GetSprite().setOrigin(15, 15); }
/* ======================== idMenuWidget_InfoBox::ObserveEvent ======================== */ void idMenuWidget_InfoBox::ResetInfoScroll() { idSWFScriptObject & root = GetSWFObject()->GetRootObject(); if ( !BindSprite( root ) || GetSprite() == NULL ){ return; } idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" ); if ( txtBody != NULL ) { txtBody->scroll = 0; } if ( scrollbar != NULL ) { scrollbar->Update(); } }
/* * UnitBottom * * Calculate how low the unit can appear on the screen. * It's partially based on the unit's size. */ int UnitBottom (typUnit *unit) { typSprite *sprite; sprite = GetSprite (unit); return (GetGameHeight () - (sprite[0].height / 2)); }
void CMessageBoxScene::Draw(float dt) { LPD3DXSPRITE pSprite = GetSprite(); LPD3DXFONT pFont = GetFont(); // Darken down any other Scenes that were drawn beneath the popup. float alpha = 1 - GetTransPos(); GetEngine()->DrawColourTint(D3DXCOLOR(0, 0, 0, alpha * 2 / 3)); // compute the sizes RECT scr = GetEngine()->GetWindowRect(); D3DXVECTOR2 scrSize((float)scr.right, (float)scr.bottom); D3DXVECTOR2 textSize = GetTextSize(pFont, mText.c_str()); D3DXVECTOR2 textPos = (scrSize - textSize) / 2; const int VPAD = 16, HPAD = 32; // padding RECT bg; bg.left = (int)textPos.x - HPAD; bg.top = (int)textPos.y - VPAD; bg.right = bg.left + (int)textSize.x + HPAD * 2; bg.bottom = bg.top + (int)textSize.y + VPAD * 2; D3DCOLOR col = D3DCOLOR_ARGB((int)(255 * alpha), 255, 255, 255); pSprite->Begin(D3DXSPRITE_ALPHABLEND); // must have ALPHABLEND or font looks awful // stretch the 8x8 background into its area DrawSprite(pSprite, mpTexture, bg, col); // add text (using the sprite batch) DrawD3DFontEx(pFont, pSprite, mText.c_str(), (int)textPos.x, (int)textPos.y, col); pSprite->End(); }
void TToweredTrainUnit::Draw() { TField *f = GetField(X, Y); TSprite *s, *sst; int rrx = GetRelX(X), rry = GetRelY(Y); int drawx = 28 * (rrx - rry) + LittleX + 28; int drawy = 14 * (rrx + rry - (f->Height)) + LittleY + 14; if ((!SelectCrossLock) && (SelectedUnit == this)) { void *oldb = MapBuf; MapBuf = FullBuf; DrawL2Selector(drawx-LittleX, drawy+28-LittleY, f->Terrain, BmpSelected); MapBuf = oldb; } s = GetSprite(); DrawSprite(drawx, drawy, s); if (ActualSprite < 8/*tj.jsme v rovine*/) { s = UnitsSprites[Type][40 + WpnOrient]; DrawSprite(drawx + SpriteLocators[Type][SpriteOrient*2], drawy + SpriteLocators[Type][SpriteOrient*2+1], s); } s = GetSmoke(); if (s) DrawSprite(drawx, drawy, s); if (iniShowStatusbar && (!StatusbarLock)) { if ((sst = GetStatusBar()) != NULL) { DrawSprite(drawx, drawy, sst); memfree(sst); } } GetDrawRect(&(LD_rect[ID])); LD_used[ID] = TRUE; }
/* ======================== idMenuScreen_Shell_Leaderboards::Update ======================== */ void idMenuScreen_Shell_Leaderboards::Update() { if ( menuData != NULL ) { idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar(); if ( cmdBar != NULL ) { cmdBar->ClearAllButtons(); idMenuWidget_CommandBar::buttonInfo_t * buttonInfo; buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 ); if ( menuData->GetPlatform() != 2 ) { buttonInfo->label = "#str_00395"; } buttonInfo->action.Set( WIDGET_ACTION_GO_BACK ); buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 ); buttonInfo->label = "#str_online_leaderboards_toggle_filter"; buttonInfo->action.Set( WIDGET_ACTION_JOY3_ON_PRESS ); if ( !lbCache->IsLoadingNewLeaderboard() && !lbCache->IsRequestingRows() && options != NULL && options->GetTotalNumberOfOptions() > 0 ) { buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 ); if ( menuData->GetPlatform() != 2 ) { buttonInfo->label = "#str_swf_view_profile"; } buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED ); } } } idSWFScriptObject & root = GetSWFObject()->GetRootObject(); if ( BindSprite( root ) ) { idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" ); if ( heading != NULL ) { heading->SetText( lbCache->GetFilterStrType() ); heading->SetStrokeInfo( true, 0.75f, 1.75f ); } idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" ); if ( gradient != NULL && heading != NULL ) { gradient->SetXPos( heading->GetTextLength() ); } } if ( btnBack != NULL ) { btnBack->BindSprite( root ); } idMenuScreen::Update(); }
void MessageBox::Draw(sf::RenderWindow& rw) { SetPosition(400, 720, true); text.setPosition(GetPosition()); rw.draw(GetSprite()); rw.draw(text); }
Bonus::Bonus(float X, float Y, int W, int H, sf::String Name):GameObject(X, Y, W, H, Name) { if (name == "Daemond") { GetSprite().setTextureRect(sf::IntRect(x, y, w, h)); } //speed = 0; }
void Renderer::Finalize() { GetSprite()->Finalize(); //GetLight()->Finalize(); //GetCamera()->Finalize(); GetTextRenderer()->Finalize(); FinalizeDevice(); }
/* ======================== idMenuWidget_InfoBox::SetScroll ======================== */ void idMenuWidget_InfoBox::SetScroll( int scroll ) { idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" ); if ( txtBody != NULL && scroll <= txtBody->maxscroll ) { txtBody->scroll = scroll; } }
/* ======================== idMenuWidget_InfoBox::GetMaxScroll ======================== */ int idMenuWidget_InfoBox::GetMaxScroll() { idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" ); if ( txtBody != NULL ) { return txtBody->maxscroll; } return 0; }
void Renderer::Initialize() { SetScreenSize(callback::GetScreenSize()); InitializeDevice(); GetTextRenderer()->Initialize(); GetCamera()->Initialize(GetGlobalInstance()->GetDeviceInformation()); GetLight()->Initialize(GetGlobalInstance()->GetDeviceInformation()); GetSprite()->Initialize(GetGlobalInstance()->GetDeviceInformation()); }
CCSprite *makeHeroImg(Hero *hero) { CCSprite *img = GetSprite( hero->profile->bodyPath().c_str()); if(hero->profile->star < 5) img->setScale(1.1); img->setUserData(hero); return img; }
//Рисуем прямоугольник и помещаем на него спрайт void SpriteToQuad(CCallParams& p) { GLfloat blend = 1.0f; if (p.Size() > 7) blend = p.AsFloat(7); CBaseSprite* spr = GetSprite(p.AsString(0)); if (spr == 0)return; spr->DrawQuad((size_t)p.AsInt(1), p.AsFloat(2), p.AsFloat(3), p.AsFloat(4), p.AsFloat(5), p.AsFloat(6), blend); }
/* * UnitTop * * Calculate the maximum height of the unit based on the * radar screen and the sprite size. */ int UnitTop (typUnit *unit) { typSprite *sprite; /* --- Get the sprite --- */ sprite = GetSprite (unit); /* --- Add 1/2 sprite size to radar size. --- */ return (RADAR_HEIGHT + (sprite[0].height / 2)); }
void CModifiedButtonWidget::SetSelectionOn( bool value ) { if( mySelectionOn != value ) { mySelectionOn = value; const std::string animation = mySelectionOn?"select_mouse_out":"mouse_out"; mySpriteHandler->PlayAnimation( GetSprite(), animation ); } }
void AFlappyBirdCharacter::UpdateAnimation() { const FVector PlayerVelocity = GetVelocity(); const float PlayerSpeed = PlayerVelocity.Size(); // Are we moving or standing still? UPaperFlipbook* DesiredAnimation = (PlayerSpeed > 0.0f) ? RunningAnimation : IdleAnimation; GetSprite()->SetFlipbook(DesiredAnimation); }