申しわけありません。作りかけで汚いですが、張らさせてもらいます。
コード:
#include "DxLib.h"
#define WIN_X 512
#define WIN_Y 384
#define BOX_MAX 8
typedef struct Box_tag
{
int graph;
int x;
int y;
int x2;
int y2;
int size;
int speed;
int cr;
int f;
} Box_t;
Box_t box[BOX_MAX];
Box_t bar;
void Set_Pos(void);
void Set_Graph(void);
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
int i;
ChangeWindowMode( TRUE );
SetGraphMode( WIN_X, WIN_Y, 32 );
if( DxLib_Init() ) return -1;
SetDrawScreen(DX_SCREEN_BACK);
Set_Pos();
while(ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0){
ClearDrawScreen();
//DrawBox(0, 0, WIN_X, WIN_Y, GetColor(0,0,0), TRUE);
bar.y += 3;
Set_Graph();
ScreenFlip();
}
WaitKey();
return 0;
}
void Set_Pos(void)
{
int i;
for(i = 0; i < BOX_MAX; i++){
box[i].size = GetRand(50) + 20;
if(i == 0){
box[0].x = 0;
box[0].y = GetRand(WIN_Y/2) + 100;
box[0].x2 = box[0].x + box[0].size;
box[0].y2 = box[0].y + box[0].size;
box[0].cr = GetColor(30, 30, 30);
} else {
box[i].x = box[i-1].x2;
box[i].y = GetRand(box[i-1].size) + box[i-1].y-20;
box[i].x2 = box[i].x + box[i].size;
box[i].y2 = box[i].y + box[i].size;
box[i].cr = GetColor( 25*(i+1), 25*(i+1), 25*(i+1) );
}
}
bar.size = GetRand(20) + 10;
bar.x = box[BOX_MAX-1].x2;
bar.y = 0;
bar.x2 = bar.x + bar.size;
bar.y2 = bar.y + bar.size;
bar.cr = GetColor(100, 200, 200);
}
void Set_Graph(void)
{
int i;
for(i = 0; i < BOX_MAX; i++){
DrawBox(box[i].x, box[i].y, box[i].x2, box[i].y2, box[i].cr, TRUE);
}
DrawBox(bar.x, bar.y, bar.x2, bar.y2, bar.cr, TRUE);
}