Skip to content

Commit

Permalink
Updated Project. Optimizing In Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWilloughby committed Dec 7, 2016
1 parent 76dd3ca commit 5015e60
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 134 deletions.
2 changes: 2 additions & 0 deletions FingersRevenge/FingersRevenge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = P5F2W7RU5W;
INFOPLIST_FILE = FingersRevenge/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.finger.FingersRevenge;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -405,6 +406,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = P5F2W7RU5W;
INFOPLIST_FILE = FingersRevenge/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.finger.FingersRevenge;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,4 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FingersRevenge/GameScene.swift"
timestampString = "498448206.357201"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "284"
endingLineNumber = "284"
landmarkName = "gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "FingersRevenge/AudioManager.swift"
timestampString = "498436527.753665"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "50"
endingLineNumber = "50"
landmarkName = "playNailClip()"
landmarkType = "9">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Binary file modified FingersRevenge/FingersRevenge/FingerParticle.sks
Binary file not shown.
203 changes: 104 additions & 99 deletions FingersRevenge/FingersRevenge/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
var dt: TimeInterval = 0
var spritesMoving = true

//obstacl spawning ivars
//obstacle spawning ivars
var obstacleInterval = 1.5
var obstacleSpawnTimer = 1.5

Expand All @@ -43,6 +43,8 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
var playerTouch:UITouch?

var levelManager:LevelManager
var endlessChunkOffset:CGFloat = 50.0
var finishHasSpawned: Bool = false


