Enhances audio effects.Adds TitleScene.

This commit is contained in:
2021-08-27 16:42:58 +09:00
parent ea6fbd572e
commit 55b64ffa45
23 changed files with 1573 additions and 53 deletions

48
src/GlitchPosteffect.h Normal file
View File

@@ -0,0 +1,48 @@
#pragma once
#include <cstring>
#include <cmath>
#include "iDrawable.h"
namespace gj {
class GlitchPosteffect : public iDrawable {
public:
GlitchPosteffect(GlitchPosteffect&&) = delete;
GlitchPosteffect(const GlitchPosteffect&) = delete;
GlitchPosteffect& operator=(GlitchPosteffect&&) = delete;
GlitchPosteffect& operator=(const GlitchPosteffect&) = delete;
GlitchPosteffect() {
}
void Draw(Colorbuffer& fb) const override {
const int32_t w = static_cast<int32_t>(fb.width());
const int32_t h = static_cast<int32_t>(fb.height());
float* ptr = fb.ptr();
for (int32_t y = 0; y < h; ++y) {
const double shift = (XorShift(seed+y)%100/100.*2-1)*maxShift;
const int32_t s = static_cast<int32_t>(w*shift);
if (std::abs(shift) > 1) continue;
const size_t offset = static_cast<size_t>(y) * w;
float* src = ptr + offset;
float* dst = ptr + offset + s;
if (src > dst) std::swap(src, dst);
std::memmove(dst, src, static_cast<size_t>(w) - std::abs(s));
}
}
uint64_t seed = 1;
double maxShift = 0;
};
}