0~速度で周期的に変化.
bool SampleSpeed()
{
using namespace SDX;
std::vector<std::shared_ptr<Shape>> shapes;
shapes.emplace_back(
new Circle(0, 50, 10));
shapes.emplace_back(
new Rect(0, 150, 20,20));
shapes.emplace_back(
new Line(0, 250, PAI/2 , 20, 5));
std::vector<std::shared_ptr<ISpeed>> speeds;
{
for (int i = 0; i < 3; ++i)
{
speeds[i]->Update();
shapes[i]->MoveA(speeds[i]->
Get() ,0);
shapes[i]->Draw(Color::White, 255);
}
if (Input::key.Return.on) break;
}
return true;
}
bool SampleSpeed2()
{
using namespace SDX;
Rect rect(0, 150, 20, 20);
Line line(0, 250, PAI / 2, 20, 5);
{
liner.Update();
accel.Update();
wave.Update();
circle.Move(liner.Get(), 0);
rect.Move(accel.Get(), 0);
line.Move(wave.Get(), 0);
circle.Draw(Color::White, 255);
rect.Draw(Color::White, 255);
line.Draw(Color::White, 255);
if (Input::key.Return.on) break;
}
return true;
}
double GetLiner(double 経過時間, double 初速, double 使わない引数A, double 使わない引数B)
{
return 初速;
}
double GetAccel(double 経過時間, double 初速, double 加速度, double 使わない引数)
{
return 初速 + 経過時間 * 加速度;
}
double GetWave(double 経過時間, double 速度, double 角速度, double 初角)
{
return std::abs(std::sin(経過時間*角速度 + 初角) * 速度);
}
double GetWave2(double 経過時間, double 速度, double 加速度, double 角速度, double 初角)
{
return std::abs(std::sin(経過時間*角速度 + 初角) * 速度 + 経過時間 * 加速度);
}
bool SampleSpeed3()
{
using namespace SDX;
Rect rect(0, 150, 20, 20);
Line line(0, 250, PAI / 2, 20, 5);
double(*pfunc[3])(double,double,double,double);
pfunc[0] = GetLiner;
pfunc[1] = GetAccel;
pfunc[2] = GetWave;
int time = 0;
{
++time;
circle.Move(pfunc[0](time,1,0,0), 0);
rect.Move(pfunc[1](time, 0, 0.01, 0), 0);
line.Move(pfunc[2](time, 2, 0.1, 0), 0);
circle.Draw(Color::White, 255);
rect.Draw(Color::White, 255);
line.Draw(Color::White, 255);
if (Input::key.Return.on) break;
}
return true;
}