Start implementing palette cycler/distorter.
This commit is contained in:
parent
462e4d1295
commit
d1837503e0
@ -1,6 +1,8 @@
|
|||||||
#define OLC_PGE_APPLICATION
|
#define OLC_PGE_APPLICATION
|
||||||
#include "olcPixelGameEngine.h"
|
#include "olcPixelGameEngine.h"
|
||||||
|
|
||||||
|
#define PI 3.14159f
|
||||||
|
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
using namespace olc;
|
using namespace olc;
|
||||||
@ -269,11 +271,45 @@ struct Rom{
|
|||||||
arrayGraphicsData=arrayBlock.decompress();
|
arrayGraphicsData=arrayBlock.decompress();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BackgroundLayer{
|
||||||
|
|
||||||
|
struct Distorter{
|
||||||
|
const float c1{1/512.f};
|
||||||
|
const float c2{8*PI/(1024*256.f)};
|
||||||
|
const float c3{PI/60.f};
|
||||||
|
Sprite&bitmap;
|
||||||
|
Distorter(Sprite&bitmap)
|
||||||
|
:bitmap(bitmap){}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PaletteCycle{
|
||||||
|
std::vector<Pixel>originalCols;
|
||||||
|
std::vector<Pixel>currentCols;
|
||||||
|
byte type,start1,end1,start2,end2,speed,cycleCountdown,cycleCount{};
|
||||||
|
PaletteCycle(BattleBackground&background,BackgroundPalette&palette)
|
||||||
|
:type(background.paletteCycleType),start1(background.paletteCycle1StartInd),end1(background.paletteCycle1EndInd),start2(background.paletteCycle2StartInd),end2(background.paletteCycle2EndInd),speed(background.paletteCycleSpeed/2),cycleCountdown(speed),originalCols(palette.colors),currentCols(originalCols){
|
||||||
|
for(int i:std::views::iota(0U,originalCols.size())){
|
||||||
|
originalCols.emplace_back(originalCols[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
PixelGameEngine*pge;
|
||||||
|
Sprite*spr;
|
||||||
|
Distorter distorter;
|
||||||
|
PaletteCycle cycle;
|
||||||
|
BattleBackground&background;
|
||||||
|
BackgroundGraphics&graphics;
|
||||||
|
BackgroundLayer(PixelGameEngine*pge,uint8_t pgeLayer,uint16_t backgroundInd,std::vector<BattleBackground>&backgrounds,std::vector<BackgroundPalette>&palettes,std::vector<BackgroundGraphics>&graphics)
|
||||||
|
:pge(pge),spr(new Sprite(256,256)),distorter(*spr),background(backgrounds[backgroundInd]),graphics(graphics[background.graphicsInd]),cycle(background,palettes[background.paletteInd]){}
|
||||||
|
};
|
||||||
std::u8string data;
|
std::u8string data;
|
||||||
inline static std::string reversedBytes;
|
inline static std::string reversedBytes;
|
||||||
std::vector<BattleBackground>backgrounds;
|
std::vector<BattleBackground>backgrounds;
|
||||||
std::vector<BackgroundPalette>palettes;
|
std::vector<BackgroundPalette>palettes;
|
||||||
std::vector<BackgroundGraphics>graphics;
|
std::vector<BackgroundGraphics>graphics;
|
||||||
|
BackgroundLayer layer1{nullptr,0U,0U,backgrounds},layer2{nullptr,1U,0U,backgrounds};
|
||||||
Rom(){
|
Rom(){
|
||||||
#pragma region Setup Reversed Bytes
|
#pragma region Setup Reversed Bytes
|
||||||
reversedBytes.resize(256);
|
reversedBytes.resize(256);
|
||||||
@ -320,8 +356,6 @@ public:
|
|||||||
public:
|
public:
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
CreateLayer();
|
|
||||||
EnableLayer(1U,true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,12 +409,17 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BackgroundLayerDisplayTest(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int yOffset{0};
|
int yOffset{0};
|
||||||
|
|
||||||
bool OnUserUpdate(float fElapsedTime) override
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
{
|
{
|
||||||
//PaletteDisplayTest();
|
//PaletteDisplayTest();
|
||||||
GraphicsDisplayTest();
|
//GraphicsDisplayTest();
|
||||||
|
BackgroundLayerDisplayTest();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user