mirror of
https://github.com/zhenyan121/SporeBG-Conid.git
synced 2026-04-10 06:14:08 +08:00
init the projetc
This commit is contained in:
30
CMakeLists.txt
Normal file
30
CMakeLists.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
project(SporeBG-Conid)
|
||||||
|
|
||||||
|
# 设置C++标准
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# 设置输出目录
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/$<CONFIGURATION>")
|
||||||
|
|
||||||
|
# 包含SDL3子项目
|
||||||
|
add_subdirectory(third_party/SDL3)
|
||||||
|
|
||||||
|
# 添加可执行文件
|
||||||
|
add_executable(SporeBG-Conid src/main.cpp)
|
||||||
|
|
||||||
|
# 使用正确的目标名称链接SDL3
|
||||||
|
# 方法1:使用别名(推荐)
|
||||||
|
target_link_libraries(SporeBG-Conid PRIVATE SDL3::SDL3)
|
||||||
|
|
||||||
|
# Windows下复制动态库 - 使用正确的目标名称
|
||||||
|
if(WIN32)
|
||||||
|
add_custom_command(TARGET SporeBG-Conid POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
$<TARGET_FILE:SDL3::SDL3>
|
||||||
|
$<TARGET_FILE_DIR:SporeBG-Conid>
|
||||||
|
COMMENT "Copying SDL3 DLL to output directory"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
10
README.md
10
README.md
@@ -1 +1,11 @@
|
|||||||
一个棋类游戏,与孢子分裂有关,本为cpp重构版,游戏核心主要玩法由cold1840制定的,可以看他的python版本,这个版本旨在用cpp完全重写这个游戏,并加入许多功能,同时cold1840也在一定程度上参与项目的开发与维护
|
一个棋类游戏,与孢子分裂有关,本为cpp重构版,游戏核心主要玩法由cold1840制定的,可以看他的python版本,这个版本旨在用cpp完全重写这个游戏,并加入许多功能,同时cold1840也在一定程度上参与项目的开发与维护
|
||||||
|
|
||||||
|
构建指南
|
||||||
|
确保电脑安装了cmake和ninja,使用gcc与g++
|
||||||
|
克隆仓库以及子模块
|
||||||
|
git clone --recursive https://github.com/zhenyan121/SporeBG-Conid.git
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ..
|
||||||
|
ninja
|
||||||
|
|
||||||
|
|||||||
67
src/main.cpp
67
src/main.cpp
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely.
|
||||||
|
*/
|
||||||
|
#define SDL_MAIN_USE_CALLBACKS 1 /* use the callbacks instead of main() */
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
#include <SDL3/SDL_main.h>
|
||||||
|
|
||||||
|
static SDL_Window *window = NULL;
|
||||||
|
static SDL_Renderer *renderer = NULL;
|
||||||
|
|
||||||
|
/* This function runs once at startup. */
|
||||||
|
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
/* Create the window */
|
||||||
|
if (!SDL_CreateWindowAndRenderer("Hello World", 800, 600, SDL_WINDOW_FULLSCREEN, &window, &renderer)) {
|
||||||
|
SDL_Log("Couldn't create window and renderer: %s", SDL_GetError());
|
||||||
|
return SDL_APP_FAILURE;
|
||||||
|
}
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
|
||||||
|
SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||||
|
{
|
||||||
|
if (event->type == SDL_EVENT_KEY_DOWN ||
|
||||||
|
event->type == SDL_EVENT_QUIT) {
|
||||||
|
return SDL_APP_SUCCESS; /* end the program, reporting success to the OS. */
|
||||||
|
}
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs once per frame, and is the heart of the program. */
|
||||||
|
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||||
|
{
|
||||||
|
const char *message = "Hello World!";
|
||||||
|
int w = 0, h = 0;
|
||||||
|
float x, y;
|
||||||
|
const float scale = 4.0f;
|
||||||
|
|
||||||
|
/* Center the message and scale it up */
|
||||||
|
SDL_GetRenderOutputSize(renderer, &w, &h);
|
||||||
|
SDL_SetRenderScale(renderer, scale, scale);
|
||||||
|
x = ((w / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE * SDL_strlen(message)) / 2;
|
||||||
|
y = ((h / scale) - SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE) / 2;
|
||||||
|
|
||||||
|
/* Draw the message */
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
|
||||||
|
SDL_RenderDebugText(renderer, x, y, message);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
return SDL_APP_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function runs once at shutdown. */
|
||||||
|
void SDL_AppQuit(void *appstate, SDL_AppResult result)
|
||||||
|
{
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user