Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Bonus::Bonus( const std::string& theName, sf::Texture& mainTex, sf::Texture& shineTex, sf::Vector2f pos )
- : name( theName ),
- doesShine( true ),
- shineCounter( 0 )
- {
- spr.SetTexture( mainTex );
- spr.SetPosition( pos );
- shineSpr.SetTexture( shineTex );
- shineSpr.SetPosition( pos.x + 10, pos.y + 4 );
- shineSpr.SetScale( 0.1, 0.1 );
- shineSpr.SetOrigin( 10, 4 );
- }
- void Bonus::Render( sf::RenderWindow& window )
- {
- Object::Render( window );
- if ( ( shineCounter == 0 and rand() % 750 == 0 ) or shineCounter > 0 )
- {
- ++shineCounter;
- float scale = shineSpr.GetScale().x;
- if ( shineCounter < 25 / 2.f )
- {
- scale += 0.1;
- }
- else
- {
- scale -= 0.1;
- }
- shineSpr.SetScale( scale, scale );
- shineSpr.Rotate( 5 );
- }
- if ( shineCounter > 0 and shineCounter <= 25 )
- {
- window.Draw( shineSpr );
- }
- else if ( shineCounter > 25 )
- {
- shineCounter = 0;
- shineSpr.SetScale( 0.1, 0.1 );
- shineSpr.SetRotation( 0 );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement