This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted | |
class GameScene: SKScene { | |
// omitted | |
var enemies = [SKSpriteNode]() | |
override func update(delta: CFTimeInterval) { | |
// loop all enemies and make then walk to collide with the player | |
for enemy in enemies { | |
enemy.position = CGPoint(x: Double(enemy.position.x) - 5, y: Double(enemy.position.y)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted | |
class GameScene: SKScene { | |
// omitted | |
// timers | |
var lastTime = 0 | |
var currentTime = 0 | |
override func update(delta: CFTimeInterval) { | |
// loop all enemies and make then walk to collide with the plyer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted | |
class GameScene: SKScene, SKPhysicsContactDelegate { | |
// omitted | |
override func didMoveToView(view: SKView) { | |
// tell the physics world that the class the implements | |
// the SKPhysicsContactDelegate is the GameScene | |
physicsWorld.contactDelegate = self | |
setupFloor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted | |
class GameScene: SKScene, SKPhysicsContactDelegate { | |
// omitted | |
func didBeginContact(contact: SKPhysicsContact) { | |
if (contact.bodyA.node!.name == "player" && contact.bodyB.node!.name == "enemy") { | |
gameOver() | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SpriteKit | |
class GameOverScene: SKScene { | |
override init(size: CGSize) { | |
super.init(size: size) | |
// change the background of the scene to be black | |
backgroundColor = SKColor.blackColor() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// omitted | |
class GameScene: SKScene, SKPhysicsContactDelegate { | |
// omitted | |
func gameOver() { | |
player.removeFromParent() | |
for enemy in enemies { | |
enemy.removeFromParent() | |
} | |
// transition effect that seems like doors opening | |
let reveal = SKTransition.doorsOpenHorizontalWithDuration(0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyChain | |
def initialize(door) | |
@door = door | |
end | |
def get | |
if door == :bedroom | |
generate_bedroom_key | |
elsif door == :front_door | |
generate_front_door_key |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KeyChain | |
def initialize(door) | |
@door = door | |
end | |
def get | |
send(door) | |
end | |
private |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BedroomKeyGenerator | |
def self.generate | |
"algorithm of bedroom key" * 3 | |
end | |
end | |
class FrontDoorKeyGenerator | |
def self.generate | |
"algorithm of front_door key" * 3 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
root 'blog#index' | |
end |