Skip to content

Commit 0360240

Browse files
committed
initial import
1 parent 69da9f6 commit 0360240

File tree

13 files changed

+96
-10
lines changed

13 files changed

+96
-10
lines changed

FlappyBird.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
43745209193D163800654986 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43745207193D163800654986 /* Main.storyboard */; };
1515
4374520B193D163800654986 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4374520A193D163800654986 /* Images.xcassets */; };
1616
43745217193D163800654986 /* FlappyBirdTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43745216193D163800654986 /* FlappyBirdTests.swift */; };
17+
437A3DBA193D326A00909BA0 /* bird.atlas in Resources */ = {isa = PBXBuildFile; fileRef = 437A3DB9193D326A00909BA0 /* bird.atlas */; };
1718
/* End PBXBuildFile section */
1819

1920
/* Begin PBXContainerItemProxy section */
@@ -38,6 +39,7 @@
3839
43745210193D163800654986 /* FlappyBirdTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FlappyBirdTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3940
43745215193D163800654986 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4041
43745216193D163800654986 /* FlappyBirdTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlappyBirdTests.swift; sourceTree = "<group>"; };
42+
437A3DB9193D326A00909BA0 /* bird.atlas */ = {isa = PBXFileReference; lastKnownFileType = folder.skatlas; path = bird.atlas; sourceTree = "<group>"; };
4143
/* End PBXFileReference section */
4244

4345
/* Begin PBXFrameworksBuildPhase section */
@@ -85,6 +87,7 @@
8587
43745205193D163800654986 /* GameViewController.swift */,
8688
43745207193D163800654986 /* Main.storyboard */,
8789
4374520A193D163800654986 /* Images.xcassets */,
90+
437A3DB9193D326A00909BA0 /* bird.atlas */,
8891
437451FD193D163700654986 /* Supporting Files */,
8992
);
9093
path = FlappyBird;
@@ -197,6 +200,7 @@
197200
files = (
198201
4374520B193D163800654986 /* Images.xcassets in Resources */,
199202
43745202193D163700654986 /* GameScene.sks in Resources */,
203+
437A3DBA193D326A00909BA0 /* bird.atlas in Resources */,
200204
43745209193D163800654986 /* Main.storyboard in Resources */,
201205
);
202206
runOnlyForDeploymentPostprocessing = 0;
@@ -407,6 +411,7 @@
407411
4374521C193D163800654986 /* Release */,
408412
);
409413
defaultConfigurationIsVisible = 0;
414+
defaultConfigurationName = Release;
410415
};
411416
4374521D193D163800654986 /* Build configuration list for PBXNativeTarget "FlappyBirdTests" */ = {
412417
isa = XCConfigurationList;
@@ -415,6 +420,7 @@
415420
4374521F193D163800654986 /* Release */,
416421
);
417422
defaultConfigurationIsVisible = 0;
423+
defaultConfigurationName = Release;
418424
};
419425
/* End XCConfigurationList section */
420426
};

FlappyBird/Base.lproj/Main.storyboard

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6162" systemVersion="14A238h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BV1-FR-VrT">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6154.17" systemVersion="13D65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BV1-FR-VrT">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6160"/>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6153.11"/>
55
</dependencies>
66
<scenes>
77
<!--Game View Controller-->
88
<scene sceneID="tXr-a1-R10">
99
<objects>
10-
<viewController id="BV1-FR-VrT" customClass="GameViewController" customModuleProvider="target" sceneMemberID="viewController">
10+
<viewController id="BV1-FR-VrT" customClass="GameViewController" customModule="FlappyBird" customModuleProvider="target" sceneMemberID="viewController">
1111
<layoutGuides>
1212
<viewControllerLayoutGuide type="top" id="maK-i9-Uhn"/>
1313
<viewControllerLayoutGuide type="bottom" id="khH-OB-KpY"/>
1414
</layoutGuides>
1515
<view key="view" contentMode="scaleToFill" id="3se-qz-xqx" customClass="SKView">
1616
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
1717
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
18-
<color key="backgroundColor" white="0" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
18+
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
19+
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
1920
</view>
2021
</viewController>
2122
<placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/>

