First version

This commit is contained in:
2022-04-11 17:17:23 +03:00
committed by GitHub
parent 45a79eed20
commit fde1669b60
29 changed files with 1434 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
//
// BoxAttackTests.m
// BoxAttackTests
//
// Created by RUSlan on 29.09.14.
// Copyright (c) 2014 RUSlan. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
@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
+24
View File
@@ -0,0 +1,24 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>RUSlan.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

+465
View File
@@ -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 = "<group>"; };
44797C6719D9B2A700B53D18 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
44797C6919D9B2A700B53D18 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
44797C6A19D9B2A700B53D18 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
44797C6C19D9B2A700B53D18 /* GameScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameScene.h; sourceTree = "<group>"; };
44797C6D19D9B2A700B53D18 /* GameScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameScene.m; sourceTree = "<group>"; };
44797C6F19D9B2A700B53D18 /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = "<group>"; };
44797C7119D9B2A700B53D18 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
44797C7419D9B2A700B53D18 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
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 = "<group>"; };
44797C8019D9B2A700B53D18 /* BoxAttackTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BoxAttackTests.m; sourceTree = "<group>"; };
44797C8A19D9B31400B53D18 /* Entity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Entity.h; sourceTree = "<group>"; };
44797C8B19D9B31400B53D18 /* Entity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Entity.m; sourceTree = "<group>"; };
44797CBB19DAF8D400B53D18 /* sceneParam.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sceneParam.c; sourceTree = "<group>"; };
44797CBE19DB237C00B53D18 /* Box.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Box.png; sourceTree = "<group>"; };
44797CBF19DB237C00B53D18 /* Player.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Player.png; sourceTree = "<group>"; };
44797CC219DB2C3A00B53D18 /* BG.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = BG.png; sourceTree = "<group>"; };
44797CDA19DC81C500B53D18 /* PlayerMove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = PlayerMove.png; sourceTree = "<group>"; };
44EBACA319E30E3100EEC339 /* Level.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Level.h; sourceTree = "<group>"; };
44EBACA419E30E3100EEC339 /* Level.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Level.m; sourceTree = "<group>"; };
/* 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 = "<group>";
};
44797C6319D9B2A700B53D18 /* Products */ = {
isa = PBXGroup;
children = (
44797C6219D9B2A700B53D18 /* BoxAttack.app */,
44797C7A19D9B2A700B53D18 /* BoxAttackTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
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 = "<group>";
};
44797C6519D9B2A700B53D18 /* Supporting Files */ = {
isa = PBXGroup;
children = (
44797C6619D9B2A700B53D18 /* Info.plist */,
44797C6719D9B2A700B53D18 /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
44797C7D19D9B2A700B53D18 /* BoxAttackTests */ = {
isa = PBXGroup;
children = (
44797C8019D9B2A700B53D18 /* BoxAttackTests.m */,
44797C7E19D9B2A700B53D18 /* Supporting Files */,
);
path = BoxAttackTests;
sourceTree = "<group>";
};
44797C7E19D9B2A700B53D18 /* Supporting Files */ = {
isa = PBXGroup;
children = (
44797C7F19D9B2A700B53D18 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
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 = "<group>";
};
/* 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 */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:BoxAttack.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,10 @@
<?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>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C6119D9B2A700B53D18"
BuildableName = "BoxAttack.app"
BlueprintName = "BoxAttack"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C7919D9B2A700B53D18"
BuildableName = "BoxAttackTests.xctest"
BlueprintName = "BoxAttackTests"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C7919D9B2A700B53D18"
BuildableName = "BoxAttackTests.xctest"
BlueprintName = "BoxAttackTests"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C6119D9B2A700B53D18"
BuildableName = "BoxAttack.app"
BlueprintName = "BoxAttack"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C6119D9B2A700B53D18"
BuildableName = "BoxAttack.app"
BlueprintName = "BoxAttack"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "44797C6119D9B2A700B53D18"
BuildableName = "BoxAttack.app"
BlueprintName = "BoxAttack"
ReferencedContainer = "container:BoxAttack.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,27 @@
<?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>BoxAttack.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>44797C6119D9B2A700B53D18</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>44797C7919D9B2A700B53D18</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
+9
View File
@@ -0,0 +1,9 @@
#import <Cocoa/Cocoa.h>
#import <SpriteKit/SpriteKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet SKView *skView;
@end
+46
View File
@@ -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
+132
View File
@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6245" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6245"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="494" id="495"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
<menuItem title="BoxAttack" id="56">
<menu key="submenu" title="BoxAttack" systemMenu="apple" id="57">
<items>
<menuItem title="About BoxAttack" id="58">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="236">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Preferences…" keyEquivalent="," id="129"/>
<menuItem isSeparatorItem="YES" id="143">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Services" id="131">
<menu key="submenu" title="Services" systemMenu="services" id="130"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="144">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Hide BoxAttack" keyEquivalent="h" id="134">
<connections>
<action selector="hide:" target="-1" id="367"/>
</connections>
</menuItem>
<menuItem title="Hide Others" keyEquivalent="h" id="145">
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
<connections>
<action selector="hideOtherApplications:" target="-1" id="368"/>
</connections>
</menuItem>
<menuItem title="Show All" id="150">
<connections>
<action selector="unhideAllApplications:" target="-1" id="370"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="149">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Quit BoxAttack" keyEquivalent="q" id="136">
<connections>
<action selector="terminate:" target="-3" id="449"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Window" id="19">
<menu key="submenu" title="Window" systemMenu="window" id="24">
<items>
<menuItem title="Minimize" keyEquivalent="m" id="537">
<connections>
<action selector="performMiniaturize:" target="-1" id="538"/>
</connections>
</menuItem>
<menuItem title="Zoom" id="239">
<connections>
<action selector="performZoom:" target="-1" id="240"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="92">
<modifierMask key="keyEquivalentModifierMask" command="YES"/>
</menuItem>
<menuItem title="Bring All to Front" id="5">
<connections>
<action selector="arrangeInFront:" target="-1" id="39"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
<menuItem title="Help" id="490">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Help" systemMenu="help" id="491">
<items>
<menuItem title="Tim Help" keyEquivalent="?" id="492">
<connections>
<action selector="showHelp:" target="-1" id="493"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
</items>
</menu>
<window title="BoxAttack" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
<rect key="contentRect" x="0.0" y="0.0" width="640" height="480"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="900"/>
<view key="contentView" id="372">
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView translatesAutoresizingMaskIntoConstraints="NO" id="539" customClass="SKView">
<rect key="frame" x="0.0" y="0.0" width="640" height="480"/>
</customView>
</subviews>
<constraints>
<constraint firstItem="539" firstAttribute="bottom" secondItem="372" secondAttribute="bottom" id="541"/>
<constraint firstItem="539" firstAttribute="top" secondItem="372" secondAttribute="top" id="542"/>
<constraint firstItem="539" firstAttribute="trailing" secondItem="372" secondAttribute="trailing" id="543"/>
<constraint firstItem="539" firstAttribute="leading" secondItem="372" secondAttribute="leading" id="544"/>
</constraints>
</view>
</window>
<customObject id="494" customClass="AppDelegate">
<connections>
<outlet property="skView" destination="539" id="540"/>
<outlet property="window" destination="371" id="532"/>
</connections>
</customObject>
<customObject id="420" customClass="NSFontManager"/>
</objects>
</document>
+34
View File
@@ -0,0 +1,34 @@
#import <SpriteKit/SpriteKit.h>
#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
+105
View File
@@ -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
+48
View File
@@ -0,0 +1,48 @@
#import <SpriteKit/SpriteKit.h>
#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
+249
View File
@@ -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
Binary file not shown.
@@ -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"
}
}
+34
View File
@@ -0,0 +1,34 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>RUSlan.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 RUSlan. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
+9
View File
@@ -0,0 +1,9 @@
#import <Foundation/Foundation.h>
@interface Level : NSObject
{
int goal, delayDec;
}
@property int goal, delayDec;
@end
+7
View File
@@ -0,0 +1,7 @@
#import "Level.h"
@implementation Level
@synthesize goal, delayDec;
@end
+13
View File
@@ -0,0 +1,13 @@
//
// main.m
// BoxAttack
//
// Created by RUSlan on 29.09.14.
// Copyright (c) 2014 RUSlan. All rights reserved.
//
#import <Cocoa/Cocoa.h>
int main(int argc, const char * argv[]) {
return NSApplicationMain(argc, argv);
}
+2
View File
@@ -0,0 +1,2 @@
#define TILE_SIZE 64
#define NUMBER_OF_LVLS 5