2021-08-23 05:22:56 +00:00
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-08-23 09:25:44 +00:00
|
|
|
|
#include <cmath>
|
2021-08-23 05:22:56 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "iDrawable.h"
|
|
|
|
|
#include "iWritable.h"
|
|
|
|
|
#include "Logger.h"
|
2021-08-23 09:25:44 +00:00
|
|
|
|
#include "Texture.h"
|
2021-08-23 05:22:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace gj {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Game : public iDrawable, public iWritable {
|
|
|
|
|
public:
|
|
|
|
|
Game() = delete;
|
|
|
|
|
Game(Game&&) = delete;
|
|
|
|
|
Game(const Game&) = delete;
|
|
|
|
|
|
|
|
|
|
Game& operator=(Game&&) = delete;
|
|
|
|
|
Game& operator=(const Game&) = delete;
|
|
|
|
|
|
2021-08-23 09:25:44 +00:00
|
|
|
|
Game(iAllocator* alloc, uint32_t w, uint32_t h) :
|
|
|
|
|
alloc_(alloc), w_(w), h_(h), logger_(h), test_(Colorbuffer(alloc, 1, 1)) {
|
|
|
|
|
Colorbuffer temp(alloc_, 5, 5);
|
|
|
|
|
float* ptr = temp.ptr();
|
|
|
|
|
for (size_t i = 0; i < 25; ++i) ptr[i] = i%2*.3+.7;
|
|
|
|
|
test_ = Texture(std::move(temp));
|
2021-08-23 05:22:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update() {
|
|
|
|
|
static int i = 0;
|
|
|
|
|
++i;
|
2021-08-23 09:25:44 +00:00
|
|
|
|
if (i%100 == 0) logger_.Print(L"すべての人類は死滅する: "+std::to_wstring(i));
|
|
|
|
|
|
|
|
|
|
double t = i%200/200.;
|
|
|
|
|
t = 1 - t;
|
|
|
|
|
|
|
|
|
|
mat3 m = mat3{ {.2, 0, 0},{0, .2, 0},{0, 0, 1} };
|
|
|
|
|
|
|
|
|
|
const double s = sin(3.14*2*t*t*t), c = cos(3.14*2*t*t*t);
|
|
|
|
|
m = ::linalg::mul(mat3{{c, -s, 0,}, {s, c, 0}, {0, 0, 1}}, m);
|
|
|
|
|
m = ::linalg::mul(mat3{{ 1, 0, 0,}, {0, 1, 0}, {(1 - t * t * t * 2) * .6, 0, 1}}, m);
|
|
|
|
|
m = ::linalg::mul(mat3{ {1, 0, 0},{0, 16/9., 0},{0, 0, 1} }, m);
|
|
|
|
|
test_.SetMatrix(m);
|
2021-08-23 05:22:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw(Colorbuffer& fb) const override {
|
2021-08-23 09:25:44 +00:00
|
|
|
|
test_.Draw(fb);
|
2021-08-23 05:22:56 +00:00
|
|
|
|
}
|
|
|
|
|
void Write(Textbuffer& fb) const override {
|
|
|
|
|
logger_.Write(fb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2021-08-23 09:25:44 +00:00
|
|
|
|
iAllocator* alloc_;
|
|
|
|
|
|
2021-08-23 05:22:56 +00:00
|
|
|
|
uint32_t w_, h_;
|
|
|
|
|
Logger logger_;
|
2021-08-23 09:25:44 +00:00
|
|
|
|
|
|
|
|
|
Texture test_;
|
2021-08-23 05:22:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|