Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
encelo committed Jul 30, 2019
0 parents commit 3ae4515
Show file tree
Hide file tree
Showing 45 changed files with 4,038 additions and 0 deletions.
128 changes: 128 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom # Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<nctl.*'
Priority: 4
- Regex: '^<ncine.*'
Priority: 5
- Regex: '^<android.*'
Priority: 2
- Regex: '<.*'
Priority: 1
- Regex: '^"imgui.*'
Priority: 7
- Regex: '^"(t,T)racy.*'
Priority: 8
- Regex: '^"[A-Z].*'
Priority: 6
- Regex: '^"[a-z].*'
Priority: 3
IncludeIsMainRegex: '$'
IndentCaseLabels: true
IndentPPDirectives: AfterHash # BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaImportGroups: []
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
TabWidth: 4
UseTab: ForIndentation
...

111 changes: 111 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
get_filename_component(PARENT_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
get_filename_component(PARENT_BINARY_DIR ${CMAKE_BINARY_DIR} DIRECTORY)

include(package_info)
include(package_check_info)

project(${PACKAGE_NAME})

include(package_options)

include(find_ncine)
if(NOT NCINE_DYNAMIC_LIBRARY)
include(package_imported_targets)
endif()

if(NOT IS_DIRECTORY ${PACKAGE_DATA_DIR})
message(WARNING "${PACKAGE_NAME} data directory not found at: ${PACKAGE_DATA_DIR}")
else()
message(STATUS "${PACKAGE_NAME} data directory: ${PACKAGE_DATA_DIR}")
endif()

include(package_get_version)
include(package_installation)

add_executable(${PACKAGE_EXE_NAME} ${PACKAGE_SOURCES})
include(package_generated_sources)
target_sources(${PACKAGE_EXE_NAME} PRIVATE ${GENERATED_SOURCES})

if(NOT DEFAULT_DATA_DIR_DIST) # Don't set the startup project if it wouldn't find the data directory
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PACKAGE_EXE_NAME})
endif()

if(IS_DIRECTORY ${GENERATED_INCLUDE_DIR})
target_include_directories(${PACKAGE_EXE_NAME} PRIVATE ${GENERATED_INCLUDE_DIR})
endif()
target_link_libraries(${PACKAGE_EXE_NAME} PRIVATE ncine::ncine_main ncine::ncine)

target_compile_definitions(${PACKAGE_EXE_NAME} PRIVATE "$<$<CONFIG:Debug>:${PACKAGE_UPPER_NAME}_DEBUG>")

if(MSVC)
target_compile_options(${PACKAGE_EXE_NAME} PRIVATE /MP)
endif()

if(APPLE)
file(RELATIVE_PATH RELPATH_TO_LIB ${CMAKE_INSTALL_PREFIX}/${RUNTIME_INSTALL_DESTINATION}/ ${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DESTINATION})
set_target_properties(${PACKAGE_EXE_NAME} PROPERTIES INSTALL_RPATH "@executable_path/${RELPATH_TO_LIB}")
endif()

if(DEFAULT_DATA_DIR_DIST)
if(MSVC OR APPLE)
# Relative path from tests to data on Windows and OS X, where the user can choose the installation directory
file(RELATIVE_PATH PACKAGE_DEFAULT_DATA_DIR
${CMAKE_INSTALL_PREFIX}/${RUNTIME_INSTALL_DESTINATION}
${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DESTINATION}) # Always strips trailing slash
set(PACKAGE_DEFAULT_DATA_DIR "${PACKAGE_DEFAULT_DATA_DIR}/")
else()
set(PACKAGE_DEFAULT_DATA_DIR "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DESTINATION}/")
endif()
elseif(NOT PACKAGE_DEFAULT_DATA_DIR)
set(PACKAGE_DEFAULT_DATA_DIR "${PACKAGE_DATA_DIR}/data/")
endif()

if(PACKAGE_DEFAULT_DATA_DIR)
file(TO_CMAKE_PATH "${PACKAGE_DEFAULT_DATA_DIR}" PACKAGE_DEFAULT_DATA_DIR) # Always strips trailing slash
set(PACKAGE_DEFAULT_DATA_DIR "${PACKAGE_DEFAULT_DATA_DIR}/")

