Пример #1
0
//=============================================================================
// 更新処理
//=============================================================================
void UpdateTimeCounter(void)
{
	if(*GetIsPlay() == true && !*GetIsPause())
	{
		g_nFrameCounter++;
		if(g_nFrameCounter % 6 == 0)
		{
			g_nTimeCounter.fCurrentTime += 0.1f;
			g_nTimeCounter.fPlaybarTime += 0.1f;
		}
	}
	else if(*GetIsStop() == true)
	{
		g_nTimeCounter.fCurrentTime = 0;
		g_nTimeCounter.fPlaybarTime = 0;
	}
	
	// 添加时间轴判断进行时间复位
	if(g_nTimeCounter.fCurrentTime >= *PlaybarNum() * TIME_5)
	{
		g_nTimeCounter.fCurrentTime = 0;
		//g_nTimeCounter.fPlaybarTime = 0;
		bIsTimeReCount = true;
	}

	// ゲームモードだけ表示する
	if(*GetGameMode() == SELECTMODE_PLAY)
	{
		PrintDebugProc("SystemTime : %f\n", g_nTimeCounter.fCurrentTime);
		PrintDebugProc("PlaybarTime : %f\n", g_nTimeCounter.fPlaybarTime);
	}
}
Пример #2
0
//=============================================================================
// 更新処理
//=============================================================================
void UpdateBotton(void)
{
	if(*GetIsStop() == true)
	{
		g_aBotton[BOTTON_PLAY].nAlpha = 255;
		g_aBotton[BOTTON_PAUSE].nAlpha = 0;
	}

	if(*GetGameMode() == SELECTMODE_PLAY)
	{
		if(IsMouseLeftTriggered())
		{
			for(int nCntBot = 0; nCntBot < MAX_BOTTON; nCntBot++)
			{
				if(g_aBotton[nCntBot].bUse)
				{
					if(g_aBotton[nCntBot].nAlpha > 0)
					{
						// 按键碰撞判定
						if(	*g_fBotGetMouX < g_aBotton[nCntBot].fMaxX && *g_fBotGetMouX > g_aBotton[nCntBot].fMinX &&
							*g_fBotGetMouY < g_aBotton[nCntBot].fMaxY && *g_fBotGetMouX > g_aBotton[nCntBot].fMinY)
						{	// 如果按键类型为播放
							if(g_aBotton[nCntBot].nType == BOTTON_PLAY)
							{
								// 被激活代表透明度开始减少
								g_aBotton[BOTTON_PLAY].bIsActiva = true;
								g_aBotton[BOTTON_PAUSE].bIsActiva = false;
								*GetIsPlay() = true;
								*GetIsStop() = false;
								*GetIsPause() = false;
							}
							// 如果按键类型为暂停
							else if(g_aBotton[nCntBot].nType == BOTTON_PAUSE)
							{
								g_aBotton[BOTTON_PLAY].bIsActiva = false;
								g_aBotton[BOTTON_PAUSE].bIsActiva = true;
								*GetIsPause() = true;
							}
							else if(g_aBotton[nCntBot].nType == BOTTON_STOP)
							{
								*GetIsStop() = true;
								*GetIsPlay() = false;
								*GetIsPause() = false;
								GetPlayer()[0].bIsHit = false;
							}
						}
					}
				}
			}
		}
	}

	if(!*GetIsStop())
	{
		if(g_aBotton[BOTTON_PLAY].bIsActiva == true && !g_aBotton[BOTTON_PAUSE].bIsActiva)
		{
			g_aBotton[BOTTON_PLAY].nAlpha -= BOTTON_SWITCH_SPEED;
			if(g_aBotton[BOTTON_PLAY].nAlpha < 0)
				g_aBotton[BOTTON_PLAY].nAlpha = 0;

			g_aBotton[BOTTON_PAUSE].nAlpha += BOTTON_SWITCH_SPEED;
			if(g_aBotton[BOTTON_PAUSE].nAlpha > 255)
				g_aBotton[BOTTON_PAUSE].nAlpha = 255;
		}
		if(g_aBotton[BOTTON_PAUSE].bIsActiva == true && !g_aBotton[BOTTON_PLAY].bIsActiva)
		{
			g_aBotton[BOTTON_PAUSE].nAlpha -= BOTTON_SWITCH_SPEED;
			if(g_aBotton[BOTTON_PAUSE].nAlpha < 0)
				g_aBotton[BOTTON_PAUSE].nAlpha = 0;

			g_aBotton[BOTTON_PLAY].nAlpha += BOTTON_SWITCH_SPEED;
			if(g_aBotton[BOTTON_PLAY].nAlpha > 255)
				g_aBotton[BOTTON_PLAY].nAlpha = 255;
		}
	}

	for(int nCntBot = 0; nCntBot < MAX_BOTTON; nCntBot++)
	{
		if(g_aBotton[nCntBot].bUse)
		{
			SetVertexBotton(nCntBot, 1, 1);
			SetTextureBotton(nCntBot, 0, 1, 1, 1);
			SetColorBotton(nCntBot, D3DCOLOR_RGBA(255, 255, 255, g_aBotton[nCntBot].nAlpha));
		}
	}
}
Пример #3
0
//=============================================================================
// 更新処理
//=============================================================================
void UpdatePlayer(void)
{
	D3DXVECTOR3 nextPos;		//次に移動する位置
	D3DXVECTOR2 Intersection;	//坂道との交点

	// プレーヤー最大範囲と最小範囲の更新
	g_aPlayer[0].fMaxX = g_aPlayer[0].pos.x + g_aPlayer[0].fWidth / 4;
	g_aPlayer[0].fMinX = g_aPlayer[0].pos.x - g_aPlayer[0].fWidth / 4;
	g_aPlayer[0].fMaxY = g_aPlayer[0].pos.y + g_aPlayer[0].fHeight / 2;
	g_aPlayer[0].fMinY = g_aPlayer[0].pos.y - g_aPlayer[0].fHeight / 2;

	if(!*GetIsStop() && !*GetIsPause())
	{
		//移動する処理
		{
			//水平移動に関する
			g_aPlayer[0].bIsHit = false;

			nextPos = D3DXVECTOR3(g_aPlayer[0].pos.x + g_aPlayer[0].move.x, g_aPlayer[0].pos.y, 0.0f);

			//坂との当たった場合
			if(IsHitBySlope(nextPos, &Intersection,  false))
			{
				g_aPlayer[0].bIsHit = true;
			}
			else
			{//坂と当たっていない、かつ坂の上にある場合
				if(g_aPlayer[0].bIsOnSlope)
				{
					//位置補正
					g_aPlayer[0].pos.y = Intersection.y - g_aPlayer[0].size.y / 2;
				}
			}

			//壁に対する当たり判定
			if(IsHitByWall(nextPos,false))
			{
				g_aPlayer[0].bIsHit = true;
				//方向逆転
				g_aPlayer[0].move.x *= -1.0f;
				g_aPlayer[0].bIsChangeDir = g_aPlayer[0].bIsChangeDir ? false : true;
				g_aPlayer[0].bIsGoLeft = !g_aPlayer[0].bIsGoLeft;
			}
			//移動可能な道があるか
			if(g_aPlayer[0].bIsOnfloor)
			{
				//歩く道がなければ
				if(!CheckCanWalk(g_aPlayer[0].move.x, g_aPlayer[0].bIsGoLeft))
				{
					g_aPlayer[0].bIsHit = true;
				}
			}

			if(!g_aPlayer[0].bIsHit)
			{
				//水平移動の移動量を加算
				g_aPlayer[0].pos.x = nextPos.x;
			}

			//垂直移動処理
			nextPos = D3DXVECTOR3(g_aPlayer[0].pos.x, g_aPlayer[0].pos.y + g_aPlayer[0].move.y, 0.0f);
			//坂の上でない場合
			if(g_aPlayer[0].bIsOnSlope == false)
			{
				if(IsHitBySlope(nextPos, &Intersection,true))
				{
					g_aPlayer[0].bIsHit = true;
				}
				else
				{
					if(g_aPlayer[0].bIsOnSlope)
					{
						g_aPlayer[0].pos.y = Intersection.y - g_aPlayer[0].size.y / 2;
					}
				}
			}
			if(IsHitByWall(nextPos,true))
			{
				g_aPlayer[0].bIsHit = true;
			}

			//坂道の上でも、オブジェクトでも当たっていない
			if(g_aPlayer[0].bIsOnSlope == false && g_aPlayer[0].bIsHit == false)
			{
				g_aPlayer[0].pos.y = nextPos.y;
			}
		}

	//アニメション処理
			g_aPlayer[0].nCounterAnim++;
			// 移動方向
			if(g_aPlayer[0].bIsChangeDir == false)
			{
				if( (g_aPlayer[0].nCounterAnim % TIME_CHANGE_PLAYER_MOTION) == 0 )
					g_aPlayer[0].nPatternAnim = (( g_aPlayer[0].nPatternAnim + 1 ) % (NUM_ANIM_PATTERN_X9_Y1 - 1));
				SetVertexPlayer(0, 1, 1);
				SetTexturePlayer(0, g_aPlayer[0].nPatternAnim, NUM_ANIM_PATTERN_X9_Y2, TEX_PATTERN_DIVIDE_X9, TEX_PATTERN_DIVIDE_Y2);
			}
			else
			{
				if( (g_aPlayer[0].nCounterAnim % TIME_CHANGE_PLAYER_MOTION) == 0 )
					g_aPlayer[0].nPatternAnim = (( g_aPlayer[0].nPatternAnim + 1 ) % (NUM_ANIM_PATTERN_X9_Y1 - 1));
				SetVertexPlayer(0, 1, 1);
				SetTexturePlayer(0, g_aPlayer[0].nPatternAnim + NUM_ANIM_PATTERN_X9_Y1, NUM_ANIM_PATTERN_X9_Y2, TEX_PATTERN_DIVIDE_X9, TEX_PATTERN_DIVIDE_Y2);
			}

			if(g_aPlayer[0].bIsHitByGimmick == true)
			{
				if(g_aPlayer[0].bIsChangeDir == false)
				{
					SetVertexPlayer(0, 1, 1);
					SetTexturePlayer(0, NUM_ANIM_PATTERN_X9_Y1 - 1, NUM_ANIM_PATTERN_X9_Y2, TEX_PATTERN_DIVIDE_X9, TEX_PATTERN_DIVIDE_Y2);
				}
				else
				{
					SetVertexPlayer(0, 1, 1);
					SetTexturePlayer(0, NUM_ANIM_PATTERN_X9_Y2 - 1, NUM_ANIM_PATTERN_X9_Y2, TEX_PATTERN_DIVIDE_X9, TEX_PATTERN_DIVIDE_Y2);
				}
			}
		}
	else if(*GetIsStop() == true)
	{
		if(*GetGameMode() != SELECTMODE_PLAYEREDIT)
		{
			g_aPlayer[0].pos = g_aPlayer[0].posSave;
			g_aPlayer[0].fSpeedX = abs(g_aPlayer[0].fSpeedX);
			g_aPlayer[0].bIsChangeDir = false;
		}
		//g_aPlayer[0].bIsHit = false;
		g_aPlayer[0].bIsHitByGimmick = false;
		g_aPlayer[0].bIsOnfloor = false;
		SetVertexPlayer(0, 1, 1);
		SetTexturePlayer(0, 0, NUM_ANIM_PATTERN_X9_Y2, TEX_PATTERN_DIVIDE_X9, TEX_PATTERN_DIVIDE_Y2);
	}

	if(IsPlayerReachGoal(0, 0, 0) == true)
	{
		// 获得当前关卡的号码
		int* nCurrentSceneNum = GetSceneNum();
		int* nLastSceneNum = GetLastSceneNum();

		if(*nCurrentSceneNum > *nLastSceneNum)
			*nLastSceneNum = *nCurrentSceneNum;
		//
		// 获得当前关卡记录 包含关卡数量及是否被攻略
		SCENE* tempScene = GetScene();

		if(!(tempScene[*nCurrentSceneNum].bIsClear))
		{
			tempScene[*nCurrentSceneNum].bIsClear = true;
			(*nLastSceneNum)++;
		}
		*GetIsStop() = true;
		*GetIsPlay() = false;
		SetFade(FADE_OUT, FADE_IN, GAMEMODE_STAGE_SELECT);
	}
}