Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Merge branch '2016180042' into 2017182040
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdwnsasa committed Nov 25, 2021
2 parents b5fbf16 + c345dc1 commit 8d38fc9
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 111 deletions.
Binary file added res/120362.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/Player_strip9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Battleroyal/Battleroyal.rc
Binary file not shown.
2 changes: 0 additions & 2 deletions src/Battleroyal/Battleroyale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ int APIENTRY wWinMain( _In_ HINSTANCE hInstance,

// 코드
framework.background_color = COLOR_NAVY;


MSG msg;
while (true) {
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
Expand Down
77 changes: 54 additions & 23 deletions src/Battleroyal/CommonDatas.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
#pragma once
#include "pch.h"

#define COMMON_PORT 15000
#define GAME_SCENE_W 1280
#define GAME_SCENE_H 1280
#define CLIENT_W 960
#define CLIENT_H 540
#define VIEW_W 320
#define VIEW_H 240
#define PORT_W 640
#define PORT_H 480


constexpr double METER_TO_PIXELS = 16.;
constexpr double HOUR_TO_SECONDS = 3600.;
constexpr double KPH_TO_PPS = (1000.0 * METER_TO_PIXELS / HOUR_TO_SECONDS);

constexpr double km_per_hr(const double velocity) {
return velocity * KPH_TO_PPS;
}

const double EWALL_BEGIN_TIME = 30.0; // 자기장 시작 시간
const double EWALL_CLOSE_PERIOD = 300.0; // 자기장 완료 시간
const double EWALL_DAMAGE_PER_SECOND = 0.7;

// 자기장 완료 시간
const double EWALL_CLOSE_PERIOD = 300.0;
const double EWALL_DAMAGE_PER_SECOND = 1.5;
const int PLAYERS_NUMBER_MAX = 10; // 최대 플레이어 수
const double PLAYER_HEALTH = 100.0; // 플레이어 최대 체력
const double PLAYER_MOVE_SPEED = km_per_hr(20); // 플레이어 이동 속도
const double PLAYER_ATTACK_COOLDOWN = 0.2; // 공격 쿨 타임
const double PLAYER_INVINCIBLE_DURATION = 2.5; // 무적 시간

// 최대 플레이어 수
const int PLAYERS_NUMBER_MAX = 10;
const double SNOWBALL_DURATION = 0.6; // 투사체 지속 시간
const double SNOWBALL_VELOCITY = km_per_hr(50); // 투사체 이동 속도

// 프레임 수
const int FRAMERATE = 100;
// 프레임 수
const int FRAMERATE = 60;
const double FRAME_TIME = (1.0 / FRAMERATE);

// 송수신 설정
const int SEND_INPUT_COUNT = 6;


enum PACKETS : int {
CLIENT_PING = 0 // 빈 패킷을 보낼 때 사용하는 메시지
, CLIENT_KEY_INPUT // 입력을 보낼 때 사용하는 메시지
, CLIENT_GAME_START // 서버에게 게임 시작을 요청하는 메시지
, CLIENT_PLAY_CONTINUE // 게임을 다시 시작하기 위해 재접속을 요청하는 메시지
, CLIENT_PLAY_DENY // 게임을 다시하지 않는다고 알려주는 메시지

, SERVER_SET_CAPATIN // 클라이언트에게 너가 방장이라고 알려주는 메시지
, SERVER_GAME_START // 클라이언트에게 게임이 시작되었음을 알려주는 메시지
, SERVER_PLAYER_COUNT // 클라이언트에게 플레이어가 몇 명인지 알려주는 메시지
, SERVER_GAME_STATUS // 클라이언트에게 게임 상태를 알려주는 메시지
, SERVER_RENDER_INFO // 클라이언트에게 렌더링 정보를 보내주는 메시지
, SERVER_GAME_DONE // 클라이언트에게 게임이 끝났음을 알려주는 메시지
, SERVER_REPLAY // 클라이언트에게 게임을 다시 시작함을 알려주는 메시지
// 클라이언트 -> 서버
CLIENT_PING = 0 // 빈 패킷을 보낼 때 사용하는 메시지
, CLIENT_KEY_INPUT // 입력을 보낼 때 사용하는 메시지
, CLIENT_KEY_PRESS // 입력을 보낼 때 사용하는 메시지
, CLIENT_KEY_RELEASE // 입력을 보낼 때 사용하는 메시지
, CLIENT_GAME_START // 서버에게 게임 시작을 요청하는 메시지
, CLIENT_PLAY_CONTINUE // 게임을 다시 시작하기 위해 재접속을 요청하는 메시지
, CLIENT_PLAY_DENY // 게임을 다시하지 않는다고 알려주는 메시지

// 서버 -> 클라이언트
, SERVER_SET_CAPATIN // 방장임을 알려주는 메시지
, SERVER_GAME_START // 게임이 시작되었음을 알려주는 메시지
, SERVER_PLAYER_COUNT // 플레이어가 몇 명인지 알려주는 메시지
, SERVER_GAME_STATUS // 게임 상태를 알려주는 메시지
, SERVER_RENDER_INFO // 렌더링 정보를 보내주는 메시지
, SERVER_GAME_DONE // 게임이 끝났음을 알려주는 메시지
, SERVER_REPLAY // 게임을 다시 시작함을 알려주는 메시지
};

struct GameUpdateMessage {
Expand All @@ -44,10 +75,10 @@ enum RENDER_TYPES : int {
};

struct RenderInstance {
RENDER_TYPES instance_type; //¹«½¼ À̹ÌÁöÀÎÁö
RENDER_TYPES instance_type;

int image_index; //¾Ö´Ï¸ÞÀÌ¼Ç ÇÁ·¹ÀÓ
double x, y, angle; //ÁÂÇ¥, °¢µµ
int image_index;
double x, y, angle;
};

void SendData(SOCKET, PACKETS, const char* = nullptr, int = 0);
Expand Down
51 changes: 25 additions & 26 deletions src/Battleroyal/Framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,6 @@

GameSprite playersprite("testimage.png", 0, 0, 0);

void ErrorAbort(const char* msg) {
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, nullptr);

MessageBox(nullptr, static_cast<LPCTSTR>(lpMsgBuf), msg, MB_ICONERROR);

LocalFree(lpMsgBuf);
exit(true);
}

void ErrorDisplay(const char* msg) {
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, nullptr);

std::cout << "[" << msg << "] " << static_cast<char*>(lpMsgBuf) << std::endl;

LocalFree(lpMsgBuf);
}

ClientFramework::ClientFramework(int rw, int rh, int vw, int vh, int pw, int ph)
: painter{}
, WORLD_W(rw), WORLD_H(rh)
Expand Down Expand Up @@ -135,9 +112,8 @@ void ClientFramework::Update() {
case GAME:
{
int itercount = 0;
PACKETS gamemessage = CLIENT_KEY_INPUT;

for (auto it = key_checkers.begin(); it != key_checkers.end(); it++) { // key_checkers에서 값을 읽어 배열 제작
for (auto it = key_checkers.begin(); it != key_checkers.end(); it++) {
// key_checkers에서 값을 읽어 배열 제작
buttonsets[itercount] = (it->second.time == -1);
itercount++;
}
Expand Down Expand Up @@ -359,3 +335,26 @@ void ClientFramework::SetSprite(GameSprite* sprite) {

sprites[0]->get_height();
}

void ErrorAbort(const char* msg) {
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, nullptr);

MessageBox(nullptr, static_cast<LPCTSTR>(lpMsgBuf), msg, MB_ICONERROR);

LocalFree(lpMsgBuf);
exit(true);
}

void ErrorDisplay(const char* msg) {
LPVOID lpMsgBuf;

FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, nullptr, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>(&lpMsgBuf), 0, nullptr);

std::cout << "[" << msg << "] " << static_cast<char*>(lpMsgBuf) << std::endl;

LocalFree(lpMsgBuf);
}
35 changes: 17 additions & 18 deletions src/Battleroyal/Framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@

//#define SERVER_IP "192.168.122.191"
#define SERVER_IP "127.0.0.1"
#define SERVER_PT 9000

enum CLIENT_STATES : int {
TITLE = 0 // 타이틀 화면
, LOBBY // 로비
, GAME // 게임
, SPECTATOR // 게임 관전
, GAME_OVER // 게임 완료
, GAME_RESTART // 게임 다시 참가
, EXIT // 클라이언트 종료
TITLE = 0 // 타이틀 화면
, LOBBY // 로비
, GAME // 게임
, SPECTATOR // 게임 관전
, GAME_OVER // 게임 완료
, GAME_RESTART // 게임 다시 참가
, EXIT // 클라이언트 종료

};

typedef LRESULT(CALLBACK* WindowProcedure)(HWND, UINT, WPARAM, LPARAM);

class GameClientInstance {
public:
double x, y;
Expand Down Expand Up @@ -62,11 +59,11 @@ class ClientFramework {
SOCKADDR_IN server_address;
int player_index = 0;
int player_num = 1;
bool buttonsets[6]; //0 = w, 1 = s, 2 = a, 3 = d
bool buttonsets[SEND_INPUT_COUNT]; //0 = w, 1 = s, 2 = a, 3 = d
bool player_captain = false;
int title_duration = 0;

// 마지막에 수신한 렌더링 정보
// 마지막에 수신한 렌더링 정보
RenderInstance* last_render_info;

class CInputChecker {
Expand All @@ -91,19 +88,21 @@ class ClientFramework {
void DrawRenderInstances();
};

typedef LRESULT(CALLBACK* WindowProcedure)(HWND, UINT, WPARAM, LPARAM);

class WindowsClient {
public:
WindowsClient(LONG width, LONG height);
~WindowsClient();

BOOL initialize(HINSTANCE handle, WNDPROC procedure, LPCWSTR title, LPCWSTR id, INT cmd_show);

HINSTANCE instance; // 프로세스 인스턴스
HWND hwindow; // 창 인스턴스
WindowProcedure procedure; // 창 처리기
WNDCLASSEX properties; // 창 등록정보
LPCWSTR title_caption, class_id; // 창 식별자
LONG width, height; // 창 크기
HINSTANCE instance; // 프로세스 인스턴스
HWND hwindow; // 창 인스턴스
WindowProcedure procedure; // 창 처리기
WNDCLASSEX properties; // 창 등록정보
LPCWSTR title_caption, class_id; // 창 식별자
LONG width, height; // 창 크기
};

//template<class Predicate>
Expand Down
40 changes: 17 additions & 23 deletions src/Battleroyal/Resource.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++에서 생성한 포함 파일입니다.
// 다음에서 사용 Battleroyal.rc

#define IDS_APP_TITLE 103

#define IDR_MAINFRAME 128
#define IDD_BATTLEROYAL_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDI_BATTLEROYAL 107
#define IDI_SMALL 108
#define IDC_BATTLEROYAL 109
#define IDC_MYICON 2
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
// 다음은 새 개체에 사용할 기본값입니다.
// Battleroyal.rc에서 사용되고 있습니다.
//
#define IDC_MYICON 2
#define IDD_BATTLEROYAL_DIALOG 102
#define IDS_APP_TITLE 103
#define IDI_BATTLEROYAL 107
#define IDI_SMALL 108
#define IDC_BATTLEROYAL 109
#define IDR_MAINFRAME 128
#define IDC_STATIC -1

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NO_MFC 130
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
18 changes: 0 additions & 18 deletions src/Battleroyal/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@

using namespace std;

#define GAME_SCENE_W 1280
#define GAME_SCENE_H 1280
#define CLIENT_W 960
#define CLIENT_H 540
#define VIEW_W 320
#define VIEW_H 240
#define PORT_W 640
#define PORT_H 480


constexpr double METER_TO_PIXELS = 16.;
constexpr double HOUR_TO_SECONDS = 3600.;
constexpr double KPH_TO_PPS = (1000.0 * METER_TO_PIXELS / HOUR_TO_SECONDS);

constexpr double km_per_hr(const double velocity) {
return velocity * KPH_TO_PPS;
}

inline double radtodeg(double value) {
return value / M_PI * 180.0;
}
Expand Down
8 changes: 8 additions & 0 deletions src/Battleroyale Server/Battleroyale Server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -129,6 +133,10 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
Binary file modified src/Battleroyale Server/BattleroyaleServer.cpp
Binary file not shown.
Binary file modified src/Battleroyale Server/BattleroyaleServer.h
Binary file not shown.
1 change: 0 additions & 1 deletion src/Battleroyale Server/CommonDatas.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#include "pch.h"
#include "CommonDatas.h"

Binary file modified src/Battleroyale Server/CommonDatas.h
Binary file not shown.
Binary file modified src/Battleroyale Server/Framework.cpp
Binary file not shown.
Binary file modified src/Battleroyale Server/Framework.h
Binary file not shown.
Binary file modified src/Battleroyale Server/pch.h
Binary file not shown.

0 comments on commit 8d38fc9

Please sign in to comment.