CMake
This commit is contained in:
parent
3719b1249b
commit
e518e31fc7
6 changed files with 36 additions and 19 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
flappyBird
|
||||
build/
|
||||
*.kdev4
|
||||
|
|
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
|
@ -0,0 +1,23 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
# Set the project name
|
||||
project(FlappyBird)
|
||||
|
||||
# Find the SDL2 and SDL2_image packages
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
|
||||
# Specify the source files
|
||||
set(SRCS main.cpp)
|
||||
|
||||
# Create the executable
|
||||
add_executable(${PROJECT_NAME} ${SRCS})
|
||||
|
||||
# Link the SDL2 and SDL2_image libraries
|
||||
target_link_libraries(${PROJECT_NAME} SDL2::SDL2 SDL2_image::SDL2_image)
|
||||
|
||||
# Specify the assets directory
|
||||
set(ASSETS_DIR ${CMAKE_SOURCE_DIR}/assets)
|
||||
|
||||
# Copy assets to the build directory
|
||||
file(COPY ${ASSETS_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 212 B |
19
main.cpp
19
main.cpp
|
@ -94,14 +94,14 @@ int main ( int argc, char* argv[] )
|
|||
}
|
||||
|
||||
// Load the sprite texture
|
||||
SDL_Texture* flappyBird = IMG_LoadTexture ( renderer, "bird.png" );
|
||||
SDL_Texture* flappyBird = IMG_LoadTexture ( renderer, "assets/bird.png" );
|
||||
if ( flappyBird == nullptr )
|
||||
{
|
||||
std::cerr << "Failed to load texture! SDL_Error: " << SDL_GetError() << std::endl;
|
||||
// Handle error
|
||||
}
|
||||
|
||||
SDL_Texture* pipe = IMG_LoadTexture ( renderer, "pipe.png" );
|
||||
SDL_Texture* pipe = IMG_LoadTexture ( renderer, "assets/pipe.png" );
|
||||
if ( pipe == nullptr )
|
||||
{
|
||||
std::cerr << "Failed to load texture! SDL_Error: " << SDL_GetError() << std::endl;
|
||||
|
@ -206,17 +206,20 @@ int main ( int argc, char* argv[] )
|
|||
|
||||
quit = sdlPipe ( &pipe1Rect, &birdRect, renderer, flappyBird, pipe );
|
||||
|
||||
if (!quit) {
|
||||
if ( !quit )
|
||||
{
|
||||
quit = sdlPipe ( &pipe2Rect, &birdRect, renderer, flappyBird, pipe );
|
||||
}
|
||||
}
|
||||
|
||||
if (!quit) {
|
||||
if ( !quit )
|
||||
{
|
||||
quit = sdlPipe ( &pipe3Rect, &birdRect, renderer, flappyBird, pipe );
|
||||
}
|
||||
}
|
||||
|
||||
if (!quit) {
|
||||
if ( !quit )
|
||||
{
|
||||
quit = sdlPipe ( &pipe4Rect, &birdRect, renderer, flappyBird, pipe );
|
||||
}
|
||||
}
|
||||
|
||||
// Present the renderer
|
||||
SDL_RenderPresent ( renderer );
|
||||
|
|
10
makefile
10
makefile
|
@ -1,10 +0,0 @@
|
|||
CXX = g++
|
||||
CXXFLAGS = -lSDL2 -lSDL2_image
|
||||
SRCS = main.cpp
|
||||
TARGET = flappyBird
|
||||
|
||||
all: $(SRCS)
|
||||
$(CXX) -o $(TARGET) $(SRCS) $(CXXFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET)
|
Loading…
Reference in a new issue