void CtfHatActionRenderer::Init( Actor const& actor ) { SpriteCollection const& Sprites = mRenderableRepo( actor.GetId() ); Sprite const& Spr = Sprites( mCtfHatId ); if( Spr.IsValid() ) { mSecsToEnd = Spr.GetSecsToEnd(); } }
void HatActionRenderer::FillRenderableSprites( const Actor& actor, IRenderableComponent const& renderableC, RenderableSprites_t& renderableSprites ) { SpriteCollection const& Sprites = mRenderableRepo( actor.GetId() ); Sprite const& Spr = Sprites( mHatId ); if( Spr.IsValid() ) { SpritePhase const& Phase = Spr( ( int32_t )GetState() ); Opt<PlayerControllerComponent> playerCC = actor.Get<PlayerControllerComponent>(); glm::vec4 col = playerCC.IsValid() ? ColorRepo::Get()( playerCC->mControllerId ) : glm::vec4( 1, 1, 1, 1 ); col.a = GetCloakColor( actor ).a; renderableSprites.push_back( RenderableSprite( &actor, &renderableC, mHatId, &Spr, &Phase, col ) ); } }
void HatActionRenderer::Init( const Actor& actor ) { Opt<Weapon> weapon = actor.Get<IInventoryComponent>()->GetSelectedWeapon(); if ( !weapon.IsValid() ) { return; } SpriteCollection const& Sprites = mRenderableRepo( actor.GetId() ); Sprite const& Spr = Sprites( mHatId ); if( Spr.IsValid() ) { mSecsToEnd = Spr.GetSecsToEnd(); } }
void IdleActionRenderer::Init( const Actor& actor ) { int32_t actorId = actor.GetId(); auto renderableC( actor.Get<IRenderableComponent>() ); actorId = GetSpriteId( renderableC->GetSpriteIndex(), actorId ); SpriteCollection const& Sprites = mRenderableRepo( actorId ); static int32_t aid = AutoId( "body_idle" ); Sprite const& Spr = Sprites( aid ); if( Spr.IsValid() ) { mSpr = &Spr; mSecsToEnd = Spr.GetSecsToEnd(); } }
int main(int ac, char **av) { if(!C2D2_Inicia(800, 600, C2D2_JANELA, C2D2_DESENHO_OPENGL, "Chien 2D v2.0 Megademo")) { printf("Nao conseguiu iniciar a tela. Encerrando.\n"); return 1; } // Inicia o áudio CA2_Inicia(); // Inicia o desenho de primitivas C2D2P_Inicia(); // Obtém o teclado C2D2_Botao *teclado = C2D2_PegaTeclas(); // Indica se deve encerrar o demo bool encerra = false; // Indica o estado do demo int estado = 0; // Carrega os recursos if(Carrega()) { // Toca a música CA2_TocaMusica(mfundo, 1); while(!encerra && !teclado[C2D2_ESC].pressionado && !teclado[C2D2_ENCERRA].pressionado) { switch(estado) { case 0: Intro(); estado++; break; case 1: Primitivas(); estado++; break; case 2: Sprites(); estado++; break; case 3: Estrela(); estado++; break; case 4: Creditos(); estado++; break; case 5: C2D2_TrocaCorLimpezaTela(0,0,0); C2D2_LimpaTela(); if(RelogioDigital(692,552) > 119000) estado++; C2D2_Sincroniza(C2D2_FPS_PADRAO); break; default: encerra=true; } } CA2_PausaMusica(); // DEscarrega os recursos Descarrega(); } else printf("Opa! Falhou algo. Encerrando.\n"); // Encerra tudo CA2_Encerra(); C2D2_Encerra(); return 0; }