#5
by かずま » 7年前
名無し さんが書きました: ↑7年前
SLEEPだと処理停止してしまうので、スムーズに動くような処理ってどうすればいいでしょうか?
自分の今作ってるコードに組み込みたいので、よろしくお願いします。
情報不足のため、よろしくお願いされません。
停止してしまう処理とはどんなものですか?
今作っているコードとはどんなものですか?
OS は何ですか? Windows それとも Linux?
言語は C++ だそうですが、
コンパイラは何ですか? VC++ それとも gcc?
何かライブラリを使っていますか? DXライブラリ それとも OpenCV?
Windows 10 で Visual Studio 2017 で DXライブラリの例です。
コード:
#include "DxLib.h"
void update(char *str, const char *s, int k)
{
for (int i = 0; i < k; i++)
str[i] = GetRand(9) + '0';
for (int i = k; i < 8; i++)
str[i] = s[i];
str[8] = '\0';
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
int y = 40, t = 0, k = 8;
char str[9];
unsigned c1 = GetColor(0, 255, 0), c2 = GetColor(0, 255, 255);
while (!ScreenFlip() && !ProcessMessage() && !ClearDrawScreen()) {
int t1 = t % 120 - 60;
y = 40 + 0.1 * t1 * t1;
DrawBox(300, y, 300 + 40, y + 30, c1, TRUE);
if (t % 6 == 0) update(str, "12345678", k);
if (k > 0 && t % 30 == 0) k--;
DrawString(100, 100, str, c2);
if (CheckHitKey(KEY_INPUT_ESCAPE)) k = 8;
t++;
}
DxLib_End();
return 0;
}
ESC を押すと、表示がグルグルします。
[quote=名無し post_id=150221 time=1520920548]
SLEEPだと処理停止してしまうので、スムーズに動くような処理ってどうすればいいでしょうか?
自分の今作ってるコードに組み込みたいので、よろしくお願いします。
[/quote]
情報不足のため、よろしくお願いされません。
停止してしまう処理とはどんなものですか?
今作っているコードとはどんなものですか?
OS は何ですか? Windows それとも Linux?
言語は C++ だそうですが、
コンパイラは何ですか? VC++ それとも gcc?
何かライブラリを使っていますか? DXライブラリ それとも OpenCV?
Windows 10 で Visual Studio 2017 で DXライブラリの例です。
[code]
#include "DxLib.h"
void update(char *str, const char *s, int k)
{
for (int i = 0; i < k; i++)
str[i] = GetRand(9) + '0';
for (int i = k; i < 8; i++)
str[i] = s[i];
str[8] = '\0';
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
int y = 40, t = 0, k = 8;
char str[9];
unsigned c1 = GetColor(0, 255, 0), c2 = GetColor(0, 255, 255);
while (!ScreenFlip() && !ProcessMessage() && !ClearDrawScreen()) {
int t1 = t % 120 - 60;
y = 40 + 0.1 * t1 * t1;
DrawBox(300, y, 300 + 40, y + 30, c1, TRUE);
if (t % 6 == 0) update(str, "12345678", k);
if (k > 0 && t % 30 == 0) k--;
DrawString(100, 100, str, c2);
if (CheckHitKey(KEY_INPUT_ESCAPE)) k = 8;
t++;
}
DxLib_End();
return 0;
}
[/code]
ESC を押すと、表示がグルグルします。