//キーが押されたかどうかを確かめる
bool CheckKeyDown(int KeyCode)
{
	static char OldKeyBuf[256];
	char KeyBuf[256];
	if(OldKeyBuf[KeyCode] == 0)
	{
		GetHitKeyStateAll(KeyBuf);
		if(KeyBuf[KeyCode] == 1)
		{
			OldKeyBuf[KeyCode] = 1;
			return true;
		}else
		{
			OldKeyBuf[KeyCode] = 0;
			return false;
		}
	}else
	{
		GetHitKeyStateAll(KeyBuf);
		if(KeyBuf[KeyCode] == 0)
		{
			OldKeyBuf[KeyCode] = 0;
		}
		return false;
	}
}
Exemple #2
0
void p12(void) {
	SetDrawScreen(DX_SCREEN_BACK);

	int i;
	char keybuf[256];
	int img;

	i = 0;
	img = LoadGraph("pic11.png");

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0 && keybuf[KEY_INPUT_ESCAPE] == 0) {
		ClearDrawScreen();

		DrawRotaGraph(120, 239, 1.0, PI / 4.0, img, TRUE);
		DrawCircle(120, 239, 5, GetColor(255, 0, 0), TRUE);

		DrawRotaGraph(320, 239, 1.0, PI / 180.0 * i, img, TRUE);
		DrawCircle(320, 239, 5, GetColor(255, 0, 0), TRUE);

		DrawRotaGraph2(520, 239, 19, 19, 1.0, PI / 180.0 * i * 2, img, TRUE);
		DrawCircle(520, 239, 5, GetColor(255, 0, 0), TRUE);
		ScreenFlip();

		i++;
	}


}
Exemple #3
0
void Keyboard::update( ) {
	_before_keys = _now_keys;
	if ( _before_keys.buffer[ 28 ] == 1 ) {
		int x = 0;
	}
	GetHitKeyStateAll( _now_keys.buffer );
}
Exemple #4
0
bool Process(char key[256]){
	if(ScreenFlip()!=0) return 0;
	if(ProcessMessage()!=0) return 0;
	if(ClearDrawScreen()!=0) return 0;
	if(GetHitKeyStateAll(key)!=0) return 0;
	return 1;
}
Exemple #5
0
bool Key::KeyState(){
	GetHitKeyStateAll(tmpKey);
	for(int i=0;i<256;i++){
		if(tmpKey[i]==0){
			if(LastKey[i]==0){
				Down_KeyTrigger[i]=false;
				UP_KeyTrigger[i]=false;	
			}else if(LastKey[i]==1){
				Down_KeyTrigger[i]=false;
				UP_KeyTrigger[i]=true;	
			}
			KeyTime[i]=0;
		}
		if(tmpKey[i]==1){
			if(LastKey[i]==0){
				Down_KeyTrigger[i]=true;
				UP_KeyTrigger[i]=false;	
			}else if(LastKey[i]==1){
				Down_KeyTrigger[i]=false;
				UP_KeyTrigger[i]=false;	
			}
			KeyTime[i]++;
		}
		LastKey[i]=tmpKey[i];
	}
	return true;
}
Exemple #6
0
void p9(void) {
	SetDrawScreen(DX_SCREEN_BACK);

	char keybuf[256];

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0 && keybuf[KEY_INPUT_ESCAPE] == 0) {
		ClearDrawScreen();
		DrawLine(10, 10, 200, 10, GetColor(255, 0, 0));
		DrawLine(10, 20, 200, 20, GetColor(0, 255, 0));
		DrawLine(10, 30, 200, 30, GetColor(0, 0, 255));
		SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);	//	αブレンド
		DrawBox(5, 5, 205, 35, GetColor(255, 255, 255), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, TRUE);	//	ブレンドなし
		DrawBox(100, 100, 201, 201, GetColor(255, 0, 0), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_ADD, 255);	//	加算ブレンド
		DrawCircle(150, 150, 50, GetColor(0, 255, 255), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_SUB, 255);	//	減算ブレンド
		DrawCircle(150, 150, 30, GetColor(0, 100, 100), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_INVSRC, 255);	//	反転ブレンド
		DrawOval(300, 200, 30, 25, GetColor(0, 0, 0), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_MULA, 255);	//	乗算ブレンド
		DrawOval(300, 200, 25, 30, GetColor(0, 100, 100), TRUE);
		SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
		DrawPixel(320, 240, GetColor(255, 255, 255));
		DrawTriangle(5, 5, 205, 5, 5, 35, GetColor(0, 0, 0), TRUE);
		DrawTriangle(5, 5, 205, 5, 5, 35, GetColor(255, 255, 255), FALSE);

		ScreenFlip();
	}
}
Exemple #7
0
void Keyboard::Update()
{
	Keyboard& ref = Singleton<Keyboard>::Instance();

	KeyBuffer buffer;
	GetHitKeyStateAll(buffer.data());
	ref.m_states.Save(buffer);
}
//キー入力状態を更新する関数
void keyUpdate()
{
	GetHitKeyStateAll(buf);
	for (int i = 0; i< 256; i++)
	{
		if (buf[i] == 1) keyState[i]++;
		else keyState[i] = 0;
	}
}
Exemple #9
0
int GetHitKeyStateAll_2(){
    char GetHitKeyStateAll_Key[256];
    GetHitKeyStateAll( GetHitKeyStateAll_Key );
    for(int i=0;i<256;i++){
        if(GetHitKeyStateAll_Key[i]==1) stateKey[i]++;
        else                            stateKey[i]=0;
    }
    return 0;
}
Exemple #10
0
void p7(void) {

	SetDrawScreen(DX_SCREEN_BACK);

	int imgs[16];
	int x, y;
	MUKI muki;	//	Œü‚«
	int speed;	//	‘¬“x
	char keybuf[256];

	x = y = 0;
	muki = UP;
	speed = 10;
	LoadDivGraph("pic11.png", 16, 4, 4, 20, 20, imgs);

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0) {
		if (keybuf[KEY_INPUT_ESCAPE]) {
			break;
		}

		if (keybuf[KEY_INPUT_UP]) {
			y -= speed;
			muki = UP;
		}

		if (keybuf[KEY_INPUT_DOWN]) {
			y += speed;
			muki = DOWN;
		}

		if (keybuf[KEY_INPUT_LEFT]) {
			x -= speed;
			muki = LEFT;
		}

		if (keybuf[KEY_INPUT_RIGHT]) {
			x += speed;
			muki = RIGHT;
		}

		
		if (y < 0) {
			y = 0;
		} else if (y > 480 - 20) {
			y = 480 - 20;
		}
		if (x < 0) {
			x = 0;
		} else if (x > 640 - 20) {
			x = 640 - 20;
		}
		
		ClearDrawScreen();
		DrawGraph(x, y, imgs[muki * 4 + (x + y) / 20 % 4], TRUE);
		ScreenFlip();
	}
}
Exemple #11
0
/*キー状態取得*/
void KeyClass::SetHitKey(){
	char TmpKey[256];
	
	GetHitKeyStateAll( TmpKey );

	for( int i=0 ; i<256 ; i++ ){
		if( TmpKey[i] == 1 )	KeyState[i]++;
		else					KeyState[i]=0;
	}
}
void KeyState::Keyupdate(){
	if(GetHitKeyStateAll(Key)==-1){//現在のキー状態を取得
		dprintfln("キー状態の取得に失敗しました");
	}else{
		for(int i=0;i<KEYNUM;i++){
			KeyDown[i]=(Key[i]==1)&&(PreKey[i]==0);
			KeyUp[i]=(Key[i]==0)&&(PreKey[i]==1);
			PreKey[i]=Key[i];
		}
	}
}
Exemple #13
0
int getupKey()
{
	char tmpKey[256];
	GetHitKeyStateAll(tmpKey);
	for (int i = 0; i < 256; i++)
	{
		if (tmpKey[i] != 0)key[i]++;
		else key[i] = 0;
	}
	return 0;
}
Exemple #14
0
void PlayerController::UpdateKey(){
	char tmpKey[256]; // 現在のキーの入力状態を格納する
	GetHitKeyStateAll( tmpKey ); // 全てのキーの入力状態を得る
	for( int i=0; i<256; i++ ){ 
		if( tmpKey[i] != 0 ){ // i番のキーコードに対応するキーが押されていたら
			key[i]++;     // 加算
		} else {              // 押されていなければ
			key[i] = 0;   // 0にする
		}
	}
}
Exemple #15
0
void KeyInput() {
    char tmpKey[256];
    GetHitKeyStateAll( tmpKey );
    for( int i = 0; i < 256; i++) {
        if( tmpKey[i] != 0 ) {
            m_Key[i]++;
        }
        else {
            m_Key[i] = 0;
        }
    }
}
Exemple #16
0
 int gpUpdateKey(int KeyStateBuf[]){
	char tmpKey[256]; // 現在のキーの入力状態を格納する
	GetHitKeyStateAll( tmpKey ); // 全てのキーの入力状態を得る
	for( int i=0; i<256; i++ ){ 
		if( tmpKey[i] != 0 ){ // i番のキーコードに対応するキーが押されていたら
		    KeyStateBuf[i]++;     // 加算
		} else {              // 押されていなければ
			KeyStateBuf[i] = 0;   // 0にする
		}
	}
	return 0;
}
Exemple #17
0
void Input::Update()
{
	char tempKey[256];
	GetHitKeyStateAll(tempKey);

	if(tempKey[KEY_INPUT_UP] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_UP)){
		input[INPUT_UP]++;
	} else input[INPUT_UP] = 0;

	if(tempKey[KEY_INPUT_DOWN] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_DOWN)){
		input[INPUT_DOWN]++;
	} else input[INPUT_DOWN] = 0;

	if(tempKey[KEY_INPUT_RIGHT] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_RIGHT)){
		input[INPUT_RIGHT]++;
	} else input[INPUT_RIGHT] = 0;

	if(tempKey[KEY_INPUT_LEFT] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_LEFT)){
		input[INPUT_LEFT]++;
	} else input[INPUT_LEFT] = 0;


	if(tempKey[KEY_INPUT_Z] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_4)){
		input[INPUT_SHOT]++;
	} else input[INPUT_SHOT] = 0;

	if(tempKey[KEY_INPUT_LCONTROL] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_3)){
		input[INPUT_SLOW]++;
	} else input[INPUT_SLOW] = 0;

	if((tempKey[KEY_INPUT_X] != 0 && tempKey[KEY_INPUT_RIGHT] != 0) || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_6) || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_8)){
		input[INPUT_RIGHTDASH]++;
	} else input[INPUT_RIGHTDASH] = 0;

	if((tempKey[KEY_INPUT_X] != 0 && tempKey[KEY_INPUT_LEFT] != 0) || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_5) || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_7)){
		input[INPUT_LEFTDASH]++;
	} else input[INPUT_LEFTDASH] = 0;

	if((tempKey[KEY_INPUT_LSHIFT] != 0) || GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_2)
	{
		input[INPUT_SATECHANGE]++;
	} else input[INPUT_SATECHANGE] = 0;

	/*
	if((tempKey[KEY_INPUT_LSHIFT] != 0) || GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_2){
		input[INPUT_SATESMASH]++;
	} else input[INPUT_SATESMASH] = 0;
	*/

	if(tempKey[KEY_INPUT_C] != 0 || (GetJoypadInputState( DX_INPUT_PAD1 ) & PAD_INPUT_1)){
		input[INPUT_MENU]++;
	} else input[INPUT_MENU] = 0;
}
Exemple #18
0
void Keyboard_Update()
{
	char tmpKey[256];
	GetHitKeyStateAll(tmpKey);

	for (int i = 0; i<256; i++)
	{
		if (tmpKey[i] != 0)
			m_Key[i]++;
		else
			m_Key[i] = 0;
	}
}
void DxKeyboard::proc()
{
	char buff[ KEY_NUM ] = {};

	GetHitKeyStateAll( buff );

	for( int i=0 ; i < KEY_NUM ; ++i ) {
		if( buff[ i ] != 0 ) {
			m_KeyInput[ i ]++;
		} else {
			m_KeyInput[ i ] = 0;
		}
	}
}
Exemple #20
0
bool checkMomentKey( int key ){
	static bool prevKey[ 256 ] = { false };
	char Buf[ 256 ];
	GetHitKeyStateAll( Buf );
	if( Buf[ key ] == 1 && !prevKey[ key ] ){
		prevKey[ key ] = true;
		return true;
	}else if( Buf[ key ] == 1 ){
		prevKey[ key ] = true;
		return false;
	}
	prevKey[ key ] = false;
	return false;
}
Exemple #21
0
int Keyboard::update(){
	char tmpKey[256];
	GetHitKeyStateAll(tmpKey);
	for(int i = 0; i < 256; i++){
		prevkey[i] = key[i];

		if(tmpKey[i] != 0){//i番のキーが押されたら
			++key[i];
		} else {
			key[i] = 0;
		}
	}
	return 0;
}
Exemple #22
0
/**********************************************************
	AIの行動を返す関数
**********************************************************/
Action taggerTest(int tx,int ty,int Stage[WIDTH][HEIGHT])
{
	//キーが押されているかどうか
	char Buf[ 256 ] ;
	GetHitKeyStateAll( Buf ) ;

	if( Buf[ KEY_INPUT_A ] == 0 ){//Aが押されていない
		int map[WIDTH][HEIGHT];
		double dist=10000;
		int ax,ay;
		for(int i=0;i<WIDTH;i++){
			for(int j=0;j<HEIGHT;j++){
				if(Stage[i][j]==1){
					map[i][j]=-1;
				}else{
					map[i][j]=0;
				}

				if(Stage[i][j]==2){
					int dx=fabs(1.0*i-tx),dy=fabs(1.0*j-ty);
					if(dx+dy<dist){
						dist=dx+dy;
						ax=i;
						ay=j;
					}
				}
			}
		}
		map[tx][ty]=1;
		taggerTestMark(ax,ay,1,map);
		Action go=taggerTestRoute(N,ax,ay,tx,ty,map[ax][ay],map);

		return go;
	}
	else{//Aが押されている
		if( Buf[ KEY_INPUT_UP ] == 1 || Buf[ KEY_INPUT_N ] == 1 )//Nか↑が押されている
			return N;
		else if( Buf[ KEY_INPUT_RIGHT ] == 1 || Buf[ KEY_INPUT_E ] == 1 )//Eか→が押されれている
			return E;
		else if( Buf[ KEY_INPUT_DOWN ] == 1 || Buf[ KEY_INPUT_S ] == 1 )//Sか↓が押されている
			return S;
		else if( Buf[ KEY_INPUT_LEFT ] == 1 || Buf[ KEY_INPUT_W ] == 1 )//Wか←が押されている
			return W;
		else 
			return STOP;//何も押されていない
	}
	return STOP;

}
Exemple #23
0
void Input::Update() {
	//軽くなるかも?
	ClearInputCharBuf();

	//キーボード入力更新
	preKeys.swap(curKeys);
	GetHitKeyStateAll(curKeys.data());

	//パッド入力更新
	pInput = cInput;
	GetJoypadXInputState(DX_INPUT_PAD1, &cInput);

	//パッドのスティック情報初期化
	GetJoypadXInputState(DX_INPUT_PAD1, &stick);
}
Exemple #24
0
bool MyInput::UpdateKey() {
	char tmpKey[256];
	GetHitKeyStateAll(tmpKey);
	for (int i = 0; i < 256; i++) {
		if (tmpKey[i] != 0) {
			keyReleasedCnt[i] = 0;
			keyPressedCnt[i]++;
			if (keyPressedCnt[i] == 1) {
				keyFlag[i] = !keyFlag[i];
			}
		}
		else {
			keyPressedCnt[i] = 0;
			++keyReleasedCnt[i];
		}
	}
	return true;
}
Exemple #25
0
void p6(void) {
	SetDrawScreen(DX_SCREEN_BACK);

	int imgs[16];
	int x, y;
	char keybuf[256];

	x = y = 0;
	LoadDivGraph("pic11.png", 16, 4, 4, 20, 20, imgs);

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0) {
		if (keybuf[KEY_INPUT_ESCAPE]) {
			break;
		}
		if (keybuf[KEY_INPUT_W]) {
			y -= 5;
		}
		if (keybuf[KEY_INPUT_S]) {
			y += 5;
		}
		if (keybuf[KEY_INPUT_A]) {
			x -= 5;
		}
		if (keybuf[KEY_INPUT_D]) {
			x += 5;
		}

		if (y < 0) {
			y = 0;
		} else if (y > 480 - 20) {
			y = 480 - 20;
		}
		if (x < 0) {
			x = 0;
		} else if (x > 640 - 20) {
			x = 640 - 20;
		}

		ClearDrawScreen();
		DrawGraph(x, y, imgs[0], TRUE);
		ScreenFlip();
	}
}
Exemple #26
0
int WINAPI WinMain(HINSTANCE hInsance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	ChangeWindowMode(TRUE); // change window mode

	if (DxLib_Init() == -1) // initialization
	{
		return -1;
	}

	//graphic handle
	int gh;

	//key arrangement
	char key[256];

	//x-coordinate
	int x = 300, y = 240;

	//load graph
	gh = LoadGraph("graph/char.png");

	//set backscreen
	SetDrawScreen(DX_SCREEN_BACK);

	while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0 && GetHitKeyStateAll(key) == 0){

		DrawGraph(x, y, gh, TRUE);

		if (key[KEY_INPUT_UP] == 1){
			y -= 6;
		}
		if (key[KEY_INPUT_DOWN] == 1){
			y += 6;
		}
		if (key[KEY_INPUT_ESCAPE] == 1){
			break;
		}
	}

	DxLib_End(); // end processing

	return 0;
}
Exemple #27
0
// 方向キー押下の判定
int Character::player_input()
{
	char Buf[256];

	GetHitKeyStateAll(Buf);

	// ただしtailのある状態で真逆方向は行けない
	if(Buf[KEY_INPUT_W] == 1 || Buf[KEY_INPUT_UP] == 1){
		if(Player_Length != 0 && IsJustAfterPlayerInit == false &&LATEST_HIT_DIRECT == DOWN)
		{
			return LATEST_HIT_DIRECT;
		}
		//IsJustAfterPlayerInit = false;
		return UP;
	}
	else if(Buf[KEY_INPUT_S] == 1 || Buf[KEY_INPUT_DOWN] == 1){
		if(Player_Length != 0 && IsJustAfterPlayerInit == false && LATEST_HIT_DIRECT == UP)
		{
			return LATEST_HIT_DIRECT;
		}
		//IsJustAfterPlayerInit = false;
		return DOWN;
	}
	else if(Buf[KEY_INPUT_A] == 1 || Buf[KEY_INPUT_LEFT] == 1){
		if(Player_Length != 0 && IsJustAfterPlayerInit == false && LATEST_HIT_DIRECT == RIGHT)
		{
			return LATEST_HIT_DIRECT;
		}
		//IsJustAfterPlayerInit = false;
		return LEFT;
	}
	else if(Buf[KEY_INPUT_D] == 1 || Buf[KEY_INPUT_RIGHT] == 1){
		if(Player_Length != 0 && IsJustAfterPlayerInit == false && LATEST_HIT_DIRECT == LEFT)
		{
			return LATEST_HIT_DIRECT;
		}
		//IsJustAfterPlayerInit = false;
		return RIGHT;
	}
	return LATEST_HIT_DIRECT;
}
// ----------------------------------------------------
//	Key::_CheckKeyEvent
// ----------------------------------------------------
void			KeyBoard::_CheckKeyEvent()
{
	// キーの状態を取得するための変数
	char KeyEvent[256];
	// ------------------------------------------------
	// 取得する
	GetHitKeyStateAll(KeyEvent);
	// 要素数だけループする
	for(int Loop = 0; Loop < 256; Loop++)
	{
		// もし押されていて
		if(KeyEvent[Loop] == 1){
			// 初めて押されてたなら
			if(_KeyInput[Loop] < 0){
				// 0にリセット
				_KeyInput[Loop] = 0;
			}
			// インクリメントする
			_KeyInput[Loop]++;
		}
		// もし押されていなくて
		else{
			// もしキーの値が0なら(初期状態なら)
			if(_KeyInput[Loop] == 0){
				// 無視して続行する
				continue;
			}
			// 初めて離されたなら
			if(_KeyInput[Loop] > 0){
				// 0にリセット
				_KeyInput[Loop] = 0;
			}
			// デクリメントする
			_KeyInput[Loop]--;
		}
	}
	// 終了
	return;
}
Exemple #29
0
void p13(void) {
	SetDrawScreen(DX_SCREEN_BACK);
	char keybuf[256];
	int img;

	int i = 0;
	img = LoadGraph("pic11.png");

	while (ProcessMessage() == 0 && GetHitKeyStateAll(keybuf) == 0 && keybuf[KEY_INPUT_ESCAPE] == 0) {
		ClearDrawScreen();

		SetDrawArea(320 - 80, 240 - 80, 320 + 80, 240 + 80);
		DrawRotaGraph(320, 240, 2.0, - PI / 180.0 * i, img, TRUE);
		DrawCircle(320, 240, 5, GetColor(255, 0, 0), TRUE);
		SetDrawArea(0, 0, 640, 480);
		DrawBox(320 - 81, 240 - 81, 320 + 81, 240 + 81, GetColor(255, 0, 0), FALSE);

		ScreenFlip();

		i++;
	}

}
Exemple #30
0
void p5() {
	SetDrawScreen(DX_SCREEN_BACK);

	int imgs[16];
	int x, y;
	char KeyBuf[256];

	x = y = 0;
	LoadDivGraph("./pic11.png", 16, 4, 4, 20, 20, imgs);

	while (ProcessMessage() == 0 && GetHitKeyStateAll(KeyBuf) == 0) {
		if (KeyBuf[KEY_INPUT_ESCAPE]){
			break;
		}

		if (KeyBuf[KEY_INPUT_UP]) {
			y -= 5;
		}

		if (KeyBuf[KEY_INPUT_DOWN]) {
			y += 5;
		}

		if (KeyBuf[KEY_INPUT_LEFT]) {
			x -= 5;
		}

		if (KeyBuf[KEY_INPUT_RIGHT]) {
			x += 5;
		}

		ClearDrawScreen();
		DrawGraph(x, y, imgs[0], TRUE);
		ScreenFlip();
	}

}