FlappyBird/GameScene.swift

+46-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,54 @@
99
import SpriteKit
1010

1111
class GameScene: SKScene {
12+
var bird: SKSpriteNode?
13+
var skyColor: SKColor?
14+
1215
override func didMoveToView(view: SKView) {
13-
/* Setup your scene here */
14-
let myLabel = SKLabelNode(fontNamed:"Chalkduster")
15-
myLabel.text = "Hello, World!";
16-
myLabel.fontSize = 65;
17-
myLabel.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame));
16+
// setup background color
17+
skyColor = SKColor(red: 113.0/255.0, green: 197.0/255.0, blue: 207.0/255.0, alpha: 1.0)
18+
self.backgroundColor = skyColor
19+
20+
// ground
21+
var groundTexture = SKTexture(imageNamed: "land")
22+
groundTexture.filteringMode = SKTextureFilteringMode.Nearest
23+
24+
for var i = 0; CGFloat(i) < (2.0 + self.frame.size.width) / ( groundTexture.size().width * 2.0 ); ++i {
25+
var sprite = SKSpriteNode(texture: groundTexture)
26+
sprite.setScale(2.0)
27+
sprite.position = CGPointMake(CGFloat(i) * sprite.size.width, sprite.size.height / 2.0)
28+
self.addChild(sprite)
29+
}
30+
31+
// skyline
32+
var skyTexture = SKTexture(imageNamed: "sky")
33+
skyTexture.filteringMode = SKTextureFilteringMode.Nearest
34+
35+
for var i = 0; CGFloat(i) < (2.0 + self.frame.size.width) / ( skyTexture.size().width * 2.0 ); ++i {
36+
var sprite = SKSpriteNode(texture: skyTexture)
37+
sprite.setScale(2.0)
38+
sprite.zPosition = -20;
39+
sprite.position = CGPointMake(CGFloat(i) * sprite.size.width, sprite.size.height / 2.0 + groundTexture.size().height * 2.0)
40+
self.addChild(sprite)
41+
}
42+
43+
// setup our bird
44+
var birdTexture1 = SKTexture(imageNamed: "bird-01")
45+
birdTexture1.filteringMode = SKTextureFilteringMode.Nearest
46+
var birdTexture2 = SKTexture(imageNamed: "bird-02")
47+
birdTexture2.filteringMode = SKTextureFilteringMode.Nearest
48+
49+
var anim = SKAction.animateWithTextures([birdTexture1, birdTexture2], timePerFrame: 0.2)
50+
var flap = SKAction.repeatActionForever(anim)
1851

19-
self.addChild(myLabel)
52+
bird = SKSpriteNode(texture: birdTexture1)
53+
bird!.setScale(2.0)
54+
bird!.position = CGPoint(x:CGRectGetMidX(self.frame), y:CGRectGetMidY(self.frame))
55+
bird!.runAction(flap)
56+
self.addChild(bird)
57+
58+
59+
2060
}
2161

2262
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "land.png"
7+
}
8+
],
9+
"info" : {
10+
"version" : 1,
11+
"author" : "xcode"
12+
}
13+
}
278 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "scoreboard.png"
7+
}
8+
],
9+
"info" : {
10+
"version" : 1,
11+
"author" : "xcode"
12+
}
13+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x",
6+
"filename" : "sky.png"
7+
}
8+
],
9+
"info" : {
10+
"version" : 1,
11+
"author" : "xcode"
12+
}
13+
}
4.38 KB
Loading

FlappyBird/bird.atlas/bird-01.png

2.97 KB
Loading

FlappyBird/bird.atlas/bird-02.png

1.13 KB
Loading

FlappyBird/bird.atlas/bird-03.png

1.14 KB
Loading

FlappyBird/bird.atlas/bird-04.png

1.13 KB
Loading

0 commit comments

Comments
 (0)