今回、携帯画面でいうところの待ち受け画面に当たるものを作ろうと思いまして、以下のようなコードを作ってみました。
Source.cpp
#include "math.h"
#include "DxLib.h"
#include"mtu.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
SetWindowStyleMode(3);
SetBackgroundColor(255, 255, 256);
SetTransColor(255, 255, 256);
SetUseBackBufferTransColorFlag(TRUE);
SetAlwaysRunFlag(TRUE);
SetGraphMode(1920, 1080, 32);
ChangeWindowMode(TRUE);
SetWindowPos(GetMainWindowHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
SetWindowInitPosition(0, -31);
if (DxLib_Init() == -1) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
SetWindowPos(GetMainWindowHandle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
int GazouYomikomiMaisuu, TimekazoeinKannsuumtu, patannhanndanninmtu, yomikomisaidaisuuwokazoeruinmtu, syoppananitimekazoeruinmtu, yomikomusainonamaegimeinmtu[100];
ss(&GazouYomikomiMaisuu, &TimekazoeinKannsuumtu, &patannhanndanninmtu, &yomikomisaidaisuuwokazoeruinmtu, &syoppananitimekazoeruinmtu, yomikomusainonamaegimeinmtu);
while (ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0){
mtu(&GazouYomikomiMaisuu, &TimekazoeinKannsuumtu, &patannhanndanninmtu, &yomikomisaidaisuuwokazoeruinmtu, &syoppananitimekazoeruinmtu, yomikomusainonamaegimeinmtu);
}
DxLib_End(); // DXライブラリ使用の終了処理
return 0; // ソフトの終了
}
void mtu(int *i, int *k, int *ah, int *j, int *t, int h[100]);
void ss(int *i, int *k, int *ah, int *j, int *t, int h[100]);
extern int x[100], y[100], x1, x2, yx, y2;
#include"mtu.h"
#include "DxLib.h"
#include<math.h>
void isk();
void yjn(int i);
void ker(int i, int o, int cr);
void ktn(int b);
void omt(int i, int f, int g);
void ekk(int i, double c, double d);
void tki();
int x[100], y[100], x1, x2, yx, y2;
void ss(int *i, int *k, int *ah, int *j, int *t, int h[100]){
*t = GetNowCount();
*i = 0;
char name[15] = "0.jpg";
while ((h[*i]= LoadGraph(name)) != -1){
GetGraphSize(h[*i], x+ (*i), y + (*i));
sprintf_s(name, 15, "%d.jpg", *i + 1);
*i=(*i)+1;
}
*ah = 0;
*j = *i;
*i = 0;
}
void mtu(int *i, int *k, int *ah, int *j, int *t, int h[100]){
int l;
if ((l = (GetNowCount() - *t)) / 500 <= 5){
yjn(*i);
isk();
omt(*ah, 0, *i);
DrawExtendGraph(x1, yx, x2, y2, h[*i], FALSE);
}
else{
*k = GetNowCount();
int s;
while ((s = GetNowCount() - *k) - 180 < 0){
isk();
omt(*ah, 0, *i);
if (s < 60){
DrawExtendGraph(x1, yx, x2, y2, h[*i], FALSE);
ker(*i, 100, GetColor(0, 0, 0));
}
else if (s < 180){
ker(*i, 420, GetColor(0, 0, 0));
}
else{
ker(*i, 100, GetColor(0, 0, 0));
}
ScreenFlip();
}
if (*i >= *j - 1){
*i = 0;
}
else
{
*i=(*i)+1;
}
DrawBox(x1, yx, x2 + 1, y2 + 1, GetColor(32, 32, 32), TRUE);
omt(*ah, 1, *i);
*ah = (*ah + 1) % 2;
*k = GetNowCount();
while ((s = GetNowCount() - *k) - 180 < 0){
isk();
omt(*ah, 0, *i);
if (s < 60){
ker(*i, 100, GetColor(255, 255, 255));
}
else if (s < 180){
DrawExtendGraph(x1, yx, x2, y2, h[*i], FALSE);
ker(*i, 420, GetColor(255, 255, 255));
}
else{
DrawExtendGraph(x1, yx, x2, y2, h[*i], FALSE);
ker(*i, 250, GetColor(255, 255, 255));
}
ScreenFlip();
}
*t = GetNowCount();
}
ScreenFlip();
}
void isk(){
DrawBox(0, 560, 960, 1041, GetColor(32, 32, 32), TRUE);
DrawBox(660, 567, 960, 1041, GetColor(0, 0, 0), TRUE);
DrawBox(0, 558, 960, 565, GetColor(32, 32, 32), TRUE);
}
void yjn(int i){
if (x[i] >= y[i] && (int)(620 * double(double(y[i]) / x[i])) < 460){
x1 = 10;
x2 = 650;
yx = 800 - (int)(310 * double(y[i]) / x[i]);
y2 = 800 + (int)(310 * double(y[i]) / x[i]);
}
else{
yx = 570;
y2 = 1030;
x1 = 330 - (int)(230 * double(x[i]) / y[i]);
x2 = 330 + (int)(230 * double(x[i]) / y[i]);
}
}
void ker(int i, int o, int cr){
int s, a;
if (x2 - x1 == 640){
s = y2 - yx;
}
else{
s = x2 - x1;
}
int k;
for (k = 0; k <o; k++){
a = x1 + (int)(rand()*(x2 - x1 + 1.0) / (1.0 + RAND_MAX));
DrawLine(a, yx + rand() % 30, a, y2 - rand() % 30, cr);
}
}
void omt(int i, int f, int g){
if (f == 0){
ekk(i, -1, 0);
}
else{
int k;
int s = 0;
int b = 0;
k = GetNowCount();
while ((s = GetNowCount() - k) < 1800){
b++;
isk();
ekk(i, -1, 0);
ScreenFlip();
}
double c, d;
k = GetNowCount();
for (s = 0; s <= b; s++){
DrawBox(x1 - 10, yx - 10, x2 + 10, y2 + 10, GetColor(32, 32, 32), TRUE);
c = (x2 - x1 + 12)*0.5*sin(s*3.14 / (2.0*b));
d = (y2 - yx + 12)*0.5*sin(s*3.14 / (2.0*b));
ekk(i, c, d);
ScreenFlip();
}
ktn(s);
yjn(g);
WaitTimer(500);
for (s = 0; s <= b; s++){
DrawBox(x1 - 10, yx - 10, x2 + 10, y2 + 10, GetColor(32, 32, 32), TRUE);
c = (x2 - x1 + 10)*0.5*cos(s*3.14 / (2.0*b));
d = (y2 - yx + 10)*0.5*cos(s*3.14 / (2.0*b));
ekk((i + 1) % 2, c, d);
ScreenFlip();
}
}
}
void ekk(int i, double c, double d){
if (c == -1){
DrawBox(x1 - 10, yx - 10, x2 + 10, y2 + 10, GetColor(32, 32, 32), TRUE);
if (i == 0){
DrawBox(x1 - 10, yx - 10, x1, yx + 30, GetColor(245, 245, 220), TRUE);
DrawBox(x1 - 10, yx - 10, x1 + 30, yx, GetColor(245, 245, 220), TRUE);
DrawBox(x2, y2 - 30, x2 + 10, y2 + 10, GetColor(245, 245, 220), TRUE);
DrawBox(x2 - 30, y2, x2, y2 + 10, GetColor(245, 245, 220), TRUE);
}
else{
DrawBox(x2, yx - 10, x2 + 10, yx + 30, GetColor(245, 245, 220), TRUE);
DrawBox(x2 - 30, yx - 10, x2 + 10, yx, GetColor(245, 245, 220), TRUE);
DrawBox(x1 - 10, y2 - 30, x1, y2 + 10, GetColor(245, 245, 220), TRUE);
DrawBox(x1, y2, x1 + 30, y2 + 10, GetColor(245, 245, 220), TRUE);
}
}
else{
if (i == 0){
DrawBox(c + x1 - 10, yx - 10 + d, x1 + c, yx + 30 + d, GetColor(245, 245, 220), TRUE);
DrawBox(x1 - 10 + c, yx - 10 + d, x1 + 30 + c, yx + d, GetColor(245, 245, 220), TRUE);
DrawBox(x2 - c, y2 - 30 - d, x2 + 10 - c, y2 + 10 - d, GetColor(245, 245, 220), TRUE);
DrawBox(x2 - 30 - c, y2 - d, x2 - c, y2 + 10 - d, GetColor(245, 245, 220), TRUE);
}
else{
DrawBox(x2 - c, yx - 10 + d, x2 + 10 - c, yx + 30 + d, GetColor(245, 245, 220), TRUE);
DrawBox(x2 - 30 - c, yx - 10 + d, x2 + 10 - c, yx + d, GetColor(245, 245, 220), TRUE);
DrawBox(x1 - 10 + c, y2 - 30 - d, x1 + c, y2 + 10 - d, GetColor(245, 245, 220), TRUE);
DrawBox(x1 + c, y2 - d, x1 + 30 + c, y2 + 10 - d, GetColor(245, 245, 220), TRUE);
}
}
}
void ktn(int b){
int s;
int nhandle = MakeScreen(70, 70, FALSE);
SetDrawScreen(nhandle);
DrawBox(0, 0, 70, 70, GetColor(32, 32, 32), TRUE);
DrawBox(30, 0, 40, 70, GetColor(245, 245, 220), TRUE);
DrawBox(0, 30, 70, 40, GetColor(245, 245, 220), TRUE);
SetDrawScreen(DX_SCREEN_BACK);
for (s = 0; s <= 90; s = s + 10){
DrawRotaGraph((x1 + x2)*0.5, (yx + y2)*0.5, 1.0, s*3.14 / 180.0, nhandle, FALSE);
ScreenFlip();
}
}
Matiuke.cpp
void ss(int *i, int *k, int *ah, int *j, int *t, int h[100]){
*t = GetNowCount();
*i = 0;
char name[15] = "0.jpg";
int m[100];
while ((m[*i]= LoadGraph(name)) != -1){
GetGraphSize(m[*i], x+ (*i), y + (*i));
SetCreateDrawValidGraphMultiSample(4, 2);
h[*i] = MakeScreen(x[*i],y[*i], FALSE);
SetDrawScreen(h[*i]);
DrawGraph(0, 0, m[*i], FALSE);
sprintf_s(name, 15, "%d.jpg", *i + 1);
*i=(*i)+1;
}
*ah = 0;
*j = *i;
*i = 0;
}
・void ktnで作られるグラフィックハンドルに設定されている(こちらはマルチサンプリングの設定を適応させたくないのです)
・初めに何も表示されない(void ktnの処理からは表示されるため、描画対象にするグラフィックハンドルの設定ができてないのではないかと考えています)
という問題点がありまして…。自分では一度画像を読み込ませ、マルチサンプリングの設定を適応させたグラフィックハンドルに描画させ後でそれを表示させる、といったことをするつもりでした。
コードの問題点、やり方(方針)の問題点、解決法などをご教授下さい。