- Life(하트) 기능 추가
- 스테이지 이동
- 리팩토링 : stage 객체 수정, 더 이상 stage 객체에서 player 상태 변경 하지 않음, player 또한 stage 객체의 블록을 직접 수정하지 않고 get, set 메소드를 사용
'develop-note > MarioGame' 카테고리의 다른 글
MarioGame 스크롤 버그 (0) | 2020.03.05 |
---|---|
MarioGame UML (0) | 2020.03.03 |
- Life(하트) 기능 추가
- 스테이지 이동
- 리팩토링 : stage 객체 수정, 더 이상 stage 객체에서 player 상태 변경 하지 않음, player 또한 stage 객체의 블록을 직접 수정하지 않고 get, set 메소드를 사용
MarioGame 스크롤 버그 (0) | 2020.03.05 |
---|---|
MarioGame UML (0) | 2020.03.03 |
맵을 렌더링 할때 발생한 것으로 보임
렌더링 코드를 살펴보면
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
void CStage::Render()
{
/*
맵은 스크톨 처리하여, 현재 플레이어가 이동한 위치로부터 맵을 출력해줌
출력 크기는 세로 4칸 가로 10칸으로 해줌
0 : 벽
1 : 길
2 : 시작점
3 : 도착점
4 : 코인
*/
CPlayer* pPlayer = CObjectManager::GetInst()->GetPlayer();
int player_Coin = pPlayer->GetCoin();
//플레이어의 x,y 좌표를 얻어온다
int player_iX = pPlayer->GetX();
int player_iY = pPlayer->GetY();
// 맵의 출력은 플레이어의 위치를 중심으로 출력
// 세로는 플레이어 2칸위부터 한칸 아래까지 출력
// 총 4줄이 출력되는것이다
// 가로는 플레이어 위치부터 오른쪽 10칸 까지 출력함
constexpr int iClientPadding_left = 0;
constexpr int iClientPadding_Top = -2;
constexpr int iClientPadding_Right = 9;
constexpr int iClientPadding_Bottom = 1;
int iClientHeight_start = player_iY + iClientPadding_Top;
int iClientHeight_end = player_iY + iClientPadding_Bottom;
int iClientWidth_start = player_iX + iClientPadding_left;
int iClientWidth_end = player_iX + iClientPadding_Right;
for (int i = iClientHeight_start; i <= iClientHeight_end; ++i)
{
for (int j = iClientWidth_start; j < iClientWidth_end; ++j)
{
if (i == player_iY && j == player_iX)
{
std::cout << "§";
}
else if (m_cStage[i][j] == SBT_WALL)
{
std::cout << "■";
}
else if (m_cStage[i][j] == SBT_ROAD)
{
std::cout << " ";
}
else if (m_cStage[i][j] == SBT_START)
{
std::cout << "☆";
}
else if (m_cStage[i][j] == SBT_END)
{
std::cout << "★";
}
else if (m_cStage[i][j] == SBT_COIN)
{
std::cout << "◎";
}
}
std::cout << std::endl;
}
std::cout << "coin : "<< player_Coin << std::endl;
std::cout << "Left : ← " << " Right : → " << std::endl;
std::cout << "Jump : space bar "<< std::endl;
}
|
cs |
31,32라인에 있는 iClientWidth, iClientHeight 가 곧 게임 클라이언트 화면의 가로 세로를 나타낸다
실제 맵 사이즈는 g_iMapWidth = 50, g_iMapHeight = 10 이며
iClientWidth_start , iClientWidth_end 는 각각, 맵에서 실제로 보여줄 가로 시작지점과 가로 끝점을 나타내고
iClientHeight_start, iClientHeight_end 는 각각, 맵에서 실제로 보여줄 세로 시작지점과 세로 끝점을 나타낸다
즉 그림으로 보면 아래와 같다
위에 버그는 iClientWidth_start 값과 iClientWidth_end 값이 일정 범위 안으로(맵의 끝에 도달하려고 했을때) 들어가면
고정된값들이 되야 하는데, 그러지 않고 맵의 처음(0)부터 다시 출력 하게 되서 버그가 발생한듯함
즉 아래와 같은 코드가 들어가야 한다
//맵 끝에 거의 도달했을때 가로 스크롤 멈춤
//클라이언트 시작 지점이 최대 시작지점(맵 가로길이 - 클라이언트 오른쪽 여백) 보다 크거나 같을때
//클라이언트 시작 지점 = 최대 시작지점(맵 가로길이 - 클라이언트 오른쪽 여백)
if (iClientWidth_start >= g_iMAP_WIDTH - iClientPadding_Right)
{
iClientWidth_start = g_iMAP_WIDTH - iClientPadding_Right;
}
//클라이언트 끝 지점이 최대 끝지점 (맵의 길이)보다 클때
//클라이언트 끝 지점 = 최대 끝 지점(맵의 가로길이)
if (iClientWidth_end > g_iMAP_WIDTH)
{
iClientWidth_end = g_iMAP_WIDTH;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
void CStage::Render()
{
/*
맵은 스크톨 처리하여, 현재 플레이어가 이동한 위치로부터 맵을 출력해줌
출력 크기는 세로 4칸 가로 10칸으로 해줌
0 : 벽
1 : 길
2 : 시작점
3 : 도착점
4 : 코인
*/
CPlayer* pPlayer = CObjectManager::GetInst()->GetPlayer();
int player_Coin = pPlayer->GetCoin();
//플레이어의 x,y 좌표를 얻어온다
int player_iX = pPlayer->GetX();
int player_iY = pPlayer->GetY();
// 맵의 출력은 플레이어의 위치를 중심으로 출력
// 세로는 플레이어 2칸위부터 한칸 아래까지 출력
// 총 4줄이 출력되는것이다
// 가로는 플레이어 위치부터 오른쪽 10칸 까지 출력함
constexpr int iClientPadding_left = 0;
constexpr int iClientPadding_Top = -2;
constexpr int iClientPadding_Right = 9;
constexpr int iClientPadding_Bottom = 1;
int iClientHeight_start = player_iY + iClientPadding_Top;
int iClientHeight_end = player_iY + iClientPadding_Bottom;
int iClientWidth_start = player_iX + iClientPadding_left;
int iClientWidth_end = player_iX + iClientPadding_Right;
//맵 끝에 거의 도달했을때 가로 스크롤 멈춤
if (iClientWidth_start >= g_iMAP_WIDTH - iClientPadding_Right)
{
iClientWidth_start = g_iMAP_WIDTH - iClientPadding_Right;
}
if (iClientWidth_end > g_iMAP_WIDTH)
{
iClientWidth_end = g_iMAP_WIDTH;
}
for (int i = iClientHeight_start; i <= iClientHeight_end; ++i)
{
for (int j = iClientWidth_start; j < iClientWidth_end; ++j)
{
if (i == player_iY && j == player_iX)
{
std::cout << "§";
}
else if (m_cStage[i][j] == SBT_WALL)
{
std::cout << "■";
}
else if (m_cStage[i][j] == SBT_ROAD)
{
std::cout << " ";
}
else if (m_cStage[i][j] == SBT_START)
{
std::cout << "☆";
}
else if (m_cStage[i][j] == SBT_END)
{
std::cout << "★";
}
else if (m_cStage[i][j] == SBT_COIN)
{
std::cout << "◎";
}
}
std::cout << std::endl;
}
std::cout << "coin : "<< player_Coin << std::endl;
std::cout << "Left : ← " << " Right : → " << std::endl;
std::cout << "Jump : space bar "<< std::endl;
}
|
cs |
버그 해결 완료
MarioGame 최근 업데이트 2020_03_07 (0) | 2020.03.07 |
---|---|
MarioGame UML (0) | 2020.03.03 |
Core : 매니저 클래스들 초기화, 게임 실행 준비, 소멸시, 매니저 클래스들 자원 해제
MapManager : Stage들을 초기화, Stage 선택
Stage : FileStream 객체를 사용하여, Stage 파일 읽기, 맵 로딩
FileStream : 파일 한줄씩 읽기 및 쓰기
ObjectManager : 플레이어 생성, 생성된 플레이어 인스턴스 가져오기
Player : 코인점수 관리, 플레이어 떨어졌는지, 허공에 있는지 여부 확인, 왼쪽, 오른쪽에 벽이 있는지 확인
지금, Stage 객체와 MapManager 객체에 맞지 않은 기능들(GameWin, GameOver)이 있다
GameWin, GameOver 를 관리해주는 다른 매니저 클래스가 필요할 것 같다
StateManager : GameOver, PlayerWin 상태 관리
MarioGame 최근 업데이트 2020_03_07 (0) | 2020.03.07 |
---|---|
MarioGame 스크롤 버그 (0) | 2020.03.05 |
Reloading System
1stWeaponAmmo/BagRifleAmmo
- BagRifleAmmo == 0
ex 1) 0/0 -> 불가능
ex 2) 25/0 -> 불가능
1stWeaponAmmo + BagRifleAmmo < MaxAmmo and BagRifleAmmo < ProvideAmmo
ex 3) 0/25 -> 1stWeaponAmmo = BagRifleAmmo, BagRifleAmmo = 0
-> 25/0
1stWeaponAmmo + BagRifleAmmo < MaxAmmo and BagRifleAmmo >= MaxAmmo
ex 4) 0/40 ->1stWeaponAmmo = MaxAmmo, BagRifleAmmo = BagRifleAmmo - MaxAmmo
-> 30/10
1stWeaponAmmo > 0 and BagRifleAmmo >= MaxAmmo
ex 5) 25/30 -> 1stWeaponAmmo = MaxAmmo ,
BagRifleAmmo = BagRifleAmmo - (MaxAmmo - 1stWeaponAmmo)
-> 30/25
ex 6) 25/110 -> 1stWeaponAmmo = MaxAmmo ,
BagRifleAmmo = BagRifleAmmo - (MaxAmmo - 1stWeaponAmmo)
-> 30/105
1stWeaponAmmo > 0 and BagRifleAmmo < MaxAmmo
ex 7) 25/28-> 1stWeaponAmmo = MaxAmmo ,
BagRifleAmmo = BagRifleAmmo - (MaxAmmo - 1stWeaponAmmo)
-> 30/23
1stWeaponAmmo + BagRifleAmmo < MaxAmmo
Ex 8) 24/5 ->
-> 29/0
Customize Skin 동기화 버그 (0) | 2019.08.20 |
---|
Lobby 화면에서 PlayerCharacter의 스킨을 설정한뒤 저장(Save)하여 나중에
Match나 Dedicated Server에 들어갔을때 Load Game from Slot 을 통해
Skin 데이터를 불러와서
동기화를 시키는데 모든 플레이어에게 동기화 되버리는 버그 발생
원인 : 서버/GameMode 에서 PlayerCharacter를 Spawn 시킬때 동기화를 시작한다
이때 GetPlayerController(PlayerIndex) 함수를 썼는데
클라이언트에서는 0번이 자기자신의 컨트롤러를 뜻하지만, 서버에서는 0번이 실제 0번째 플레이어를 뜻하므로
0번째 플레이어 컨트롤러의 Skin 데이터를 적용한다가 되버린다
해결
동기화 로직을 서버/GameMode 에서 PlayerCharacter/BeginPlay 에서 처리하도록 옮겼다
Reloading System (0) | 2019.09.02 |
---|