//입력 및 경과 처리 함수 public bool update(GameTime gameTime, Frog frog, Map map) { //해당 부분이 클리어가 됐으면(KING) 더는 악어가 나오지 않 게 처리 if (map.isKing(mX, mY)) { mIsSunk = false; mSeq = -1; return(false); } //악어가 떠올라있는데 개구리가 접근하면 개구리 사망처리 if (!mIsSunk && frog.X == mX && frog.Y == mY) { frog.IsDead = true; return(true); } //프레임에 따른 악어 모습 변화 처리 mTimeSinceLastInput += gameTime.ElapsedGameTime.TotalSeconds; if (mTimeSinceLastInput >= MIN_TIME) { mSeq++; if (mSeq > 1) { mSeq = -1; } if (mSeq == -1) { mIsSunk = true; } else { mIsSunk = false; } mTimeSinceLastInput = 0.0; } return(false); }
//입력 및 경과 처리 함수 public void update(GameTime gameTime, Map map, Frog frog) { //개구리가 거북이 위에 있는지 검사, 만약 악어 입 위면 개구리 사망처리 if (frog.X == mX && frog.Y == mY) { mFrogOn = true; if (mIsMouth) { frog.IsDead = true; } } else { mFrogOn = false; } //mSpeed에 맞춰 이동 방향에 알맞게 자신의 좌표(mX,mY)를 증감 //끝에 도달하면 처음으로 돌아가고 만약 개구리가 위에 있으면 개구리 사망처리 //거북이가 물 위를 이동함에 따라 걷기 가능 여부도 변경 mTimeSinceLastInput += gameTime.ElapsedGameTime.TotalSeconds; if (mTimeSinceLastInput >= mSpeed / 1.5) { if (mSeq == 0) { mSeq = 1; } else { mSeq = 0; } } if (mTimeSinceLastInput >= mSpeed) { map.resetWalk(mX, mY); if (mOrigin) // 오른쪽 { if (mX < COL) { mX++; if (mFrogOn) { frog.X++; if (frog.X > COL - 1) { frog.IsDead = true; } } } else { mX = -(mLength - 1); if (mFrogOn) { frog.IsDead = true; } } } else // 왼쪽 { if (mX > -(mLength - 1)) { mX--; if (mFrogOn) { frog.X--; if (frog.X < 0) { frog.IsDead = true; } } } else { mX = COL + mLength; if (mFrogOn) { frog.IsDead = true; } } } mTimeSinceLastInput = 0.0f; } map.setWalk(mX, mY); }
//입력 및 경과 처리 함수 public void update(GameTime gameTime, Map map, Frog frog) { //프레임 변화를 처리하는 루틴(start) //시간이 경과하면 프레임(0~5)을 증가, 만약 5 프레임(완전히 잠김)에 도달하고 개구리가 거북이 위에 있으면 사망처리 mTimeSinceLastFrame += gameTime.ElapsedGameTime.TotalSeconds; if (mTimeSinceLastFrame >= mFrameTime) { if (mIsSunk && !mIsGone) { mSeq++; if (mSeq >= 5) { mIsGone = true; if (mFrogOn) { frog.IsDead = true; } } } mTimeSinceLastFrame = 0.0; } //프레임 변화를 처리하는 루틴(end) //개구리가 거북이 위에 있는지 검사 if (frog.X == mX && frog.Y == mY) { mFrogOn = true; } else { mFrogOn = false; } //mSpeed에 맞춰 이동 방향에 알맞게 자신의 좌표(mX,mY)를 증감 //끝에 도달하면 처음으로 돌아가고 만약 개구리가 위에 있으면 개구리 사망처리 //거북이가 물 위를 이동함에 따라 걷기 가능 여부도 변경 mTimeSinceLastInput += gameTime.ElapsedGameTime.TotalSeconds; if (mTimeSinceLastInput >= mSpeed) { map.resetWalk(mX, mY); if (mOrigin) // 오른쪽 { if (mX < (COL - 1)) { mX++; if (mFrogOn) { frog.X++; if (frog.X > COL - 1) { frog.IsDead = true; } } } else { mX = -(mLength - 1); if (mFrogOn) { frog.IsDead = true; } } } else // 왼쪽 { if (mX > -(mLength - 1)) { mX--; if (mFrogOn) { frog.X--; if (frog.X < 0) { frog.IsDead = true; } } } else { mX = COL; mSeq = 0; mIsGone = false; if (mFrogOn) { frog.IsDead = true; } } } mTimeSinceLastInput = 0.0f; } map.setWalk(mX, mY); }