initial
This commit is contained in:
@@ -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 = "<group>"; };
|
||||||
|
A4CCBE7324A2700700E761C2 /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = "<group>"; };
|
||||||
|
A4CCBE7524A2700700E761C2 /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; };
|
||||||
|
A4CCBE7824A2700700E761C2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||||
|
A4CCBE7A24A2700700E761C2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
|
A4CCBE7D24A2700700E761C2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||||
|
A4CCBE7F24A2700700E761C2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
A4CCBE8524A27FC700E761C2 /* Apple.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Apple.swift; sourceTree = "<group>"; };
|
||||||
|
A4CCBE8724A280E100E761C2 /* SnakeBodyPart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnakeBodyPart.swift; sourceTree = "<group>"; };
|
||||||
|
A4CCBE8924A2814E00E761C2 /* SnakeHead.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SnakeHead.swift; sourceTree = "<group>"; };
|
||||||
|
A4CCBE8B24A2817B00E761C2 /* Snake.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Snake.swift; sourceTree = "<group>"; };
|
||||||
|
/* 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 = "<group>";
|
||||||
|
};
|
||||||
|
A4CCBE6B24A2700700E761C2 /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
A4CCBE6A24A2700700E761C2 /* snakegame.app */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
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 = "<group>";
|
||||||
|
};
|
||||||
|
/* 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 = "<group>";
|
||||||
|
};
|
||||||
|
A4CCBE7C24A2700700E761C2 /* LaunchScreen.storyboard */ = {
|
||||||
|
isa = PBXVariantGroup;
|
||||||
|
children = (
|
||||||
|
A4CCBE7D24A2700700E761C2 /* Base */,
|
||||||
|
);
|
||||||
|
name = LaunchScreen.storyboard;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* 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 */;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:snakegame.xcodeproj">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>IDEDidComputeMac32BitWarning</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+24
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Bucket
|
||||||
|
uuid = "E28D6AD1-4A60-4A32-858F-50801BE83415"
|
||||||
|
type = "1"
|
||||||
|
version = "2.0">
|
||||||
|
<Breakpoints>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
uuid = "37360217-EE23-4F5B-B09E-2D5A531602A0"
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "snakegame/Snake.swift"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "43"
|
||||||
|
endingLineNumber = "43"
|
||||||
|
landmarkName = "move()"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
</Breakpoints>
|
||||||
|
</Bucket>
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>snakegame.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Bucket
|
||||||
|
uuid = "313D35F9-860E-473D-B5E8-C54835F22D4D"
|
||||||
|
type = "1"
|
||||||
|
version = "2.0">
|
||||||
|
</Bucket>
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>SchemeUserState</key>
|
||||||
|
<dict>
|
||||||
|
<key>snakegame.xcscheme_^#shared#^_</key>
|
||||||
|
<dict>
|
||||||
|
<key>orderHint</key>
|
||||||
|
<integer>0</integer>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -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.
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--View Controller-->
|
||||||
|
<scene sceneID="EHf-IW-A2E">
|
||||||
|
<objects>
|
||||||
|
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||||
|
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="53" y="375"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BV1-FR-VrT">
|
||||||
|
<device id="retina6_1" orientation="portrait" appearance="light"/>
|
||||||
|
<dependencies>
|
||||||
|
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
|
||||||
|
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
|
</dependencies>
|
||||||
|
<scenes>
|
||||||
|
<!--Game View Controller-->
|
||||||
|
<scene sceneID="tXr-a1-R10">
|
||||||
|
<objects>
|
||||||
|
<viewController id="BV1-FR-VrT" customClass="GameViewController" customModule="snakegame" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
|
<view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="3se-qz-xqx" customClass="SKView">
|
||||||
|
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
|
<viewLayoutGuide key="safeArea" id="4qk-I5-YsI"/>
|
||||||
|
</view>
|
||||||
|
</viewController>
|
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/>
|
||||||
|
</objects>
|
||||||
|
<point key="canvasLocation" x="157" y="168"/>
|
||||||
|
</scene>
|
||||||
|
</scenes>
|
||||||
|
</document>
|
||||||
@@ -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..<frame.maxX - 5)
|
||||||
|
let randY = CGFloat.random(in: 0..<frame.maxY - 5)
|
||||||
|
|
||||||
|
let apple = Apple(position: CGPoint(x: randX, y: randY))
|
||||||
|
|
||||||
|
addChild(apple)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func addRotationButton(name: String, position: CGPoint) {
|
||||||
|
let button = SKShapeNode()
|
||||||
|
button.path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 45, height: 45)).cgPath
|
||||||
|
|
||||||
|
button.position = position
|
||||||
|
button.fillColor = .gray
|
||||||
|
button.strokeColor = .gray
|
||||||
|
button.lineWidth = 10
|
||||||
|
button.name = name
|
||||||
|
addChild(button)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func touchesBegan(_ touches: Set<UITouch>, 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<UITouch>, 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>$(EXECUTABLE_NAME)</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>$(PRODUCT_NAME)</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>1.0</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1</string>
|
||||||
|
<key>LSRequiresIPhoneOS</key>
|
||||||
|
<true/>
|
||||||
|
<key>UILaunchStoryboardName</key>
|
||||||
|
<string>LaunchScreen</string>
|
||||||
|
<key>UIMainStoryboardFile</key>
|
||||||
|
<string>Main</string>
|
||||||
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
|
<array>
|
||||||
|
<string>armv7</string>
|
||||||
|
</array>
|
||||||
|
<key>UIStatusBarHidden</key>
|
||||||
|
<true/>
|
||||||
|
<key>UISupportedInterfaceOrientations</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||||
|
<array>
|
||||||
|
<string>UIInterfaceOrientationPortrait</string>
|
||||||
|
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||||
|
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
@@ -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..<body.count {
|
||||||
|
let previous = body[i - 1]
|
||||||
|
let current = body[i]
|
||||||
|
|
||||||
|
moveBodyPart(current, previous: previous)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func moveHead(_ head: SnakeBodyPart) {
|
||||||
|
let dx = moveSpeed * sin(angle)
|
||||||
|
let dy = moveSpeed * cos(angle)
|
||||||
|
|
||||||
|
let nextPostion = CGPoint(x: head.position.x + dx, y: head.position.y + dy)
|
||||||
|
|
||||||
|
let moveAction = SKAction.move(to: nextPostion, duration: 1.0)
|
||||||
|
head.run(moveAction)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func moveBodyPart(_ part: SnakeBodyPart, previous: SnakeBodyPart ) {
|
||||||
|
let moveAction = SKAction.move(to: previous.position, duration: 0.1)
|
||||||
|
|
||||||
|
part.run(moveAction)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// SnakeBodyPart.swift
|
||||||
|
// snakegame
|
||||||
|
//
|
||||||
|
// Created by Nik Rodionov on 23.06.2020.
|
||||||
|
// Copyright © 2020 nrodionov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class SnakeBodyPart: SKShapeNode {
|
||||||
|
init(position: CGPoint) {
|
||||||
|
super.init()
|
||||||
|
|
||||||
|
path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: 10, height: 10)).cgPath
|
||||||
|
|
||||||
|
fillColor = .green
|
||||||
|
strokeColor = .green
|
||||||
|
lineWidth = 5
|
||||||
|
self.position = position
|
||||||
|
|
||||||
|
physicsBody = SKPhysicsBody(circleOfRadius: 10.0, center:CGPoint(x: 5, y: 5))
|
||||||
|
physicsBody?.isDynamic = true
|
||||||
|
|
||||||
|
physicsBody?.categoryBitMask = CollisionCategories.Snake
|
||||||
|
physicsBody?.contactTestBitMask = CollisionCategories.EdgeBody | CollisionCategories.Apple
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// SnakeHead.swift
|
||||||
|
// snakegame
|
||||||
|
//
|
||||||
|
// Created by Nik Rodionov on 23.06.2020.
|
||||||
|
// Copyright © 2020 nrodionov. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SpriteKit
|
||||||
|
|
||||||
|
class SnakeHead: SnakeBodyPart {
|
||||||
|
override init(position: CGPoint) {
|
||||||
|
super.init(position: position)
|
||||||
|
|
||||||
|
physicsBody?.categoryBitMask = CollisionCategories.SnakeHead
|
||||||
|
physicsBody?.contactTestBitMask = CollisionCategories.EdgeBody | CollisionCategories.Apple | CollisionCategories.Snake
|
||||||
|
}
|
||||||
|
|
||||||
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
fatalError("init(coder:) has not been implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user