質問させていただきます。
ランダムを使い
0(false)なら(発射しない画像を描画し)5秒のカウントをした後もう一度ランダムへ。
1(true)なら3秒のカウントを(それぞれの画像を描画)した後レーザーを発射しもう一度ランダムへ。(レーザーが発射している時間は2秒です)
ということをしたいのですが、
1(true)のときはちゃんと描画してくれるのに
0(false)のとき、発射しない画像と”3秒前”の画像が被ってしまい
さらに5秒間発射しないという処理も上手くいきません。
5秒間発射しない画像だけを表示したままにして
またランダムをさせるにはどうすればいいか
拙い説明かもしれませんが、よろしくお願いします。
現在のコードです。
#include "DxLib.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
char Key[256];
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定
int map,chara,hassya;//格納用変数
int tim01,tim1,tim2,tim3;//格納用変数tim
int laser1,laser11,laser2,laser22;//格納用変数laser
int count = 0;
bool limit = true;
int rand;
int i,x;
// 画像をロード
map = LoadGraph( "pazzle_field.png" );// マップ画像
tim01 = LoadGraph( "count-01.png" );//発射しない画像
tim3 = LoadGraph( "count-3.png" );//”3秒前”の画像
tim2 = LoadGraph( "count-2.png" );//”2秒前”の画像
tim1 = LoadGraph( "count-1.png" );//”1秒前”の画像
laser1 = LoadGraph( "laser_tate_alarm.png" );//レーザー発射予告、縦
laser11 =LoadGraph( "laser_tate.png" );//レーザー発射、縦
laser2 = LoadGraph( "laser_yoko_alarm.png" );//レーザー発射予告、横
laser22 = LoadGraph( "laser_yoko.png" );//レーザー発射、横
hassya = LoadGraph( "hassya.png" );//”発射!”の画像
chara = LoadGraph( "character.png" );//キャラクターの画像
// while(裏画面を表画面に反映, メッセージ処理, 画面クリア、キー取得、ESCキーで抜ける)
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && !GetHitKeyStateAll( Key ) && !Key[KEY_INPUT_ESCAPE]){
//初期化
if( DxLib_Init() == -1 )
{
return 0;
}
//map
DrawGraph( 0, 0, map, TRUE ); // データハンドルを使って画像を描画
//laser
if( count == 0){
SRand((unsigned int)time(NULL)); // 乱数の初期値をtimeに設定する
rand = GetRand( 1 ); // 乱数を生成する
if( rand == 0){
DrawGraph( 0, 0, tim01, TRUE );
limit = false;
}
else if( rand == 1){
limit = true;
}
}
if( limit = true && rand == 1){
count++;
}
else if( limit = false && rand == 0){
for( i = 0; i == 300; i++){
x++;
}
}
if( limit = true && count <= 60) {
DrawGraph( 0, 0, tim3, TRUE );
DrawGraph( 0, 100, laser1, TRUE );
}
else if( limit = true && count <= 120){
DrawGraph( 0, 0, tim2, TRUE );
DrawGraph( 0, 100, laser1, TRUE );
}
else if( limit = true && count <= 180){
DrawGraph( 0, 0, tim1, TRUE );
DrawGraph( 0, 100, laser1, TRUE );
}
else if( limit = true && count <= 300){
DrawGraph( 0, 0, hassya, TRUE );
DrawGraph( 0, 100, laser11, TRUE );
}
else{
count = 0;
x = 0;
}
//character
DrawGraph( 255, 192, chara, TRUE );//初期位置(仮)
}
DxLib_End(); // DXライブラリ終了処理
return 0;
}