Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ensures the character’s position stays within the screen bounds and sets fixed spawn points when using portals.
- Clamps
xandyinmove()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
yis 0 or 900 andxis 0 or 1600) to verify the clamping logic works as expected.
case "w": y = Math.max(0, y - 1); break;
| 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; |
There was a problem hiding this comment.
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.
| 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; |
| } else { | ||
| // 방향 이동 처리 | ||
| // 방향 이동 처리(0,0) ~ (1600,900) | ||
| switch (message.getDirection()) { |
There was a problem hiding this comment.
Add a default case to the switch to handle any unexpected direction values and prevent silent failures.
| x = "left".equals(message.getPortalDirection()) ? 50 : 1550; | ||
| y = 450; |
There was a problem hiding this comment.
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.
| x = "left".equals(message.getPortalDirection()) ? 50 : 1550; | |
| y = 450; | |
| x = "left".equals(message.getPortalDirection()) ? PORTAL_LEFT_X : PORTAL_RIGHT_X; | |
| y = PORTAL_Y; |
#️⃣ 연관된 이슈
#107
📝 작업 내용
캐릭터 이동 좌표를 화면 해상도 기준 (0, 0) ~ (1600, 900) 범위로 제한하도록 수정
포탈 이동 시 캐릭터 위치를 좌/우측 적절한 위치(x=50 또는 x=1550, y=450)로 초기화하도록 구현
📷 스크린샷 (선택)
💬 리뷰 요구사항 (선택)