//---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 SpriteComponentUPtr RenderComponentFactory::CreateSpriteComponent(const Vector2& in_size, const MaterialCSPtr& in_material, SizePolicy in_sizePolicy)
 {
     SpriteComponentUPtr pSprite(new SpriteComponent());
     pSprite->SetMaterial(in_material);
     pSprite->SetSizePolicy(in_sizePolicy);
     pSprite->SetSize(in_size);
     return pSprite;
 }
	Sprite *Sprite::Create(std::wstring path)
	{
		Sprite *pSprite(new Sprite);
		if (pSprite->_Init(path))
			return pSprite;
		else
			return nullptr;
	}
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 SpriteComponentUPtr RenderComponentFactory::CreateSpriteComponent(const Vector2& in_size, const TextureAtlasCSPtr& in_textureAtlas, const std::string& in_textureId, const MaterialCSPtr& in_material, SizePolicy in_sizePolicy)
 {
     SpriteComponentUPtr pSprite(new SpriteComponent());
     pSprite->SetMaterial(in_material);
     pSprite->SetTextureAtlas(in_textureAtlas);
     pSprite->SetTextureAtlasId(in_textureId);
     pSprite->SetSizePolicy(in_sizePolicy);
     pSprite->SetSize(in_size);
     
     return pSprite;
 }
