i need to go

This commit is contained in:
tildearrow 2022-02-15 18:52:12 -05:00
parent e5d9aed669
commit 7a05f902ea
2 changed files with 66 additions and 1 deletions

View file

@ -169,6 +169,18 @@ const char* pitchLabel[11]={
String getHomeDir(); String getHomeDir();
ImU32 partTest[256];
bool Particle::update() {
pos.x+=speed.x;
pos.y+=speed.y;
speed.x*=friction;
speed.y*=friction;
speed.y+=gravity;
life-=lifeSpeed;
return (life>0);
}
void FurnaceGUI::bindEngine(DivEngine* eng) { void FurnaceGUI::bindEngine(DivEngine* eng) {
e=eng; e=eng;
} }
@ -3511,9 +3523,24 @@ void FurnaceGUI::drawPattern() {
DivChannelState* ch=e->getChanState(i); DivChannelState* ch=e->getChanState(i);
if (ch->portaSpeed>0) { if (ch->portaSpeed>0) {
ImVec4 col=uiColors[GUI_COLOR_PATTERN_EFFECT_PITCH]; ImVec4 col=uiColors[GUI_COLOR_PATTERN_EFFECT_PITCH];
col.w*=0.3; col.w*=0.2;
float width=patChanX[i+1]-patChanX[i]; float width=patChanX[i+1]-patChanX[i];
if (e->isPlaying()) {
particles.push_back(Particle(
partTest,
(ch->portaNote<=ch->note)?ICON_FA_CHEVRON_DOWN:ICON_FA_CHEVRON_UP,
off.x+patChanX[i]+fmod(rand(),width),
off.y+fmod(rand(),MAX(1,ImGui::GetWindowHeight())),
0.0f,
(7.0f+(rand()%5)+ch->portaSpeed)*((ch->portaNote<=ch->note)?1:-1),
0.0f,
1.0f,
255.0f,
18.0f
));
}
for (float j=-patChanSlideY[i]; j<ImGui::GetWindowHeight(); j+=width*0.7) { for (float j=-patChanSlideY[i]; j<ImGui::GetWindowHeight(); j+=width*0.7) {
ImVec2 tMin=ImVec2(off.x+patChanX[i],off.y+j); ImVec2 tMin=ImVec2(off.x+patChanX[i],off.y+j);
ImVec2 tMax=ImVec2(off.x+patChanX[i+1],off.y+j+width*0.6); ImVec2 tMax=ImVec2(off.x+patChanX[i+1],off.y+j+width*0.6);
@ -3547,6 +3574,21 @@ void FurnaceGUI::drawPattern() {
} }
} }
} }
// particle simulation
for (size_t i=0; i<particles.size(); i++) {
Particle& part=particles[i];
if (part.update()) {
dl->AddText(
part.pos,
part.colors[(int)part.life],
part.type
);
} else {
particles.erase(particles.begin()+i);
i--;
}
}
} }
ImGui::PopStyleColor(3); ImGui::PopStyleColor(3);
@ -8425,6 +8467,10 @@ void FurnaceGUI::applyUISettings() {
ImGui::GetStyle()=sty; ImGui::GetStyle()=sty;
for (int i=0; i<256; i++) {
partTest[i]=ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,(float)i/255.0f));
}
// set to 800 for now due to problems with unifont // set to 800 for now due to problems with unifont
static const ImWchar loadEverything[]={0x20,0x800,0}; static const ImWchar loadEverything[]={0x20,0x800,0};

View file

@ -365,6 +365,23 @@ struct UndoStep {
std::vector<UndoPatternData> pat; std::vector<UndoPatternData> pat;
}; };
struct Particle {
ImU32* colors;
const char* type;
ImVec2 pos, speed;
float gravity, friction, life, lifeSpeed;
bool update();
Particle(ImU32* color, const char* ty, float x, float y, float sX, float sY, float g, float fr, float l, float lS):
colors(color),
type(ty),
pos(x,y),
speed(sX,sY),
gravity(g),
friction(fr),
life(l),
lifeSpeed(lS) {}
};
class FurnaceGUI { class FurnaceGUI {
DivEngine* e; DivEngine* e;
@ -515,6 +532,8 @@ class FurnaceGUI {
}; };
std::vector<ActiveNote> activeNotes; std::vector<ActiveNote> activeNotes;
std::vector<Particle> particles;
bool wavePreviewOn; bool wavePreviewOn;
SDL_Scancode wavePreviewKey; SDL_Scancode wavePreviewKey;
int wavePreviewNote; int wavePreviewNote;