Skip to content

Commit

Permalink
feat(tutorial): step 2 is step 3 minus background
Browse files Browse the repository at this point in the history
  • Loading branch information
naezith authored and Milerius committed Nov 3, 2019
1 parent 464a539 commit 072a8ec
Show file tree
Hide file tree
Showing 11 changed files with 432 additions and 0 deletions.
78 changes: 78 additions & 0 deletions tutorials/flappy-bird/step_2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the source code and call cmake from there")
endif ()

##! Minimum version of the CMake.
cmake_minimum_required(VERSION 3.14)

##! C++ Standard needed by the SDK is 17
set(CMAKE_CXX_STANDARD 17)

##! Our Project title, here flappy-bird.
project(flappy-bird DESCRIPTION "An awesome flappy-bird" LANGUAGES CXX)

##! The SDK need's clang as main compiler.
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
message(FATAL_ERROR "Only Clang is supported (minimum LLVM 8.0)")
endif()
endif ()

##! We will let know the SDK if our on Linux
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(LINUX TRUE)
endif ()

##! We include the module from CMake for fetching dependencies
include(FetchContent)

##! We declare information about the dependance that we want to fetch.
FetchContent_Declare(
antara-gaming-sdk
URL https://github.com/KomodoPlatform/antara-gaming-sdk/archive/master.zip
)

##! We set extras modules from the SDK that we want to use, here we will use the SFML module.
set(USE_SFML_ANTARA_WRAPPER ON)

##! We fetch our dependence
FetchContent_MakeAvailable(antara-gaming-sdk)

##! Calling this macros provided by the sdk will if you are on Apple init the environment for this OS (std::filesystem).
init_apple_env()

##! Osx bundle icon
set(ICON)
configure_icon_osx(data/osx/kmd_logo.icns ICON kmd_logo.icns)

##! We create the executable with the project name
add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${ICON} flappy-bird.cpp)

##! Setting output directory
set_target_properties(${PROJECT_NAME}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
)

##! We link the SDK modules that we want to use to our executable
target_link_libraries(${PROJECT_NAME} PUBLIC antara::world antara::sfml antara::collisions)

##! Move assets
if (WIN32)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/bin/)
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${SFML_BINARY_DIR}/lib" "${CMAKE_BINARY_DIR}/bin/"
COMMENT "copying dlls …"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)

ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${SFML_SOURCE_DIR}/extlibs/bin/x64/openal32.dll" "${CMAKE_BINARY_DIR}/bin/openal32.dll"
COMMENT "copying dlls …"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endif ()

if (APPLE)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}.app/Contents/Resources)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"background_color":[0,0,0,255],"canvas_height":1080.0,"canvas_width":1920.0,"custom_canvas_height":true,"custom_canvas_width":true,"native_desktop_mode":false,"scale_mode":"fit","window_height":1080.0,"window_title":"game title","window_width":1920.0}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<component type="desktop-application">
<id>org.antara.gaming.sfml.flappybird.desktop</id>
<metadata_license>MIT</metadata_license>
<project_license>MIT</project_license>
<name>flappy-bird</name>
<summary>flappy-bird tutorial antara gaming sdk</summary>
<description>
<p>Written in c++17</p>
</description>
<launchable type="desktop-id">org.antara.gaming.sfml.flappybird.desktop</launchable>
<url type="homepage">https://github.com/KomodoPlatform/antara-gaming-sdk</url>
<screenshots>
<screenshot type="default">
<image>https://www.freedesktop.org/software/appstream/docs/images/scr-examples/geany-good.png</image>
</screenshot>
</screenshots>
<provides>
<id>org.antara.gaming.sfml.flappybird.desktop</id>
</provides>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Type=Application
Name=flappy-bird
Exec=flappy-bird
Icon=komodo_icon
Categories=Game;
Binary file not shown.
57 changes: 57 additions & 0 deletions tutorials/flappy-bird/step_2/data/osx/Packaging_CMakeDMGSetup.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
on run argv
set image_name to item 1 of argv

tell application "Finder"
tell disk image_name

-- wait for the image to finish mounting
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5

-- open the image the first time and save a DS_Store with just
-- background and icon setup
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.tif"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 128
delay 5
close

-- next setup the position of the app and Applications symlink
-- plus hide all the window decorationPackaging_CMakeDMGBackground.tif
open
update without registering applications
tell container window
set sidebar width to 0
set statusbar visible to false
set toolbar visible to false
set the bounds to { 400, 100, 900, 465 }
set position of item "flappy-bird.app" to { 133, 200 }
set position of item "Applications" to { 378, 200 }
end tell
update without registering applications
delay 5
close

-- one last open and close so you can see everything looks correct
open
delay 5
close

end tell
delay 1
end tell
end run
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if (APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
RESOURCE data/osx/${PROJECT_NAME}.icns
MACOSX_BUNDLE_ICON_FILE ${PROJECT_NAME}
MACOSX_BUNDLE_SHORT_VERSION_STRING 0.0.1
MACOSX_BUNDLE_LONG_VERSION_STRING 0.0.1
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in")
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/"
$<TARGET_FILE:${PROJECT_NAME}>)
endif ()

if (APPLE)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION bin COMPONENT Runtime
)

# Note Mac specific extension .app
set(APPS "\${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app")

# Directories to look for dependencies
set(DIRS ${CMAKE_BINARY_DIR})

install(CODE "include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")")

set(CPACK_GENERATOR "DRAGNDROP")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/data/osx/Packaging_CMakeDMGSetup.scpt")
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/data/osx/Packaging_CMakeDMGBackground.tif")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
include(CPack)
endif ()
Loading

0 comments on commit 072a8ec

Please sign in to comment.