フレームレートの違う画面(PC画面145fps、外付けモニタ60fps)でそれぞれ、フレームベースの移動と、時間ベースの移動がどのように変わってくるか確認しよう。
# include <Siv3D.hpp> // OpenSiv3D v0.6.10 Vec2 dPos = { 0,200 }; //ドラゴンの初期位置 Vec2 cPos = { 0,300 }; //ラクダさんの初期位置 Vec2 dVelocity = { 2, 0 };//1frameに2pixel 進む 60fps なので 1s で120pixel Vec2 cVelocity = { 120, 0 };//1s に 120pixel void Update() { //場所などの更新処理 dPos = dPos + dVelocity; cPos = cPos + Scene::DeltaTime() * cVelocity; } void Draw() { //描画関係の処理 TextureAsset(U"dragon").mirrored().resized(64, 64).draw(dPos); TextureAsset(U"rakuda").mirrored().resized(64, 64).draw(cPos); } void Main() { // 背景の色を設定する | Set the background color Scene::SetBackground(ColorF{ 0.6, 0.8, 0.7 }); TextureAsset::Register(U"dragon", U"🦖"_emoji); TextureAsset::Register(U"rakuda", U"🐪"_emoji); // 絵文字からテクスチャを作成する | Create a texture from an emoji //const Texture dragon{ U"🦖"_emoji }; //const Texture chari{ U"🐪"_emoji }; bool isPushStart = false; while (System::Update()) { if (KeySpace.up()) { isPushStart = true; } if (isPushStart) { Update(); Draw(); } } }