# include <Siv3D.hpp> // OpenSiv3D v0.6.10 # include <vector> #include <string> Vec2 ConvertScrP2MathP(Vec2 _spoint) { Vec2 resultPoint; resultPoint.x = _spoint.x; resultPoint.y = Scene::Height() - _spoint.y; return resultPoint; } void Main() { // 背景の色を設定する | Set the background color Scene::SetBackground(ColorF{ 0.6, 0.8, 0.7 }); Vec2 clickPoint[6] = { {0,0},{0,0},{0,0},{0,0}, {0,0},{0,0} }; //int state = 0;//何個目をクリックしたか int pcount = 0; //今何個目の点? stateだとわかりづらいから変更 Line lines[6]; //5本引いてから、最初の点から最後の点にベクトル引くから6本! int lineNo = 0;//今何本目のベクトル描いているかな? std::string Mess[7]; //座標の表示用に用意しとく(今のところ使ってない) while (System::Update()) { if (MouseR.down())//右クリックしたらリセットするよ { pcount = 0; lineNo = 0; } if (MouseL.down()) { if (あなうめ) {//6個以上は追加させない番人 あなうめ = Cursor::Pos(); Print << pcount << U":" << clickPoint[pcount]; if (pcount > 0) //点が2個以上ならLine配列を追加 { lines[あなうめ] = Line{ あなうめ, うめろ }; うめろ書け; //線を一本増やす } 分かれうめろ; //点のカウンタを増やす } } if(条件埋めて)//点が一個でもあったら、最新の点を黒丸で描画 Circle{ どの点を描く?, 4 }.draw(Palette::Black); for (int i = 0; i < うめて; i++) //lineNo(線の数)分線を引く lines[i].drawArrow(4, { 10, 10 }, Palette::Orange); if(lineNo >= 2) //線の数が2本以上なら、ベクトルを合成(したふりして最初と最後を結ぶ矢印を描く) Line{ はじめのてん, 最後の点}.drawArrow(4, {10, 10}, Palette::Red); } }