본문 바로가기

분류 전체보기75

1. HelloWorld 코드 간략 분석 Main.cpp 코드 간략 분석 다른 프로그램들과 동일하게 진입점의 기능을 하는 코드. ▼ cocos2d 네임스페이스 사용한다는 의미. // main.cpp USING_NS_CC // CCPlatformMacros.h #define USING_NS_CC using namespace cocos2d ▼ 윈도우 운영체제에서 제공하는 윈도우 창 전용 Main 함수로 진입한다. int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { } ▼ 싱글턴(Singleton)으로 구현되어있다. AppDelegate app; return Application::getInstance()->run(); 싱.. 2021. 1. 28.
그리미 코드 스타일 최종 수정일 : 2021.01.28 헤더 재정의 방지(Include Guard) #ifndef __EXAMPLE_H__ #define __EXAMPLE_H__ // CODE #endif _ (한 개)가 아니라 __(두 개) 사용한다. 큰 의미는 없지만 구분도 잘 되고 좀 더 균형감 있어보인다. 헤더 기입 순서 // C STANDARD LIBS #include // CPP STANDARD LIBS #include // OS LIBS #include // LOCAL LIBS #include "App.h" 들여쓰기(Identation Style) int main() { return (0); } 예외없이 Allman(BSD)를 따른다. 정수(Integer) 2021. 1. 28.
2. 간단한 탑뷰 게임 출구로 나가면 게임이 종료된다. 코인을 먹으면 카운트는 올라간다.. ▼ 실행화면 ▼ 전체코드 #include #include #include const static unsigned int FRAME = 30; const static unsigned int FPS = (1000 / FRAME); const static unsigned int WIDTH = 10; const static unsigned int HEIGHT = 10; const static unsigned int KEY_LEFT = 37; const static unsigned int KEY_TOP = 38; const static unsigned int KEY_RIGHT = 39; const static unsigned int KEY_DOW.. 2021. 1. 27.
20210127(수) std::sort() CPP 표준 라이브러리 에 정의되어 있는 함수. 기본적으로 오름차순이며 내림차순으로 지정할 수도 있다. ▼ 사용법 sort(v.begin(), v.end()); sort(v.begin(), v.end(), greater()); sort(v.begin(), v.end(), compare()); ▼ 예시 코드 #include #include #include void Print(int* arr) { printf("arr[] : "); for (int i = 0; i < 10; i++) printf("%d ", arr[i]); printf("\n"); } int main() { int arr[10] = { 3,4,2,4,5,1,2,3,5,0 }; Print(arr); std::sort(ar.. 2021. 1. 27.