message(STATUS "Default data directory: ${PACKAGE_DEFAULT_DATA_DIR}")
target_compile_definitions(${PACKAGE_EXE_NAME} PRIVATE "PACKAGE_DEFAULT_DATA_DIR=\"${PACKAGE_DEFAULT_DATA_DIR}\"")
endif()

if(EMSCRIPTEN)
target_compile_options(${PACKAGE_EXE_NAME} PRIVATE "SHELL:--preload-file ${PACKAGE_DATA_DIR}/data@ --no-heap-copy")
target_link_options(${PACKAGE_EXE_NAME} PRIVATE "SHELL:--preload-file ${PACKAGE_DATA_DIR}/data@ --no-heap-copy")
configure_file(${CMAKE_SOURCE_DIR}/emscripten_shell.html.in ${CMAKE_BINARY_DIR}/${PACKAGE_EXE_NAME}.html @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_EXE_NAME}.html DESTINATION ${RUNTIME_INSTALL_DESTINATION})
install(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_EXE_NAME}.data DESTINATION ${RUNTIME_INSTALL_DESTINATION})
install(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_EXE_NAME}.wasm DESTINATION ${RUNTIME_INSTALL_DESTINATION})
if(EXISTS ${PACKAGE_DATA_DIR}/icons/ncInvaders.ico)
file(COPY ${PACKAGE_DATA_DIR}/icons/ncInvaders.ico DESTINATION ${CMAKE_BINARY_DIR})
file(RENAME ${CMAKE_BINARY_DIR}/ncInvaders.ico ${CMAKE_BINARY_DIR}/favicon.ico)
install(FILES ${CMAKE_BINARY_DIR}/favicon.ico DESTINATION ${RUNTIME_INSTALL_DESTINATION})
endif()
endif()

install(TARGETS ${PACKAGE_EXE_NAME} RUNTIME DESTINATION ${RUNTIME_INSTALL_DESTINATION})
install(FILES README.md DESTINATION ${README_INSTALL_DESTINATION})
if(MSVC OR APPLE)
install(FILES LICENSE DESTINATION . RENAME LICENSE.txt)
endif()
if(NOT EMSCRIPTEN)
install(DIRECTORY ${PACKAGE_DATA_DIR}/data/ DESTINATION ${DATA_INSTALL_DESTINATION})
endif()
install(FILES ${PACKAGE_DATA_DIR}/README.md DESTINATION ${DATA_INSTALL_DESTINATION})
if(IS_DIRECTORY ${NCINE_SHADERS_DIR})
install(DIRECTORY ${NCINE_SHADERS_DIR} DESTINATION ${SHADERS_INSTALL_DESTINATION})
endif()

if(MSVC)
install(FILES ${NCINE_LOCATION} DESTINATION ${RUNTIME_INSTALL_DESTINATION})
install(DIRECTORY ${MSVC_BINDIR}/ DESTINATION ${RUNTIME_INSTALL_DESTINATION} FILES_MATCHING PATTERN "*.dll")
elseif(APPLE)
install(FILES ${NCINE_LOCATION} DESTINATION ${LIBRARY_INSTALL_DESTINATION})
install(DIRECTORY ${FRAMEWORKS_DIR}/ DESTINATION ${FRAMEWORKS_INSTALL_DESTINATION})
endif()

include(package_copy_targets)
include(package_build_android)
include(package_strip_binaries)
34 changes: 34 additions & 0 deletions Info.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@CPACK_BUNDLE_NAME@</string>
<key>CFBundleIconFile</key>
<string>@[email protected]</string>
<key>CFBundleIdentifier</key>
<string>io.github.ncine.ncinvaders</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@CPACK_BUNDLE_NAME@</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>@PACKAGE_VERSION@</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string></string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright ©2011-2019 Angelo Theodorou</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2016-2019 Angelo Theodorou

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ncInvaders
ncInvaders is a simplified version of **Space Invaders** made with the nCine.
It has a slightly more complicated game logic than the `ncPong` example.

You can control the ship with the mouse or keyboard on PC, tapping the screen on Android or with the joystick on both platforms.
Loading

0 comments on commit 3ae4515

Please sign in to comment.