diff --git a/BoxAttackTests/BoxAttackTests.m b/BoxAttackTests/BoxAttackTests.m new file mode 100644 index 0000000..e299892 --- /dev/null +++ b/BoxAttackTests/BoxAttackTests.m @@ -0,0 +1,40 @@ +// +// BoxAttackTests.m +// BoxAttackTests +// +// Created by RUSlan on 29.09.14. +// Copyright (c) 2014 RUSlan. All rights reserved. +// + +#import +#import + +@interface BoxAttackTests : XCTestCase + +@end + +@implementation BoxAttackTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + XCTAssert(YES, @"Pass"); +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end diff --git a/BoxAttackTests/Info.plist b/BoxAttackTests/Info.plist new file mode 100644 index 0000000..3c6d4dc --- /dev/null +++ b/BoxAttackTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + RUSlan.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Orig/Player.psd b/Orig/Player.psd new file mode 100644 index 0000000..0e98ab9 Binary files /dev/null and b/Orig/Player.psd differ diff --git a/Orig/PlayerMove.psd b/Orig/PlayerMove.psd new file mode 100644 index 0000000..28510b3 Binary files /dev/null and b/Orig/PlayerMove.psd differ diff --git a/Textures/BG.png b/Textures/BG.png new file mode 100644 index 0000000..c60d081 Binary files /dev/null and b/Textures/BG.png differ diff --git a/Textures/Box.png b/Textures/Box.png new file mode 100644 index 0000000..f8abdf7 Binary files /dev/null and b/Textures/Box.png differ diff --git a/Textures/Player.png b/Textures/Player.png new file mode 100644 index 0000000..bc26ddd Binary files /dev/null and b/Textures/Player.png differ diff --git a/Textures/PlayerMove.png b/Textures/PlayerMove.png new file mode 100644 index 0000000..98a21e5 Binary files /dev/null and b/Textures/PlayerMove.png differ diff --git a/boxattack.xcodeproj/project.pbxproj b/boxattack.xcodeproj/project.pbxproj new file mode 100644 index 0000000..c1584d8 --- /dev/null +++ b/boxattack.xcodeproj/project.pbxproj @@ -0,0 +1,465 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 44797C6819D9B2A700B53D18 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 44797C6719D9B2A700B53D18 /* main.m */; }; + 44797C6B19D9B2A700B53D18 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 44797C6A19D9B2A700B53D18 /* AppDelegate.m */; }; + 44797C6E19D9B2A700B53D18 /* GameScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 44797C6D19D9B2A700B53D18 /* GameScene.m */; }; + 44797C7019D9B2A700B53D18 /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = 44797C6F19D9B2A700B53D18 /* GameScene.sks */; }; + 44797C7219D9B2A700B53D18 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44797C7119D9B2A700B53D18 /* Images.xcassets */; }; + 44797C7519D9B2A700B53D18 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 44797C7319D9B2A700B53D18 /* MainMenu.xib */; }; + 44797C8119D9B2A700B53D18 /* BoxAttackTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 44797C8019D9B2A700B53D18 /* BoxAttackTests.m */; }; + 44797C8C19D9B31400B53D18 /* Entity.m in Sources */ = {isa = PBXBuildFile; fileRef = 44797C8B19D9B31400B53D18 /* Entity.m */; }; + 44797CBC19DAF8D400B53D18 /* sceneParam.c in Sources */ = {isa = PBXBuildFile; fileRef = 44797CBB19DAF8D400B53D18 /* sceneParam.c */; }; + 44797CC019DB237C00B53D18 /* Box.png in Resources */ = {isa = PBXBuildFile; fileRef = 44797CBE19DB237C00B53D18 /* Box.png */; }; + 44797CC119DB237C00B53D18 /* Player.png in Resources */ = {isa = PBXBuildFile; fileRef = 44797CBF19DB237C00B53D18 /* Player.png */; }; + 44797CC319DB2C3A00B53D18 /* BG.png in Resources */ = {isa = PBXBuildFile; fileRef = 44797CC219DB2C3A00B53D18 /* BG.png */; }; + 44797CDB19DC81C500B53D18 /* PlayerMove.png in Resources */ = {isa = PBXBuildFile; fileRef = 44797CDA19DC81C500B53D18 /* PlayerMove.png */; }; + 44EBACA519E30E3100EEC339 /* Level.m in Sources */ = {isa = PBXBuildFile; fileRef = 44EBACA419E30E3100EEC339 /* Level.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 44797C7B19D9B2A700B53D18 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 44797C5A19D9B2A700B53D18 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 44797C6119D9B2A700B53D18; + remoteInfo = BoxAttack; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 44797C6219D9B2A700B53D18 /* BoxAttack.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BoxAttack.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 44797C6619D9B2A700B53D18 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 44797C6719D9B2A700B53D18 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 44797C6919D9B2A700B53D18 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 44797C6A19D9B2A700B53D18 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 44797C6C19D9B2A700B53D18 /* GameScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameScene.h; sourceTree = ""; }; + 44797C6D19D9B2A700B53D18 /* GameScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameScene.m; sourceTree = ""; }; + 44797C6F19D9B2A700B53D18 /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = ""; }; + 44797C7119D9B2A700B53D18 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 44797C7419D9B2A700B53D18 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 44797C7A19D9B2A700B53D18 /* BoxAttackTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BoxAttackTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 44797C7F19D9B2A700B53D18 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 44797C8019D9B2A700B53D18 /* BoxAttackTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BoxAttackTests.m; sourceTree = ""; }; + 44797C8A19D9B31400B53D18 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = ""; }; + 44797C8B19D9B31400B53D18 /* Entity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Entity.m; sourceTree = ""; }; + 44797CBB19DAF8D400B53D18 /* sceneParam.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sceneParam.c; sourceTree = ""; }; + 44797CBE19DB237C00B53D18 /* Box.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Box.png; sourceTree = ""; }; + 44797CBF19DB237C00B53D18 /* Player.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Player.png; sourceTree = ""; }; + 44797CC219DB2C3A00B53D18 /* BG.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BG.png; sourceTree = ""; }; + 44797CDA19DC81C500B53D18 /* PlayerMove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PlayerMove.png; sourceTree = ""; }; + 44EBACA319E30E3100EEC339 /* Level.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Level.h; sourceTree = ""; }; + 44EBACA419E30E3100EEC339 /* Level.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Level.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 44797C5F19D9B2A700B53D18 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 44797C7719D9B2A700B53D18 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 44797C5919D9B2A700B53D18 = { + isa = PBXGroup; + children = ( + 44797C6419D9B2A700B53D18 /* BoxAttack */, + 44797C7D19D9B2A700B53D18 /* BoxAttackTests */, + 44797C6319D9B2A700B53D18 /* Products */, + ); + sourceTree = ""; + }; + 44797C6319D9B2A700B53D18 /* Products */ = { + isa = PBXGroup; + children = ( + 44797C6219D9B2A700B53D18 /* BoxAttack.app */, + 44797C7A19D9B2A700B53D18 /* BoxAttackTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 44797C6419D9B2A700B53D18 /* BoxAttack */ = { + isa = PBXGroup; + children = ( + 44EBACA319E30E3100EEC339 /* Level.h */, + 44EBACA419E30E3100EEC339 /* Level.m */, + 44797CBD19DB237C00B53D18 /* Textures */, + 44797C6919D9B2A700B53D18 /* AppDelegate.h */, + 44797C6A19D9B2A700B53D18 /* AppDelegate.m */, + 44797C6C19D9B2A700B53D18 /* GameScene.h */, + 44797C6D19D9B2A700B53D18 /* GameScene.m */, + 44797C6F19D9B2A700B53D18 /* GameScene.sks */, + 44797C7119D9B2A700B53D18 /* Images.xcassets */, + 44797C7319D9B2A700B53D18 /* MainMenu.xib */, + 44797C6519D9B2A700B53D18 /* Supporting Files */, + 44797C8A19D9B31400B53D18 /* Entity.h */, + 44797C8B19D9B31400B53D18 /* Entity.m */, + 44797CBB19DAF8D400B53D18 /* sceneParam.c */, + ); + path = BoxAttack; + sourceTree = ""; + }; + 44797C6519D9B2A700B53D18 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 44797C6619D9B2A700B53D18 /* Info.plist */, + 44797C6719D9B2A700B53D18 /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 44797C7D19D9B2A700B53D18 /* BoxAttackTests */ = { + isa = PBXGroup; + children = ( + 44797C8019D9B2A700B53D18 /* BoxAttackTests.m */, + 44797C7E19D9B2A700B53D18 /* Supporting Files */, + ); + path = BoxAttackTests; + sourceTree = ""; + }; + 44797C7E19D9B2A700B53D18 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 44797C7F19D9B2A700B53D18 /* Info.plist */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; + 44797CBD19DB237C00B53D18 /* Textures */ = { + isa = PBXGroup; + children = ( + 44797CDA19DC81C500B53D18 /* PlayerMove.png */, + 44797CC219DB2C3A00B53D18 /* BG.png */, + 44797CBE19DB237C00B53D18 /* Box.png */, + 44797CBF19DB237C00B53D18 /* Player.png */, + ); + path = Textures; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 44797C6119D9B2A700B53D18 /* BoxAttack */ = { + isa = PBXNativeTarget; + buildConfigurationList = 44797C8419D9B2A700B53D18 /* Build configuration list for PBXNativeTarget "BoxAttack" */; + buildPhases = ( + 44797C5E19D9B2A700B53D18 /* Sources */, + 44797C5F19D9B2A700B53D18 /* Frameworks */, + 44797C6019D9B2A700B53D18 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = BoxAttack; + productName = BoxAttack; + productReference = 44797C6219D9B2A700B53D18 /* BoxAttack.app */; + productType = "com.apple.product-type.application"; + }; + 44797C7919D9B2A700B53D18 /* BoxAttackTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 44797C8719D9B2A700B53D18 /* Build configuration list for PBXNativeTarget "BoxAttackTests" */; + buildPhases = ( + 44797C7619D9B2A700B53D18 /* Sources */, + 44797C7719D9B2A700B53D18 /* Frameworks */, + 44797C7819D9B2A700B53D18 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 44797C7C19D9B2A700B53D18 /* PBXTargetDependency */, + ); + name = BoxAttackTests; + productName = BoxAttackTests; + productReference = 44797C7A19D9B2A700B53D18 /* BoxAttackTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 44797C5A19D9B2A700B53D18 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0600; + ORGANIZATIONNAME = RUSlan; + TargetAttributes = { + 44797C6119D9B2A700B53D18 = { + CreatedOnToolsVersion = 6.0.1; + }; + 44797C7919D9B2A700B53D18 = { + CreatedOnToolsVersion = 6.0.1; + TestTargetID = 44797C6119D9B2A700B53D18; + }; + }; + }; + buildConfigurationList = 44797C5D19D9B2A700B53D18 /* Build configuration list for PBXProject "BoxAttack" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 44797C5919D9B2A700B53D18; + productRefGroup = 44797C6319D9B2A700B53D18 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 44797C6119D9B2A700B53D18 /* BoxAttack */, + 44797C7919D9B2A700B53D18 /* BoxAttackTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 44797C6019D9B2A700B53D18 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 44797C7019D9B2A700B53D18 /* GameScene.sks in Resources */, + 44797C7219D9B2A700B53D18 /* Images.xcassets in Resources */, + 44797CC319DB2C3A00B53D18 /* BG.png in Resources */, + 44797C7519D9B2A700B53D18 /* MainMenu.xib in Resources */, + 44797CC019DB237C00B53D18 /* Box.png in Resources */, + 44797CDB19DC81C500B53D18 /* PlayerMove.png in Resources */, + 44797CC119DB237C00B53D18 /* Player.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 44797C7819D9B2A700B53D18 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 44797C5E19D9B2A700B53D18 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 44EBACA519E30E3100EEC339 /* Level.m in Sources */, + 44797CBC19DAF8D400B53D18 /* sceneParam.c in Sources */, + 44797C8C19D9B31400B53D18 /* Entity.m in Sources */, + 44797C6B19D9B2A700B53D18 /* AppDelegate.m in Sources */, + 44797C6E19D9B2A700B53D18 /* GameScene.m in Sources */, + 44797C6819D9B2A700B53D18 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 44797C7619D9B2A700B53D18 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 44797C8119D9B2A700B53D18 /* BoxAttackTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 44797C7C19D9B2A700B53D18 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 44797C6119D9B2A700B53D18 /* BoxAttack */; + targetProxy = 44797C7B19D9B2A700B53D18 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 44797C7319D9B2A700B53D18 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 44797C7419D9B2A700B53D18 /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 44797C8219D9B2A700B53D18 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + 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; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 44797C8319D9B2A700B53D18 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + 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; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + 44797C8519D9B2A700B53D18 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = BoxAttack/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 44797C8619D9B2A700B53D18 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = BoxAttack/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 44797C8819D9B2A700B53D18 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(DEVELOPER_FRAMEWORKS_DIR)", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = BoxAttackTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BoxAttack.app/Contents/MacOS/BoxAttack"; + }; + name = Debug; + }; + 44797C8919D9B2A700B53D18 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(DEVELOPER_FRAMEWORKS_DIR)", + "$(inherited)", + ); + INFOPLIST_FILE = BoxAttackTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/BoxAttack.app/Contents/MacOS/BoxAttack"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 44797C5D19D9B2A700B53D18 /* Build configuration list for PBXProject "BoxAttack" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 44797C8219D9B2A700B53D18 /* Debug */, + 44797C8319D9B2A700B53D18 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 44797C8419D9B2A700B53D18 /* Build configuration list for PBXNativeTarget "BoxAttack" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 44797C8519D9B2A700B53D18 /* Debug */, + 44797C8619D9B2A700B53D18 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 44797C8719D9B2A700B53D18 /* Build configuration list for PBXNativeTarget "BoxAttackTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 44797C8819D9B2A700B53D18 /* Debug */, + 44797C8919D9B2A700B53D18 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 44797C5A19D9B2A700B53D18 /* Project object */; +} diff --git a/boxattack.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/boxattack.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..ed3bcc2 --- /dev/null +++ b/boxattack.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/UserInterfaceState.xcuserstate b/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..a8894f6 Binary files /dev/null and b/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/WorkspaceSettings.xcsettings b/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..659c876 --- /dev/null +++ b/boxattack.xcodeproj/project.xcworkspace/xcuserdata/ruslan.xcuserdatad/WorkspaceSettings.xcsettings @@ -0,0 +1,10 @@ + + + + + HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges + + SnapshotAutomaticallyBeforeSignificantChanges + + + diff --git a/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/BoxAttack.xcscheme b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/BoxAttack.xcscheme new file mode 100644 index 0000000..d66cd15 --- /dev/null +++ b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/BoxAttack.xcscheme @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/xcschememanagement.plist b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..821a32b --- /dev/null +++ b/boxattack.xcodeproj/xcuserdata/ruslan.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + BoxAttack.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 44797C6119D9B2A700B53D18 + + primary + + + 44797C7919D9B2A700B53D18 + + primary + + + + + diff --git a/boxattack/AppDelegate.h b/boxattack/AppDelegate.h new file mode 100644 index 0000000..a368db8 --- /dev/null +++ b/boxattack/AppDelegate.h @@ -0,0 +1,9 @@ +#import +#import + +@interface AppDelegate : NSObject + +@property (assign) IBOutlet NSWindow *window; +@property (assign) IBOutlet SKView *skView; + +@end diff --git a/boxattack/AppDelegate.m b/boxattack/AppDelegate.m new file mode 100644 index 0000000..8aa185c --- /dev/null +++ b/boxattack/AppDelegate.m @@ -0,0 +1,46 @@ +#import "AppDelegate.h" +#import "GameScene.h" + +@implementation SKScene (Unarchive) + ++ (instancetype)unarchiveFromFile:(NSString *)file { + /* Retrieve scene file path from the application bundle */ + NSString *nodePath = [[NSBundle mainBundle] pathForResource:file ofType:@"sks"]; + /* Unarchive the file to an SKScene object */ + NSData *data = [NSData dataWithContentsOfFile:nodePath + options:NSDataReadingMappedIfSafe + error:nil]; + NSKeyedUnarchiver *arch = [[NSKeyedUnarchiver alloc] initForReadingWithData:data]; + [arch setClass:self forClassName:@"SKScene"]; + SKScene *scene = [arch decodeObjectForKey:NSKeyedArchiveRootObjectKey]; + [arch finishDecoding]; + + return scene; +} + +@end + +@implementation AppDelegate + +@synthesize window = _window; + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { + GameScene *scene = [GameScene unarchiveFromFile:@"GameScene"]; + + /* Set the scale mode to scale to fit the window */ + scene.scaleMode = SKSceneScaleModeAspectFit; + + [self.skView presentScene:scene]; + + /* Sprite Kit applies additional optimizations to improve rendering performance */ + self.skView.ignoresSiblingOrder = YES; + + self.skView.showsFPS = YES; + self.skView.showsNodeCount = YES; +} + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { + return YES; +} + +@end diff --git a/boxattack/Base.lproj/MainMenu.xib b/boxattack/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..76b1377 --- /dev/null +++ b/boxattack/Base.lproj/MainMenu.xib @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/boxattack/Entity.h b/boxattack/Entity.h new file mode 100644 index 0000000..9a3c500 --- /dev/null +++ b/boxattack/Entity.h @@ -0,0 +1,34 @@ +#import +#import "sceneParam.c" + +@interface Entity : SKSpriteNode +{ + @private + BOOL isBlockedFromLeft; + BOOL isBlockedFromRight; + BOOL isBlockedFromUp; + BOOL isBlockedFromDown; + Entity *blockedFromLeftBy; + Entity *blockedFromRightBy; + Entity *blockedFromUpBy; + Entity *blockedFromDownBy; +} +@property BOOL isBlockedFromLeft; +@property BOOL isBlockedFromRight; +@property BOOL isBlockedFromUp; +@property BOOL isBlockedFromDown; +@property Entity *blockedFromLeftBy; +@property Entity *blockedFromRightBy; +@property Entity *blockedFromUpBy; +@property Entity *blockedFromDownBy; + +-(void)resetCollisions; +-(void)checkCollisionWith:(Entity *) secondEntity; +-(void)checkCollisionWithRoomWithWidth:(CGFloat)roomWidth; + +-(void)moveLeft; +-(void)moveRight; +-(void)fall; +-(void)jump; + +@end diff --git a/boxattack/Entity.m b/boxattack/Entity.m new file mode 100644 index 0000000..a4b507e --- /dev/null +++ b/boxattack/Entity.m @@ -0,0 +1,105 @@ +#import "Entity.h" + +@implementation Entity + +@synthesize isBlockedFromLeft, isBlockedFromRight, isBlockedFromUp, isBlockedFromDown; +@synthesize blockedFromLeftBy, blockedFromRightBy, blockedFromUpBy, blockedFromDownBy; + +-(void)resetCollisions { + self.isBlockedFromLeft = self.isBlockedFromRight = self.isBlockedFromUp = self.isBlockedFromDown = false; + self.blockedFromLeftBy = self.blockedFromRightBy = self.blockedFromUpBy = self.blockedFromDownBy = nil; +} + +-(void)checkCollisionWith:(Entity *)secondEntity { + if ((lround(self.position.x - secondEntity.size.width-1) < lround(secondEntity.position.x))&& + (lround(self.position.x - secondEntity.size.width+1) > lround(secondEntity.position.x))) { + if ((lround(self.position.y + secondEntity.size.height) > lround(secondEntity.position.y))&& + ((lround(self.position.y - secondEntity.size.height) < lround(secondEntity.position.y)))) { + self.isBlockedFromLeft = true; + blockedFromLeftBy = secondEntity; + } + } + if ((lround(self.position.x + self.size.width-1) < lround(secondEntity.position.x))&& + (lround(self.position.x + self.size.width+1) > lround(secondEntity.position.x))) { + if ((lround(self.position.y + secondEntity.size.height) > lround(secondEntity.position.y))&& + ((lround(self.position.y - secondEntity.size.height) < lround(secondEntity.position.y)))) + { + self.isBlockedFromRight = true; + blockedFromRightBy = secondEntity; + } + } + if ((lround(self.position.x - self.size.width) < lround(secondEntity.position.x))&& + (lround(self.position.x + self.size.width) > (secondEntity.position.x))) { + if ((lround(self.position.y + self.size.height*0.75) < lround(secondEntity.position.y))&& + (lround(self.position.y + self.size.height+1) > lround(secondEntity.position.y))) { + self.isBlockedFromUp = true; + blockedFromUpBy = secondEntity; + } + } + if ((lround(self.position.x - self.size.width+1) < lround(secondEntity.position.x))&& + (lround(self.position.x + self.size.width-1) > (secondEntity.position.x))) { + if ((lround(self.position.y - secondEntity.size.height-1) <= lround(secondEntity.position.y))&& + (lround(self.position.y - secondEntity.size.height+1) >= lround(secondEntity.position.y))) { + self.isBlockedFromDown = true; + blockedFromDownBy = secondEntity; + } + } +} + +-(void)checkCollisionWithRoomWithWidth:(CGFloat)roomWidth { + if (lround(self.position.x) == 0) { + self.isBlockedFromLeft = true; + } + if (lround(self.position.x) == lround(roomWidth - TILE_SIZE)) { + self.isBlockedFromRight = true; + } + if (lround(self.position.y) == 0) { + self.isBlockedFromDown = true; + } +} + +-(void)moveLeft { + if (![self actionForKey:@"move"]) { + SKAction *moveLeft = [SKAction moveByX:-TILE_SIZE y:0 duration: (self.isBlockedFromLeft) ? 0.7 : 0.4]; + if ((!self.isBlockedFromLeft)|| + (!(self.blockedFromRightBy.isBlockedFromLeft)&&(!self.blockedFromRightBy.isBlockedFromUp))) { + [self runAction:moveLeft withKey:@"move"]; + [self.blockedFromLeftBy runAction:moveLeft]; + } + } +} + +-(void)moveRight { + if (![self actionForKey:@"move"]) { + SKAction *moveRight = [SKAction moveByX:+TILE_SIZE y:0 duration: (self.isBlockedFromRight) ? 0.7 : 0.4]; + if ((!self.isBlockedFromRight)|| + (!(self.blockedFromRightBy.isBlockedFromRight)&&(!self.blockedFromRightBy.isBlockedFromUp))) { + [self runAction:moveRight withKey:@"move"]; + [self.blockedFromRightBy runAction:moveRight]; + } + } +} + +-(void)fall { + if (!self.isBlockedFromDown) { + SKAction *fall = [SKAction moveByX:0 y:-TILE_SIZE*0.5 duration:0.1]; + SKAction *idle = [SKAction moveByX:0 y:0 duration:0.4]; + if ((![self actionForKey:@"fall"])&&(![self actionForKey:@"jump"])) { + [self runAction:fall withKey:@"fall"]; + [self runAction:idle withKey:@"afterFallIdle"]; + } + } +} + +-(void)jump { + if (self.isBlockedFromDown) { + SKAction *jump = [SKAction moveByX:0 y:+TILE_SIZE*1.5 duration:0.15]; + SKAction *pauseAfterJump = [SKAction moveByX:0 y:0 duration:0.2]; + if (![self actionForKey:@"jump"]) { + [self runAction:jump]; + [self runAction:pauseAfterJump withKey:@"jump"]; + } + } +} + +@end diff --git a/boxattack/GameScene.h b/boxattack/GameScene.h new file mode 100644 index 0000000..c9d32cf --- /dev/null +++ b/boxattack/GameScene.h @@ -0,0 +1,48 @@ +#import +#import "Entity.h" +#import "Level.h" +#import "sceneParam.c" + +@interface GameScene : SKScene +{ + Entity *player; + NSMutableArray *boxes; + SKSpriteNode *background; + SKLabelNode *scoreLabel; + SKLabelNode *levelLabel; + CFTimeInterval lastUpdateTime; + CFTimeInterval pauseBeforeBoxDrop; + CFTimeInterval boxDropDelay; + int score; + NSMutableArray *levels; + int currentLvl; + BOOL godmode; + SKLabelNode *godmodeLabel; +} +@property Entity *player; +@property NSMutableArray *boxes; +@property SKSpriteNode *background; +@property SKLabelNode *scoreLabel; +@property SKLabelNode *levelLabel; +@property CFTimeInterval lastUpdateTime; +@property CFTimeInterval pauseBeforeBoxDrop; +@property CFTimeInterval boxDropDelay; +@property int score; +@property NSMutableArray *levels; +@property int currentLvl; +@property BOOL godmode; +@property SKLabelNode *godmodeLabel; + +-(void)backGrInit; +-(void)playerInit; +-(void)scoreLabelInit; +-(void)levelLabelInit; +-(void)godmodeLabelInit; + +-(void)newGame; +-(void)newBox; +-(int)getRandomNumberBetween:(int)start and:(int)end; +-(void)checkForPlayerIsBlockedBy:(Entity *) checkedBox; +-(void)checkForFullLine; + +@end diff --git a/boxattack/GameScene.m b/boxattack/GameScene.m new file mode 100644 index 0000000..8247ea4 --- /dev/null +++ b/boxattack/GameScene.m @@ -0,0 +1,249 @@ +#import "GameScene.h" + +@implementation GameScene + +@synthesize player, boxes, levels, background, scoreLabel, levelLabel, godmodeLabel; +@synthesize lastUpdateTime, pauseBeforeBoxDrop, boxDropDelay; +@synthesize score, currentLvl, godmode; + +-(void)didMoveToView:(SKView *)view { + boxes = [NSMutableArray new]; + levels = [NSMutableArray new]; + + self.size = CGSizeMake(640, 480); + + background = [SKSpriteNode new]; + player = [Entity new]; + scoreLabel = [SKLabelNode new]; + levelLabel = [SKLabelNode new]; + godmodeLabel = [SKLabelNode new]; + + [self backGrInit]; + [self playerInit]; + [self scoreLabelInit]; + [self levelLabelInit]; + [self godmodeLabelInit]; + + for (int i = 0; i < NUMBER_OF_LVLS; i++) { + Level *newLvl = [Level new]; + newLvl.goal = (i+1)*2; + newLvl.delayDec = 0.5*i; + [levels addObject:newLvl]; + } + + godmode = false; + + [self newGame]; + + + //----- + SKLabelNode *test = [SKLabelNode new]; + test.fontName = @"Arial"; + test.position = CGPointMake(TILE_SIZE*2, TILE_SIZE*2); + test.text = @"Test"; + test.fontColor = [NSColor blackColor]; + test.fontSize = 8; + [self addChild:test]; +} + +-(void)backGrInit { + background = [SKSpriteNode spriteNodeWithImageNamed:@"BG.png"]; + background.anchorPoint = CGPointMake(0, 0); + background.position = CGPointMake(0, 0); + [self addChild:background]; +} + +-(void)playerInit { + SKTexture *playerTexture = [SKTexture textureWithImageNamed:@"Player.png"]; + player = [Entity spriteNodeWithTexture:playerTexture]; + player.anchorPoint = CGPointMake(0, 0); + player.size = CGSizeMake(TILE_SIZE, TILE_SIZE*1.5); + [self addChild:player]; +} + +-(void)scoreLabelInit { + scoreLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; + scoreLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft; + scoreLabel.position = CGPointMake(TILE_SIZE, self.size.height - TILE_SIZE); + scoreLabel.fontColor = [NSColor blackColor]; + scoreLabel.fontSize = 24; + [self addChild:scoreLabel]; +} + +-(void)levelLabelInit { + levelLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; + levelLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeLeft; + levelLabel.position = CGPointMake(TILE_SIZE, self.size.height - TILE_SIZE*1.5); + levelLabel.fontColor = [NSColor blackColor]; + levelLabel.fontSize = 24; + [self addChild:levelLabel]; +} + +-(void)godmodeLabelInit { + godmodeLabel = [SKLabelNode labelNodeWithFontNamed:@"Arial"]; + godmodeLabel.hidden = true; + godmodeLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeRight; + godmodeLabel.position = CGPointMake(self.size.width - TILE_SIZE, self.size.height - TILE_SIZE); + godmodeLabel.fontColor = [NSColor blackColor]; + godmodeLabel.fontSize = 8; + godmodeLabel.text = @"Godmode"; + [self addChild:godmodeLabel]; +} + +-(void)newGame { + currentLvl = 0; + pauseBeforeBoxDrop = 0; + lastUpdateTime = 0; + boxDropDelay = 2; + score = 0; + player.position = CGPointMake(TILE_SIZE*5, TILE_SIZE*2); + [player removeAllActions]; + + for (int i = 0; i < boxes.count; i++) { + [boxes[i] removeFromParent]; + } + + [boxes removeAllObjects]; +} + +-(void)update:(CFTimeInterval)currentTime { + CFTimeInterval timeSinceLastUpdate = currentTime - lastUpdateTime; + lastUpdateTime = currentTime; + if (timeSinceLastUpdate > 1) { + timeSinceLastUpdate = 1.0 / 60.0; + lastUpdateTime = currentTime; + } + + [player resetCollisions]; + scoreLabel.text = [NSString stringWithFormat:@"Score:\t%d", score]; + levelLabel.text = [NSString stringWithFormat:@"Level:\t%d", currentLvl+1]; + for (int i = 0; i < boxes.count; i++) { + Entity *checkedBox = [boxes objectAtIndex:i]; + + [checkedBox resetCollisions]; + + [player checkCollisionWith:checkedBox]; + [checkedBox checkCollisionWith:player]; + for (int j = 0; j < boxes.count; j++) if (i != j) { + [checkedBox checkCollisionWith:[boxes objectAtIndex:j]]; + } + + [checkedBox checkCollisionWithRoomWithWidth: self.size.width]; + [checkedBox fall]; + + [self checkForPlayerIsBlockedBy: checkedBox]; + } + + pauseBeforeBoxDrop += timeSinceLastUpdate; + if (pauseBeforeBoxDrop > boxDropDelay) { + pauseBeforeBoxDrop = 0; + boxDropDelay = [self getRandomNumberBetween:1 and:4] - ((Level *)levels[currentLvl]).delayDec; + [self newBox]; + } + + [player checkCollisionWithRoomWithWidth: self.size.width]; + [player fall]; + + [self checkForFullLine]; +} + +-(void)checkForPlayerIsBlockedBy:(Entity *) checkedBox { + if (player.isBlockedFromUp) { + if ([player actionForKey:@"jump"]) { + [checkedBox removeFromParent]; + [boxes removeObject:checkedBox]; + } + else { + if (!godmode) { + [self newGame]; + } + } + } +} + +-(void)checkForFullLine { + NSMutableArray *firstLine = [NSMutableArray new]; + for (int i = 0; i < boxes.count; i++) { + Entity *checkedBox = [boxes objectAtIndex:i]; + if (lround(checkedBox.position.y) == 0) { + if ((checkedBox.isBlockedFromDown)&&!([checkedBox actionForKey:@"afterFallIdle"])) { + [firstLine addObject:checkedBox]; + } + } + } + if (firstLine.count > 9) { + for (int i = 0; i < firstLine.count; i++) { + Entity *boxForDel = [firstLine objectAtIndex:i]; + [boxForDel removeFromParent]; + [boxes removeObject:boxForDel]; + } + score++; + if (score > ((Level *)levels[currentLvl]).goal) { + currentLvl++; + score = 0; + } + } +} + +-(void)newBox { + SKTexture *boxTexture = [SKTexture textureWithImageNamed:@"Box.png"]; + Entity *box = [Entity spriteNodeWithTexture:boxTexture]; + box.size = CGSizeMake(TILE_SIZE, TILE_SIZE); + box.anchorPoint = CGPointMake(0, 0); + box.position = CGPointMake(TILE_SIZE*[self getRandomNumberBetween:0 and:9], TILE_SIZE*9); + [boxes addObject:box]; + [self addChild: [boxes lastObject]]; +} + +-(void)keyDown:(NSEvent *)theEvent { + if ([theEvent modifierFlags] & NSNumericPadKeyMask) { + + NSString *arrow = [theEvent charactersIgnoringModifiers]; + if ([arrow length] == 1) { + unichar keyChar = [arrow characterAtIndex: 0]; + switch (keyChar) { + case NSLeftArrowFunctionKey: + [player moveLeft]; + break; + case NSRightArrowFunctionKey: + [player moveRight]; + break; + case NSUpArrowFunctionKey: + [player jump]; + break; + } + } + } + NSString *characters = [theEvent characters]; + for (int i = 0; i < [characters length]; i++) { + unichar c = [characters characterAtIndex: i]; + switch (c) { + case 'a': + [player moveLeft]; + break; + case 'd': + [player moveRight]; + break; + case 'w': + case ' ': + [player jump]; + break; + case 'B': + [self newBox]; + break; + case 'N': + [self newGame]; + break; + case 'G': + godmode = !godmode; + godmodeLabel.hidden = !godmode; + break; + } + } +} + +-(int)getRandomNumberBetween:(int)start and:(int)end { + return start + arc4random()%(end-start+1); +} + +@end diff --git a/boxattack/GameScene.sks b/boxattack/GameScene.sks new file mode 100644 index 0000000..61eb4fe Binary files /dev/null and b/boxattack/GameScene.sks differ diff --git a/boxattack/Images.xcassets/AppIcon.appiconset/Contents.json b/boxattack/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..2db2b1c --- /dev/null +++ b/boxattack/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/boxattack/Info.plist b/boxattack/Info.plist new file mode 100644 index 0000000..6ffa72c --- /dev/null +++ b/boxattack/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + RUSlan.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2014 RUSlan. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/boxattack/Level.h b/boxattack/Level.h new file mode 100644 index 0000000..668a0d1 --- /dev/null +++ b/boxattack/Level.h @@ -0,0 +1,9 @@ +#import + +@interface Level : NSObject +{ + int goal, delayDec; +} +@property int goal, delayDec; + +@end diff --git a/boxattack/Level.m b/boxattack/Level.m new file mode 100644 index 0000000..1794898 --- /dev/null +++ b/boxattack/Level.m @@ -0,0 +1,7 @@ +#import "Level.h" + +@implementation Level + +@synthesize goal, delayDec; + +@end diff --git a/boxattack/main.m b/boxattack/main.m new file mode 100644 index 0000000..6cf2b87 --- /dev/null +++ b/boxattack/main.m @@ -0,0 +1,13 @@ +// +// main.m +// BoxAttack +// +// Created by RUSlan on 29.09.14. +// Copyright (c) 2014 RUSlan. All rights reserved. +// + +#import + +int main(int argc, const char * argv[]) { + return NSApplicationMain(argc, argv); +} diff --git a/boxattack/sceneParam.c b/boxattack/sceneParam.c new file mode 100644 index 0000000..127df1d --- /dev/null +++ b/boxattack/sceneParam.c @@ -0,0 +1,2 @@ +#define TILE_SIZE 64 +#define NUMBER_OF_LVLS 5 \ No newline at end of file