style: 调整main.cpp的代码格式和include顺序

- 统一缩进为2个空格
- 调整头文件include顺序
- 移除多余的注释分隔线
This commit is contained in:
ChestnutYueyue 2026-03-03 19:41:20 +08:00
parent d5cb194552
commit e011cea090
1 changed files with 42 additions and 46 deletions

View File

@ -12,9 +12,9 @@
* - SpriteRenderer * - SpriteRenderer
*/ */
#include <extra2d.h>
#include "game_scene.h" #include "game_scene.h"
#include <cstdio> #include <cstdio>
#include <extra2d.h>
using namespace extra2d; using namespace extra2d;
@ -22,58 +22,54 @@ using namespace extra2d;
* @brief * @brief
*/ */
int main(int argc, char **argv) { int main(int argc, char **argv) {
// ======================================== // ========================================
// 1. 创建应用 // 1. 创建应用
// ======================================== // ========================================
auto app = Application::create(); auto app = Application::create();
AppConfig config; AppConfig config;
config.title = "Scene Graph Demo - Extra2D"; config.title = "Scene Graph Demo - Extra2D";
config.width = 1280; config.width = 1280;
config.height = 720; config.height = 720;
if (!app->init(config)) { if (!app->init(config)) {
printf("Failed to initialize application!\n"); printf("Failed to initialize application!\n");
return -1; return -1;
} }
// ========================================
// 2. 获取场景模块和导演
// ========================================
SceneModule *sceneModule = app->getModule<SceneModule>();
if (!sceneModule) {
printf("Failed to get SceneModule!\n");
return -1;
}
printf("Application initialized successfully\n"); Director *director = sceneModule->getDirector();
printf("Window size: %dx%d\n", app->getWindowWidth(), app->getWindowHeight()); if (!director) {
printf("Failed to get Director!\n");
return -1;
}
// ======================================== printf("Scene module and director ready\n");
// 2. 获取场景模块和导演
// ========================================
SceneModule *sceneModule = app->getModule<SceneModule>();
if (!sceneModule) {
printf("Failed to get SceneModule!\n");
return -1;
}
Director *director = sceneModule->getDirector(); // ========================================
if (!director) { // 3. 创建并运行游戏场景
printf("Failed to get Director!\n"); // ========================================
return -1; auto gameScene = makePtr<GameScene>();
} director->runScene(gameScene);
printf("Scene module and director ready\n"); printf("Game scene started\n");
// ======================================== // ========================================
// 3. 创建并运行游戏场景 // 4. 运行应用主循环
// ======================================== // ========================================
auto gameScene = makePtr<GameScene>(); app->run();
director->runScene(gameScene);
printf("Game scene started\n"); // ========================================
// 5. 清理(自动进行)
// ========================================
printf("Application shutting down...\n");
// ======================================== return 0;
// 4. 运行应用主循环
// ========================================
app->run();
// ========================================
// 5. 清理(自动进行)
// ========================================
printf("Application shutting down...\n");
return 0;
} }