Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinWilloughby committed Oct 18, 2016
1 parent afe7b50 commit 76dd3ca
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 13 deletions.
3 changes: 0 additions & 3 deletions AssetBackup/Sources.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ Echipian Swagger by RoccoW\
{\field{\*\fldinst{HYPERLINK "http://freemusicarchive.org/genre/Chiptune/?sort=track_date_published&d=1&page=1"}}{\fldrslt http://freemusicarchive.org/genre/Chiptune/?sort=track_date_published&d=1&page=1}}\
\
Sound effects:\
Generated with bfxr (usable commercially for free)\
{\field{\*\fldinst{HYPERLINK "http://www.bfxr.net/"}}{\fldrslt http://www.bfxr.net/}}\
\
Nail clip noise: \
{\field{\*\fldinst{HYPERLINK "https://www.youtube.com/watch?v=ESrqwV1VBeM"}}{\fldrslt https://www.youtube.com/watch?v=ESrqwV1VBeM}}}
2 changes: 2 additions & 0 deletions FingersRevenge/FingersRevenge/AudioManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AVFoundation
var backgroundMusicPlayer = AVAudioPlayer()
var arrayOfPlayers: [AVAudioPlayer] = [AVAudioPlayer]()

//Play background audio
func playBackgroundMusic(filename: String){
let url = Bundle.main.url(forResource: filename, withExtension: nil)
guard let newURL = url else{
Expand All @@ -31,6 +32,7 @@ func playBackgroundMusic(filename: String){
}
}

//Play nail clip audio
func playNailClip(){
let fx = Bundle.main.url(forResource: "nailClip.mp3", withExtension: nil)

Expand Down
Binary file modified FingersRevenge/FingersRevenge/GameScene.sks
Binary file not shown.
10 changes: 9 additions & 1 deletion FingersRevenge/FingersRevenge/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
// MARK: - Lifecycle -
override func didMove(to view: SKView){
setupUI()
//makeSprites(howMany: 1)

//Set up everything on the screen
tap = UITapGestureRecognizer(target: self, action: #selector(tapDetected))
tap.delegate = self

Expand Down Expand Up @@ -190,6 +190,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
scoreLabel.zPosition = 2
addChild(scoreLabel)

//If the game is stil progressing, load the right level. Otherwise start the first chunk of endless
if(GameData.level >= 4){
//Endless start
var level:[RectangleSprite] = levelManager.randomChunk()
Expand All @@ -206,6 +207,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate

}

//Calculate time since last cycle
func calculateDeltaTime(currentTime: TimeInterval){
if lastUpdateTime > 0 {
dt = currentTime - lastUpdateTime
Expand All @@ -216,6 +218,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
lastUpdateTime = currentTime
}

//Move all of the sprites
func moveSprites(dt:CGFloat){
if spritesMoving{
enumerateChildNodes(withName: "projectile", using: {
Expand All @@ -232,6 +235,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
o.update(dt: dt)
})

//If there are no more obstacles, generate new ones (for endless mode)
if(count <= 0){
var level:[RectangleSprite] = levelManager.randomChunk()
for i in 0 ..< level.count{
Expand All @@ -241,6 +245,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
}
}

//Unpause actions
func unpauseSprites (){
let unpauseAction = SKAction.sequence([
SKAction.wait(forDuration: 0.5),
Expand All @@ -258,6 +263,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate

// MARK: - Actions -
func panDetected(_ sender:UIPanGestureRecognizer) {
//Handle gesture recognition
sender.maximumNumberOfTouches = 1; // programming
if sender.state == .began{
var touchLocation = sender.location(in: sender.view)
Expand Down Expand Up @@ -288,6 +294,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
}
}

//handle tapping
func tapDetected(_ sender:UITapGestureRecognizer){
if spritesMoving == true{
if sender.state == .ended{
Expand Down Expand Up @@ -417,6 +424,7 @@ class GameScene: SKScene, UIGestureRecognizerDelegate, SKPhysicsContactDelegate
}
}

//pause or unpause
func setPauseState(gamePaused: Bool){
spritesMoving = !gamePaused
playerSprite.canMove = !gamePaused
Expand Down
1 change: 1 addition & 0 deletions FingersRevenge/FingersRevenge/HomeScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class HomeScene: SKScene {
fatalError("init(coder:) has not been inplemented")
}

//Set up scene
override func didMove(to view: SKView) {
backgroundColor = GameData.scene.backgroundColor
let fingerLogo = SKSpriteNode(texture: SKTexture(image: #imageLiteral(resourceName: "fingersLogo")))
Expand Down
1 change: 1 addition & 0 deletions FingersRevenge/FingersRevenge/LevelChunks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2016 Austin Willoughby / Peter Lockhart. All rights reserved.
//

//This stores all of the level "maps" for quick use and access
import Foundation

struct LevelChunks{
Expand Down
1 change: 1 addition & 0 deletions FingersRevenge/FingersRevenge/LevelFinishScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LevelFinishScene: SKScene {
fatalError("init(coder:) has not been implemented")
}

//Set up scene
override func didMove(to view: SKView){
backgroundColor = GameData.scene.backgroundColor

Expand Down
9 changes: 8 additions & 1 deletion FingersRevenge/FingersRevenge/LevelManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LevelManager{
}


//Load an array of rectanglesprites from a map identifier
func loadMap(map:String)->[RectangleSprite]{
var chunkMap:[String] = map.characters.split{$0 == ","}.map(String.init)

Expand All @@ -45,6 +46,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){
var currentLine = map[0]
let xSize: Int = tilesAcross
Expand Down Expand Up @@ -101,7 +103,7 @@ class LevelManager{
}



//Handle generating the rectangle information
func generateRectDetails(fill: SKColor, stroke: SKColor, name: String, xValue: Int, yValue: Int, startHeight: Int, elementID: String) -> RectangleSprite
{
let tempRect = RectangleSprite(size: CGSize(width: unitSize, height: unitSize), fillColor: fill, strokeColor: stroke)
Expand Down Expand Up @@ -182,10 +184,12 @@ class LevelManager{
return SKColor(hue: 0, saturation: 0, brightness: l, alpha: 1)
}

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

//Get the chunk at a given index
func getChunkAtIndex(chunk: String) -> [String]{
var levelChunk: [String]
switch(chunk){
Expand Down Expand Up @@ -247,6 +251,7 @@ class LevelManager{
return levelChunk
}

//Get the level at index
func getLevelAtIndex(index: Int) -> String{
switch index{
case 1:
Expand All @@ -258,11 +263,13 @@ class LevelManager{
}
}

//Generate random number
func randRange (lower: UInt32 , upper: UInt32) -> UInt32 {
return lower + arc4random_uniform(upper - lower + 1)
}
}

//Maps
struct LevelMaps{
static let one :String = "1,1,2,2,3,4,5,5"
static let two :String = "6,7,8,9,10,10,11,11,12,13,12,13"
Expand Down
8 changes: 0 additions & 8 deletions FingersRevenge/FingersRevenge/RectangleSprite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ class RectangleSprite : SKShapeNode{
path = pathToDraw
self.fillColor = fillColor
self.strokeColor = strokeColor

//adding physics body
// self.physicsBody = SKPhysicsBody(rectangleOf: size)
// self.physicsBody?.isDynamic = true
// self.physicsBody?.affectedByGravity = false
// self.physicsBody?.categoryBitMask = CollisionMask.wall
// self.physicsBody?.contactTestBitMask = CollisionMask.projectile
// self.physicsBody?.collisionBitMask = CollisionMask.wall
}

required init?(coder aDecoder: NSCoder){
Expand Down

0 comments on commit 76dd3ca

Please sign in to comment.