Skip to content

캐릭터가 화면 밖 좌표로 이동하는 현상 수정#108

Merged
ahyeonkong merged 2 commits intodevelopfrom
fix/#107-limit-character-move-range
Jul 3, 2025
Merged

캐릭터가 화면 밖 좌표로 이동하는 현상 수정#108
ahyeonkong merged 2 commits intodevelopfrom
fix/#107-limit-character-move-range

Conversation

@ahyeonkong
Copy link
Contributor

#️⃣ 연관된 이슈

#107

📝 작업 내용

캐릭터 이동 좌표를 화면 해상도 기준 (0, 0) ~ (1600, 900) 범위로 제한하도록 수정
포탈 이동 시 캐릭터 위치를 좌/우측 적절한 위치(x=50 또는 x=1550, y=450)로 초기화하도록 구현

📷 스크린샷 (선택)

💬 리뷰 요구사항 (선택)

@ahyeonkong ahyeonkong requested a review from Copilot July 2, 2025 14:25
@ahyeonkong ahyeonkong self-assigned this Jul 2, 2025
@ahyeonkong ahyeonkong added the 🐞 BugFix 버그 수정 label Jul 2, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures the character’s position stays within the screen bounds and sets fixed spawn points when using portals.

  • Clamps x and y in move() to the range (0,0)–(1600,900)
  • Initializes portal entry positions to (50,450) on the left or (1550,450) on the right
Comments suppressed due to low confidence (1)

src/main/java/com/chatting/capstone/domain/location/controller/MovementController.java:69

  • Add unit tests covering boundary conditions (e.g., when y is 0 or 900 and x is 0 or 1600) to verify the clamping logic works as expected.
                case "w": y = Math.max(0, y - 1); break;

Comment on lines +69 to +72
case "w": y = Math.max(0, y - 1); break;
case "a": x = Math.max(0, x - 1); break;
case "s": y = Math.min(900, y + 1); break;
case "d": x = Math.min(1600, x + 1); break;
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the magic numbers (0, 1600, 900) into named constants (e.g., MIN_X, MAX_X, MIN_Y, MAX_Y) to improve readability and avoid duplication.

Suggested change
case "w": y = Math.max(0, y - 1); break;
case "a": x = Math.max(0, x - 1); break;
case "s": y = Math.min(900, y + 1); break;
case "d": x = Math.min(1600, x + 1); break;
case "w": y = Math.max(MIN_Y, y - 1); break;
case "a": x = Math.max(MIN_X, x - 1); break;
case "s": y = Math.min(MAX_Y, y + 1); break;
case "d": x = Math.min(MAX_X, x + 1); break;

Copilot uses AI. Check for mistakes.
} else {
// 방향 이동 처리
// 방향 이동 처리(0,0) ~ (1600,900)
switch (message.getDirection()) {
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a default case to the switch to handle any unexpected direction values and prevent silent failures.

Copilot uses AI. Check for mistakes.
Comment on lines +142 to +143
x = "left".equals(message.getPortalDirection()) ? 50 : 1550;
y = 450;
Copy link

Copilot AI Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider defining portal entry positions (50, 1550, 450) as named constants (e.g., PORTAL_LEFT_X, PORTAL_RIGHT_X, PORTAL_Y) for clarity and easier updates.

Suggested change
x = "left".equals(message.getPortalDirection()) ? 50 : 1550;
y = 450;
x = "left".equals(message.getPortalDirection()) ? PORTAL_LEFT_X : PORTAL_RIGHT_X;
y = PORTAL_Y;

Copilot uses AI. Check for mistakes.
@ahyeonkong ahyeonkong merged commit bd461e5 into develop Jul 3, 2025
1 check passed
@ahyeonkong ahyeonkong linked an issue Jul 3, 2025 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 BugFix 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

캐릭터가 화면 밖 좌표로 이동하는 현상 수정

2 participants