Beispiel #4
0
void ending()
{
    /*
      *************************
      * WIN THE GAME SEQUENCE *
      *************************
      0    LINK at ZELDA's side
      288  begin WIPE (8px per side per step, each 5 frames)
      363  WIPE complete, DOT out, A/B items out
      QMisc.colors.link_dot = 255;
      show_subscreen_items = false;
      365  first MESSAGE character in
      371  next character in
      407  last character in
      668  LINK out, ZELDA out
      669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
      733  BLUE flash bg
      734  RED
      735  GREEN
      736  BLACK
      ...
      860  BLACK, LINK out, ZELDA out
      861  LINK in, ZELDA in
      927  first MSG character in
      935  next character in
      1335 last character in
      1461 LINK out, ZELDA out
      1493 begin SCROLL
      */
    
    //get rid off all sprites but Link and Zelda
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    decorations.clear();
    
    music_stop();
    kill_sfx();
    sfx(WAV_ZELDA);
    Quit=0;
    
    game->set_cheat(game->get_cheat() | (cheat>1)?1:0);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    draw_screen_clip_rect_y1=0;
    draw_screen_clip_rect_y2=223;
    //draw_screen_clip_rect_show_link=true;
    //draw_screen_clip_rect_show_guys=false;
    
    for(int f=0; f<365; f++)
    {
        if(f==363)
        {
            //363  WIPE complete, DOT out, A/B items out
            QMisc.colors.link_dot = 255;
            show_subscreen_items = false;
            
            for(int i = guys.Count() - 1; i >= 0; i--)
            {
                if(guys.spr(i)->id > gDUMMY9)
                {
                    guys.del(i);
                }
            }
            
            guys.draw(framebuf,true);
            Link.draw(framebuf);
        }
        
        if(f>=288 && ((f-288)%5 == 0))
        {
            //288  begin WIPE (8px per side per step, each 5 frames)
            //TODO::
            draw_screen_clip_rect_x1+=8;
            draw_screen_clip_rect_x2-=8;
            //draw_screen_clip_rect_show_guys=true;
        }
        
        draw_screen(tmpscr);
        advanceframe(true);
        
        if(Quit) return;
    }
    
    clear_bitmap(msgdisplaybuf);
    draw_screen(tmpscr);
    advanceframe(true);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    //draw_screen_clip_rect_show_guys=false;
    
    char tmpmsg[6][25];
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    strncpy(tmpmsg[x], MsgStrings[QMisc.endstring].s+(24*x), 24);
    }
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x+3], "%.24s", MsgStrings[QMisc.endstring+1].s+(24*x));
        //    strncpy(tmpmsg[x+3], MsgStrings[QMisc.endstring+1].s+(24*x), 24);
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("THANKS LINK,YOU'RE",32,96,6,noproc);
        putendmsg("THE HERO OF HYRULE.",32,112,6,noproc);
    }
    else
    {
        putendmsg(tmpmsg[0],32,80,6,noproc);
        putendmsg(tmpmsg[1],32,96,6,noproc);
        putendmsg(tmpmsg[2],32,112,6,noproc);
    }
    
    for(int f=408; f<927; f++)
    {
        /*
          668  LINK out, ZELDA out
          669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
          733  BLUE flash bg
          734  RED
          735  GREEN
          736  BLACK
          ...
          860  BLACK, LINK out, ZELDA out
          861  LINK in, ZELDA in
          */
        if(f==668)
        {
            rectfill(framebuf,120,129,152,145,0);
            blit(framebuf, tmp_bmp, 120,113, 0,0, 32,32);
        }
        
        if(f==860)
        {
            blit(tmp_bmp, framebuf, 0,0, 120,113, 32,32);
        }
        
        if(f==669 || f==861)
        {
            overtile16(framebuf,36,120,129,6,0);//draw Zelda two-handed overhead
            overtile16(framebuf,BSZ?32:29,136,129,6,0);//draw Link two-handed overhead
        }
        
        if(f==733)
        {
            blit(framebuf,scrollbuf,0,playing_field_offset!=0?168:0,0,0,256,passive_subscreen_height);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(!(framebuf->line[y][x]&15))
                    {
                        framebuf->line[y][x]=16;
                    }
                }
            }
        }
        
        if(f>=733 && f<861)
        {
            static byte flash[4] = {0x12,0x16,0x2A,0x0F};
            RAMpal[16] = NESpal(flash[(f-733)&3]);
            refreshpal=true;
        }
        
        if(f==861)
        {
            blit(scrollbuf,framebuf,0,0,0,playing_field_offset!=0?168:0,256,passive_subscreen_height);
            try_zcmusic((char*)"zelda.nsf", 1, ZC_MIDI_ENDING);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(framebuf->line[y][x]==16)
                    {
                        framebuf->line[y][x]=0;
                    }
                }
            }
        }
        
        if(f>668 && f!=860)
        {
            put_triforce();
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("FINALLY,",96,160,8,put_triforce);
        putendmsg("PEACE RETURNS TO HYRULE.",32,176,8,put_triforce);
        putendmsg("THIS ENDS THE STORY.",48,200,8,put_triforce);
    }
    else
    {
        putendmsg(tmpmsg[3],32,160,6,noproc);
        putendmsg(tmpmsg[4],32,176,6,noproc);
        putendmsg(tmpmsg[5],32,200,6,noproc);
    }
    
    for(int f=1336; f<1492; f++)
    {
        if(f<1461)
        {
            put_triforce();
        }
        
        if(f==1461)
        {
            blit(tmp_bmp,framebuf,0,0,120,113,32,32);
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    clear_bitmap(scrollbuf);
    blit(framebuf,scrollbuf,0,0,0,0,256,224);
    endingpal();
    // draw the brick
    puttile16(scrollbuf,3,256,0,csBOSS,0);
    
    int len=600*2;
    
    if(game->get_quest()>1)
    {
        len=720*2;
    }
    
    int creditsLine=0;
    int endTextLine=0;
    
    const EndingTextLine* endText;
    int numEndTextLines=0;
    int deathsYPos=-1;
    int timeYPos=-1;
    
    switch(game->get_quest())
    {
    case 1:
        endText=quest1End;
        numEndTextLines=numQuest1EndLines;
        break;
        
    case 2:
        endText=quest2End;
        numEndTextLines=numQuest2EndLines;
        deathsYPos=792;
        break;
        
    case 3:
    case 4:
        endText=quest34End;
        numEndTextLines=numQuest34EndLines;
        deathsYPos=792;
        break;
        
    default:
        endText=customQuestEnd;
        numEndTextLines=numCustomQuestEndLines;
        deathsYPos=784;
        timeYPos=800;
        break;
    }
    
    for(int f=0; f<len; f++)
    {
        if(!(f&15))
        {
            int y=(f>>1)+224;
            
            if(y>240 && y<584)
            {
                brick(24,224);
                brick(224,224);
            }
            
            if(y==240 || y==584)
            {
                for(int x=24; x<=224; x+=8)
                {
                    brick(x,224);
                }
            }
            
            if(creditsLine<numCreditsLines)
            {
                if(y==credits[creditsLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               credits[creditsLine].text,
                               credits[creditsLine].xPos,
                               224,
                               credits[creditsLine].color,
                               0);
                    creditsLine++;
                }
            }
            else
            {
                if(endTextLine<numEndTextLines &&
                   y==endText[endTextLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               endText[endTextLine].text,
                               endText[endTextLine].xPos,
                               224,
                               endText[endTextLine].color,
                               0);
                    endTextLine++;
                }
                else if(y==deathsYPos)
                    textprintf_ex(scrollbuf, zfont, 72, 224, red, 0,
                                  "%-8s -%3d", game->get_name(), game->get_deaths());
                else if(y==timeYPos)
                {
                    if(game->get_timevalid() && !game->get_cheat())
                        textout_centre_ex(scrollbuf, zfont, time_str_med(game->get_time()), 128, 224, blue, 0);
                }
            }
        }
        
        if(f==112)                                              // after subscreen has scrolled away
        {
            init_NES_mode();
            loadpalset(9,pSprite(spPILE));
            endingpal();
        }
        
        if(f&1)
        {
            blit(scrollbuf,scrollbuf,0,1,0,0,256,232);
        }
        
        blit(scrollbuf,framebuf,0,0,0,0,256,224);
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
        
        load_control_state();
        rSbtn();
    }