Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	FingersRevenge/FingersRevenge/GameScene.swift
  • Loading branch information
pxl1778 committed Dec 7, 2016
2 parents 7a53f2c + 641994c commit 9feb7d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Binary file not shown.
11 changes: 7 additions & 4 deletions FingersRevenge/FingersRevenge/GameScene.swift
Expand Up @@ -50,6 +50,8 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
private var shaderTitles = [String]()
var shaderIndex:Int = 0

var chunkCount:Int = 0
var maxChunks:Int = 20

var healthBar:SKSpriteNode = SKSpriteNode(texture: SKTexture(image: #imageLiteral(resourceName: "ThreeHealth")))

Expand Down Expand Up @@ -151,7 +153,6 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
s.run(SKAction.sequence([actionMove, actionMoveDone]))
self.levelScore -= 1

run(SKAction.playSoundFileNamed("nailClip.mp3", waitForCompletion: true))
playNailClip()
}
}
Expand Down Expand Up @@ -296,9 +297,10 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
addChild(scoreLabel)

//If the game is stil progressing, load the right level. Otherwise start the first chunk of endless
if(GameData.level >= 4){
if(GameData.level >= 0){
//Endless start
var level:[RectangleSprite] = levelManager.randomChunk()
chunkCount += 1
var level:[RectangleSprite] = levelManager.randomChunk(currentChunk: chunkCount, endChunk: maxChunks)
for i in 0 ..< level.count{
addChild(level[i])
}
Expand Down Expand Up @@ -347,7 +349,8 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
})

if offTopCount <= 0 && !finishHasSpawned{
var level:[RectangleSprite] = self.levelManager.randomChunk()
chunkCount += 1
var level:[RectangleSprite] = levelManager.randomChunk(currentChunk: chunkCount, endChunk: maxChunks)
for i in 0 ..< level.count{
addChild(level[i])
}
Expand Down
9 changes: 6 additions & 3 deletions FingersRevenge/FingersRevenge/LevelManager.swift
Expand Up @@ -47,7 +47,7 @@ class LevelManager{


//Load a chunk from a map string[], give starting height to know where it is in the world
private func loadChunk(map:[String], startingHeight: Int)->(newChunk: [RectangleSprite], height: Int){
func loadChunk(map:[String], startingHeight: Int)->(newChunk: [RectangleSprite], height: Int){
var currentLine = map[0]
let xSize: Int = tilesAcross
let ySize: Int = map.count
Expand Down Expand Up @@ -186,8 +186,11 @@ class LevelManager{
}

//Get a random chunk back
func randomChunk() -> [RectangleSprite]{
return loadChunk(map: getChunkAtIndex(chunk: String(randRange(lower: 1, upper: 20))),startingHeight: 1920).0
func randomChunk(currentChunk: Int, endChunk: Int) -> [RectangleSprite]{
if(currentChunk > endChunk){
return loadChunk(map: LevelChunks.end, startingHeight: 1920).0
}
return loadChunk(map: getChunkAtIndex(chunk: String(randRange(lower: 1, upper: 17))),startingHeight: 1920).0
}

//Get the chunk at a given index
Expand Down

0 comments on commit 9feb7d5

Please sign in to comment.