Add in some layer encapsulation and prepare drawing tick.
This commit is contained in:
parent
99dde2e607
commit
bbeac33ad6
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cstdint": "cpp"
|
||||
}
|
||||
}
|
@ -342,8 +342,9 @@ struct Rom{
|
||||
BattleBackground&background;
|
||||
BackgroundGraphics&graphics;
|
||||
PaletteCycle cycle;
|
||||
uint_fast16_t backgroundInd;
|
||||
BackgroundLayer(PixelGameEngine*pge,uint_fast16_t backgroundInd,std::vector<BattleBackground>&backgrounds,std::vector<BackgroundPalette>&palettes,std::vector<BackgroundGraphics>&graphics,std::u8string_view data)
|
||||
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){
|
||||
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),backgroundInd(backgroundInd),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){
|
||||
uint_fast32_t effectVal{((background.GetAnimation()>>16)&0xFF)};
|
||||
if(effectVal==0)effectVal=(((background.GetAnimation()>>24)&0xFF));
|
||||
distorter.effect=std::make_unique<DistortionEffect>(data,effectVal);
|
||||
@ -354,7 +355,20 @@ struct Rom{
|
||||
std::vector<BattleBackground>backgrounds;
|
||||
std::vector<BackgroundPalette>palettes;
|
||||
std::vector<BackgroundGraphics>graphics;
|
||||
|
||||
const BackgroundLayer*const GetLayer1(){return layer1.get();}
|
||||
const BackgroundLayer*const GetLayer2(){return layer2.get();}
|
||||
void SetLayer1(uint_fast16_t backgroundInd){
|
||||
backgroundInd=std::clamp(backgroundInd,0U,uint_fast16_t(backgrounds.size()));
|
||||
layer1=std::make_unique<BackgroundLayer>(nullptr,backgroundInd,backgrounds,palettes,graphics,data);
|
||||
}
|
||||
void SetLayer2(uint_fast16_t backgroundInd){
|
||||
backgroundInd=std::clamp(backgroundInd,0U,uint_fast16_t(backgrounds.size()));
|
||||
layer2=std::make_unique<BackgroundLayer>(nullptr,backgroundInd,backgrounds,palettes,graphics,data);
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<BackgroundLayer>layer1,layer2;
|
||||
public:
|
||||
Rom(){
|
||||
#pragma region Setup Reversed Bytes
|
||||
reversedBytes.resize(256);
|
||||
@ -457,17 +471,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void BackgroundLayerDisplayTest(){
|
||||
|
||||
}
|
||||
|
||||
int yOffset{0};
|
||||
float accumulatedTime{};
|
||||
|
||||
void runTick(){
|
||||
float alpha1{1.f},alpha2{1.f};
|
||||
if(rom.GetLayer1()->backgroundInd&&!rom.GetLayer2()->backgroundInd){
|
||||
alpha1=1.f;
|
||||
alpha2=0.f;
|
||||
}
|
||||
if(!rom.GetLayer1()->backgroundInd&&rom.GetLayer2()->backgroundInd){
|
||||
alpha1=0.f;
|
||||
alpha2=1.f;
|
||||
}
|
||||
}
|
||||
|
||||
bool OnUserUpdate(float fElapsedTime) override
|
||||
{
|
||||
//PaletteDisplayTest();
|
||||
//GraphicsDisplayTest();
|
||||
//BackgroundLayerDisplayTest();
|
||||
accumulatedTime+=fElapsedTime;
|
||||
while(accumulatedTime>=1/60.f){
|
||||
runTick();
|
||||
accumulatedTime-=1/60.f
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user