diff --git a/snakegame.xcodeproj/project.pbxproj b/snakegame.xcodeproj/project.pbxproj new file mode 100644 index 0000000..e88cc48 --- /dev/null +++ b/snakegame.xcodeproj/project.pbxproj @@ -0,0 +1,359 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + A4CCBE6E24A2700700E761C2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE6D24A2700700E761C2 /* AppDelegate.swift */; }; + A4CCBE7424A2700700E761C2 /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE7324A2700700E761C2 /* GameScene.swift */; }; + A4CCBE7624A2700700E761C2 /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE7524A2700700E761C2 /* GameViewController.swift */; }; + A4CCBE7924A2700700E761C2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A4CCBE7724A2700700E761C2 /* Main.storyboard */; }; + A4CCBE7B24A2700700E761C2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A4CCBE7A24A2700700E761C2 /* Assets.xcassets */; }; + A4CCBE7E24A2700700E761C2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A4CCBE7C24A2700700E761C2 /* LaunchScreen.storyboard */; }; + A4CCBE8624A27FC700E761C2 /* Apple.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE8524A27FC700E761C2 /* Apple.swift */; }; + A4CCBE8824A280E100E761C2 /* SnakeBodyPart.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE8724A280E100E761C2 /* SnakeBodyPart.swift */; }; + A4CCBE8A24A2814E00E761C2 /* SnakeHead.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE8924A2814E00E761C2 /* SnakeHead.swift */; }; + A4CCBE8C24A2817B00E761C2 /* Snake.swift in Sources */ = {isa = PBXBuildFile; fileRef = A4CCBE8B24A2817B00E761C2 /* Snake.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A4CCBE6A24A2700700E761C2 /* snakegame.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = snakegame.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A4CCBE6D24A2700700E761C2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + A4CCBE7324A2700700E761C2 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; + A4CCBE7524A2700700E761C2 /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; + A4CCBE7824A2700700E761C2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + A4CCBE7A24A2700700E761C2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + A4CCBE7D24A2700700E761C2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + A4CCBE7F24A2700700E761C2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A4CCBE8524A27FC700E761C2 /* Apple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Apple.swift; sourceTree = ""; }; + A4CCBE8724A280E100E761C2 /* SnakeBodyPart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnakeBodyPart.swift; sourceTree = ""; }; + A4CCBE8924A2814E00E761C2 /* SnakeHead.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnakeHead.swift; sourceTree = ""; }; + A4CCBE8B24A2817B00E761C2 /* Snake.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Snake.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A4CCBE6724A2700700E761C2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + A4CCBE6124A2700700E761C2 = { + isa = PBXGroup; + children = ( + A4CCBE6C24A2700700E761C2 /* snakegame */, + A4CCBE6B24A2700700E761C2 /* Products */, + ); + sourceTree = ""; + }; + A4CCBE6B24A2700700E761C2 /* Products */ = { + isa = PBXGroup; + children = ( + A4CCBE6A24A2700700E761C2 /* snakegame.app */, + ); + name = Products; + sourceTree = ""; + }; + A4CCBE6C24A2700700E761C2 /* snakegame */ = { + isa = PBXGroup; + children = ( + A4CCBE6D24A2700700E761C2 /* AppDelegate.swift */, + A4CCBE7324A2700700E761C2 /* GameScene.swift */, + A4CCBE7524A2700700E761C2 /* GameViewController.swift */, + A4CCBE7724A2700700E761C2 /* Main.storyboard */, + A4CCBE7A24A2700700E761C2 /* Assets.xcassets */, + A4CCBE7C24A2700700E761C2 /* LaunchScreen.storyboard */, + A4CCBE7F24A2700700E761C2 /* Info.plist */, + A4CCBE8524A27FC700E761C2 /* Apple.swift */, + A4CCBE8724A280E100E761C2 /* SnakeBodyPart.swift */, + A4CCBE8924A2814E00E761C2 /* SnakeHead.swift */, + A4CCBE8B24A2817B00E761C2 /* Snake.swift */, + ); + path = snakegame; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + A4CCBE6924A2700700E761C2 /* snakegame */ = { + isa = PBXNativeTarget; + buildConfigurationList = A4CCBE8224A2700700E761C2 /* Build configuration list for PBXNativeTarget "snakegame" */; + buildPhases = ( + A4CCBE6624A2700700E761C2 /* Sources */, + A4CCBE6724A2700700E761C2 /* Frameworks */, + A4CCBE6824A2700700E761C2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = snakegame; + productName = snakegame; + productReference = A4CCBE6A24A2700700E761C2 /* snakegame.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A4CCBE6224A2700700E761C2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1150; + LastUpgradeCheck = 1150; + ORGANIZATIONNAME = nrodionov; + TargetAttributes = { + A4CCBE6924A2700700E761C2 = { + CreatedOnToolsVersion = 11.5; + }; + }; + }; + buildConfigurationList = A4CCBE6524A2700700E761C2 /* Build configuration list for PBXProject "snakegame" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = A4CCBE6124A2700700E761C2; + productRefGroup = A4CCBE6B24A2700700E761C2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + A4CCBE6924A2700700E761C2 /* snakegame */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A4CCBE6824A2700700E761C2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A4CCBE7924A2700700E761C2 /* Main.storyboard in Resources */, + A4CCBE7B24A2700700E761C2 /* Assets.xcassets in Resources */, + A4CCBE7E24A2700700E761C2 /* LaunchScreen.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A4CCBE6624A2700700E761C2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A4CCBE8A24A2814E00E761C2 /* SnakeHead.swift in Sources */, + A4CCBE8624A27FC700E761C2 /* Apple.swift in Sources */, + A4CCBE7424A2700700E761C2 /* GameScene.swift in Sources */, + A4CCBE7624A2700700E761C2 /* GameViewController.swift in Sources */, + A4CCBE8824A280E100E761C2 /* SnakeBodyPart.swift in Sources */, + A4CCBE8C24A2817B00E761C2 /* Snake.swift in Sources */, + A4CCBE6E24A2700700E761C2 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + A4CCBE7724A2700700E761C2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A4CCBE7824A2700700E761C2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + A4CCBE7C24A2700700E761C2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + A4CCBE7D24A2700700E761C2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + A4CCBE8024A2700700E761C2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + A4CCBE8124A2700700E761C2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + A4CCBE8324A2700700E761C2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 5K5TF5N85C; + INFOPLIST_FILE = snakegame/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nrodionov.snakegame; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + A4CCBE8424A2700700E761C2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 5K5TF5N85C; + INFOPLIST_FILE = snakegame/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.nrodionov.snakegame; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A4CCBE6524A2700700E761C2 /* Build configuration list for PBXProject "snakegame" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A4CCBE8024A2700700E761C2 /* Debug */, + A4CCBE8124A2700700E761C2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A4CCBE8224A2700700E761C2 /* Build configuration list for PBXNativeTarget "snakegame" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A4CCBE8324A2700700E761C2 /* Debug */, + A4CCBE8424A2700700E761C2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A4CCBE6224A2700700E761C2 /* Project object */; +} diff --git a/snakegame.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/snakegame.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..9d2342b --- /dev/null +++ b/snakegame.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/snakegame.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/snakegame.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/snakegame.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/snakegame.xcodeproj/project.xcworkspace/xcuserdata/halofourteen.xcuserdatad/UserInterfaceState.xcuserstate b/snakegame.xcodeproj/project.xcworkspace/xcuserdata/halofourteen.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..0174019 Binary files /dev/null and b/snakegame.xcodeproj/project.xcworkspace/xcuserdata/halofourteen.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/snakegame.xcodeproj/project.xcworkspace/xcuserdata/rodionov.nikolay.xcuserdatad/UserInterfaceState.xcuserstate b/snakegame.xcodeproj/project.xcworkspace/xcuserdata/rodionov.nikolay.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..5a5abb5 Binary files /dev/null and b/snakegame.xcodeproj/project.xcworkspace/xcuserdata/rodionov.nikolay.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..ff4ecc1 --- /dev/null +++ b/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,24 @@ + + + + + + + + + diff --git a/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcschemes/xcschememanagement.plist b/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..cf4973b --- /dev/null +++ b/snakegame.xcodeproj/xcuserdata/halofourteen.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + snakegame.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..9761ea2 --- /dev/null +++ b/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcschemes/xcschememanagement.plist b/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..cf4973b --- /dev/null +++ b/snakegame.xcodeproj/xcuserdata/rodionov.nikolay.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + snakegame.xcscheme_^#shared#^_ + + orderHint + 0 + + + + diff --git a/snakegame/AppDelegate.swift b/snakegame/AppDelegate.swift new file mode 100644 index 0000000..7817508 --- /dev/null +++ b/snakegame/AppDelegate.swift @@ -0,0 +1,41 @@ +// +// AppDelegate.swift +// snakegame +// +// Created by Nik Rodionov on 23.06.2020. +// Copyright © 2020 nrodionov. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + +} + diff --git a/snakegame/Apple.swift b/snakegame/Apple.swift new file mode 100644 index 0000000..f4467be --- /dev/null +++ b/snakegame/Apple.swift @@ -0,0 +1,25 @@ +// +// Apple.swift +// snakegame +// +// Created by Nik Rodionov on 23.06.2020. +// Copyright © 2020 nrodionov. All rights reserved. +// + +import SpriteKit + +class Apple: SKShapeNode { + convenience init(position: CGPoint) { + self.init() + + path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 10, height: 10)).cgPath + + fillColor = .red + strokeColor = .red + lineWidth = 5 + self.position = position + + physicsBody = SKPhysicsBody(circleOfRadius: 10.0, center:CGPoint(x: 5, y: 5)) + physicsBody?.categoryBitMask = CollisionCategories.Apple + } +} diff --git a/snakegame/Assets.xcassets/AppIcon.appiconset/Contents.json b/snakegame/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/snakegame/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/snakegame/Assets.xcassets/Contents.json b/snakegame/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/snakegame/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/snakegame/Base.lproj/LaunchScreen.storyboard b/snakegame/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/snakegame/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snakegame/Base.lproj/Main.storyboard b/snakegame/Base.lproj/Main.storyboard new file mode 100644 index 0000000..6ecf17a --- /dev/null +++ b/snakegame/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/snakegame/GameScene.swift b/snakegame/GameScene.swift new file mode 100644 index 0000000..2f10bec --- /dev/null +++ b/snakegame/GameScene.swift @@ -0,0 +1,128 @@ +// +// GameScene.swift +// snakegame +// +// Created by Nik Rodionov on 23.06.2020. +// Copyright © 2020 nrodionov. All rights reserved. +// + +import SpriteKit +import GameplayKit + +struct CollisionCategories { + static let Snake: UInt32 = 1 + static let SnakeHead: UInt32 = 1 << 1 + static let Apple: UInt32 = 1 << 2 + static let EdgeBody: UInt32 = 1 << 3 +} + +class GameScene: SKScene { + private let counterClockWiseButtonName = "counterClockwiseButton" + private let clockWiseButtonName = "clockwiseButton" + private var snake: Snake! + + override func didMove(to view: SKView) { + backgroundColor = .black + + physicsWorld.gravity = CGVector(dx: 0, dy: 0) + + physicsBody = SKPhysicsBody(edgeLoopFrom: frame) + physicsBody?.allowsRotation = false + + let counterClockwisePosition = CGPoint(x: frame.minX + 30, y: frame.minY + 30) + let clockwisePosition = CGPoint(x: frame.maxX - 80, y: frame.minY + 30) + + addRotationButton(name: counterClockWiseButtonName, position: counterClockwisePosition) + addRotationButton(name: clockWiseButtonName, position: clockwisePosition) + + snake = Snake(position: CGPoint(x: frame.midX, y: frame.midY)) + addChild(snake) + createApple() + + physicsWorld.contactDelegate = self + + physicsBody?.categoryBitMask = CollisionCategories.EdgeBody + physicsBody?.collisionBitMask = CollisionCategories.Snake | CollisionCategories.SnakeHead + } + + private func createApple() { + let randX = CGFloat.random(in: 0.., with event: UIEvent?) { + + for touch in touches { + let touchLocation = touch.location(in: self) + + guard let touchedNode = atPoint(touchLocation) as? SKShapeNode else { continue } + + if touchedNode.name == clockWiseButtonName { + touchedNode.fillColor = .green + snake.moveClockWise() + } + else if touchedNode.name == counterClockWiseButtonName { + touchedNode.fillColor = .green + snake.moveCounterClockWise() + } + } + } + + + override func touchesEnded(_ touches: Set, with event: UIEvent?) { + for touch in touches { + let touchLocation = touch.location(in: self) + + guard let touchedNode = atPoint(touchLocation) as? SKShapeNode else { continue } + + if touchedNode.name == clockWiseButtonName { + touchedNode.fillColor = .gray + } + else if touchedNode.name == counterClockWiseButtonName { + touchedNode.fillColor = .gray + } + } + + // * SKLabelNode - для отображения текста + } + + + override func update(_ currentTime: TimeInterval) { + // Called before each frame is rendered + snake.move() + } +} + +extension GameScene: SKPhysicsContactDelegate { + func didBegin(_ contact: SKPhysicsContact) { + let bytes = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask + + let collisioObject = bytes ^ CollisionCategories.SnakeHead + + switch collisioObject { + case CollisionCategories.Apple: + let apple = contact.bodyA.node is Apple ? contact.bodyA.node : contact.bodyB.node + snake.addBodyPart() + apple?.removeFromParent() + createApple() + default: + break + } + } +} diff --git a/snakegame/GameViewController.swift b/snakegame/GameViewController.swift new file mode 100644 index 0000000..6a423f4 --- /dev/null +++ b/snakegame/GameViewController.swift @@ -0,0 +1,50 @@ +// +// GameViewController.swift +// snakegame +// +// Created by Nik Rodionov on 23.06.2020. +// Copyright © 2020 nrodionov. All rights reserved. +// + +import UIKit +import SpriteKit +import GameplayKit + +class GameViewController: UIViewController { + override func viewDidLoad() { + super.viewDidLoad() + + // view UIView -> view SKView + + // self.view as? SKView -> SKView? + let v1 = self.view as? SKView + if let skView = v1 { + let scene = GameScene() + scene.scaleMode = .resizeFill + + skView.presentScene(scene) + + skView.showsPhysics = true + skView.ignoresSiblingOrder = true + skView.showsFPS = true + skView.showsNodeCount = true + } + } + + + override var shouldAutorotate: Bool { + return true + } + + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if UIDevice.current.userInterfaceIdiom == .phone { + return .allButUpsideDown + } else { + return .all + } + } + + override var prefersStatusBarHidden: Bool { + return true + } +} diff --git a/snakegame/Info.plist b/snakegame/Info.plist new file mode 100644 index 0000000..870f784 --- /dev/null +++ b/snakegame/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/snakegame/Snake.swift b/snakegame/Snake.swift new file mode 100644 index 0000000..aa18b97 --- /dev/null +++ b/snakegame/Snake.swift @@ -0,0 +1,66 @@ +// +// Snake.swift +// snakegame +// +// Created by Nik Rodionov on 23.06.2020. +// Copyright © 2020 nrodionov. All rights reserved. +// + +import SpriteKit + +class Snake: SKShapeNode { + private var body = [SnakeBodyPart]() + private let moveSpeed: CGFloat = 125.0 + private var angle: CGFloat = 0.0 + + convenience init(position: CGPoint) { + self.init() + + let head = SnakeHead(position: position) + body.append(head) + + addChild(head) + } + + func addBodyPart() { + let newBodyPart = SnakeBodyPart(position: body[0].position) + body.append(newBodyPart) + + addChild(newBodyPart) + } + + func moveClockWise() { + angle += CGFloat.pi / 2 + } + + func moveCounterClockWise() { + angle -= CGFloat.pi / 2 + } + + func move() { + moveHead(body[0]) + + for i in 1..