var healthBar:SKSpriteNode = SKSpriteNode(texture: SKTexture(image: #imageLiteral(resourceName: "ThreeHealth")))
Expand Down Expand Up @@ -92,6 +94,95 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
fatalError("init(coder:) has not been implemented")
}

func panDetected(_ sender:UIPanGestureRecognizer) {
//Handle gesture recognition
sender.maximumNumberOfTouches = 1; // programming
if sender.state == .began{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
let touchedNodes = self.nodes(at: touchLocation)
for sprite in touchedNodes{
if let name = sprite.name{
if name == "player"
{
playerSprite.changeColor(strokeColor: SKColor.clear, fillColor: SKColor.clear)
setPauseState(gamePaused: false)
}
}
}
}
if(sender.state == .changed){
if(playerSprite.canMove)
{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
playerSprite.position = touchLocation

}
}
if(sender.state == .ended){
playerSprite.changeColor(strokeColor: SKColor.white, fillColor: SKColor.lightGray)
setPauseState(gamePaused: true)
}
}

//handle tapping
func tapDetected(_ sender:UITapGestureRecognizer){
if spritesMoving == true{
if sender.state == .ended{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
let s = ProjectileSprite(size: SKTexture(image: #imageLiteral(resourceName: "NailClipping")).size())
s.name = "projectile"
s.position = playerSprite.position
s.zPosition = CGFloat(-1)
let offset = touchLocation - s.position
addChild(s)
let direction = offset.normalized()
let shootAmount = direction * 2300
let realDest = shootAmount + s.position
s.rotateToDirection(dest: realDest)
let actionMove = SKAction.move(to: realDest, duration: 0.5)
let actionMoveDone = SKAction.removeFromParent()
s.run(SKAction.sequence([actionMove, actionMoveDone]))
self.levelScore -= 1

run(SKAction.playSoundFileNamed("nailClip.mp3", waitForCompletion: true))
playNailClip()
}
}
}

func setPauseState(gamePaused: Bool){
spritesMoving = !gamePaused
playerSprite.canMove = !gamePaused
enumerateChildNodes(withName: "projectile", using:{
node, stop in
let d = node as! ProjectileSprite
d.isPaused = gamePaused
})

if(gamePaused == true){
if(playerSprite.position.y > playableRect.maxY - 500)
{
pauseLabel.position.x = playableRect.maxX / 2
pauseLabel.position.y = playerSprite.position.y - 225
}
else{
pauseLabel.position.x = playableRect.maxX / 2
pauseLabel.position.y = playerSprite.position.y + 225
}
pauseLabel.fontColor = SKColor.lightGray
screenBlocker.fillColor = SKColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.6)
}
else{
shootLabel.isHidden = true
pauseLabel.text = "Move Diamond to Resume"
screenBlocker.fillColor = SKColor.clear
pauseLabel.fontColor = SKColor.clear
}
}

// MARK: - Lifecycle -
override func didMove(to view: SKView){
setupUI()
Expand Down Expand Up @@ -227,17 +318,22 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
s.update(dt: dt)
})

var count:Int = 0
enumerateChildNodes(withName: "obstacle", using:{
var offTopCount:Int = 0
enumerateChildNodes(withName: "obstacle", using: {
node, stop in
count += 1
let o = node as! RectangleSprite
o.update(dt: dt)
if o.position.y > self.size.height - self.endlessChunkOffset
{
offTopCount += 1
}
if o.elementID == "F"{
self.finishHasSpawned = true
}
})

//If there are no more obstacles, generate new ones (for endless mode)
if(count <= 0){
var level:[RectangleSprite] = levelManager.randomChunk()
if offTopCount <= 0 && !finishHasSpawned{
var level:[RectangleSprite] = self.levelManager.randomChunk()
for i in 0 ..< level.count{
addChild(level[i])
}
Expand All @@ -256,69 +352,9 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate

// MARK: - Events -
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if(playerSprite.canMove)
{
}
}

// MARK: - Actions -
func panDetected(_ sender:UIPanGestureRecognizer) {
//Handle gesture recognition
sender.maximumNumberOfTouches = 1; // programming
if sender.state == .began{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
let touchedNodes = self.nodes(at: touchLocation)
for sprite in touchedNodes{
if let name = sprite.name{
if name == "player"
{
playerSprite.changeColor(strokeColor: SKColor.clear, fillColor: SKColor.clear)
setPauseState(gamePaused: false)
}
}
}
}
if(sender.state == .changed){
if(playerSprite.canMove)
{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
playerSprite.position = touchLocation

}
}
if(sender.state == .ended){
playerSprite.changeColor(strokeColor: SKColor.white, fillColor: SKColor.lightGray)
setPauseState(gamePaused: true)
}
}

//handle tapping
func tapDetected(_ sender:UITapGestureRecognizer){
if spritesMoving == true{
if sender.state == .ended{
var touchLocation = sender.location(in: sender.view)
touchLocation = self.convertPoint(fromView: touchLocation)
let s = ProjectileSprite(size: SKTexture(image: #imageLiteral(resourceName: "NailClipping")).size())
s.name = "projectile"
s.position = playerSprite.position
s.zPosition = CGFloat(-1)
let offset = touchLocation - s.position
addChild(s)
let direction = offset.normalized()
let shootAmount = direction * 2300
let realDest = shootAmount + s.position
s.rotateToDirection(dest: realDest)
let actionMove = SKAction.move(to: realDest, duration: 0.5)
let actionMoveDone = SKAction.removeFromParent()
s.run(SKAction.sequence([actionMove, actionMoveDone]))
self.levelScore -= 1

playNailClip()
}
}
}

func gestureRecognizer(_ gestureRecognizer:UIGestureRecognizer, shouldRecognizeSimultaneouslyWith: UIGestureRecognizer) -> Bool{
return (gestureRecognizer == tap && shouldRecognizeSimultaneouslyWith == pan)
Expand Down Expand Up @@ -417,41 +453,10 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
obstacleSpawnTimer = obstacleSpawnTimer - dt
if(obstacleSpawnTimer <= 0)
{
levelScore += 100;
levelScore += 100
obstacleSpawnTimer = obstacleInterval
}
}
}
}

//pause or unpause
func setPauseState(gamePaused: Bool){
spritesMoving = !gamePaused
playerSprite.canMove = !gamePaused
enumerateChildNodes(withName: "projectile", using:{
node, stop in
let d = node as! ProjectileSprite
d.isPaused = gamePaused
})

if(gamePaused == true){
if(playerSprite.position.y > playableRect.maxY - 500)
{
pauseLabel.position.x = playableRect.maxX / 2
pauseLabel.position.y = playerSprite.position.y - 225
}
else{
pauseLabel.position.x = playableRect.maxX / 2
pauseLabel.position.y = playerSprite.position.y + 225
}
pauseLabel.fontColor = SKColor.lightGray
screenBlocker.fillColor = SKColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.6)
}
else{
shootLabel.isHidden = true
pauseLabel.text = "Move Diamond to Resume"
screenBlocker.fillColor = SKColor.clear
pauseLabel.fontColor = SKColor.clear
}
}
}
1 change: 1 addition & 0 deletions FingersRevenge/FingersRevenge/LevelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class LevelManager{
{
let tempRect = RectangleSprite(size: CGSize(width: unitSize, height: unitSize), fillColor: fill, strokeColor: stroke)
tempRect.name = name
tempRect.elementID = elementID
let x = (xValue * unitSize) + (unitSize / 2)
let y = startHeight + (yValue * unitSize)
tempRect.position = CGPoint(x: CGFloat(x), y: CGFloat(y))
Expand Down
3 changes: 2 additions & 1 deletion FingersRevenge/FingersRevenge/RectangleSprite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class RectangleSprite : SKShapeNode{
let size:CGSize
var isButton:Bool = false
var gates:[RectangleSprite] = [RectangleSprite]()
var elementID:String = "O"

let colorArrayIndex = 2;//which color to draw

Expand Down Expand Up @@ -45,7 +46,7 @@ class RectangleSprite : SKShapeNode{
{
velocity = fwd * delta
position = position + velocity * dt
if(position.y < -size.height/2){
if(position.y < -size.height){
self.removeFromParent()
}

Expand Down

0 comments on commit 5015e60

Please sign in to comment.