diff --git a/GoldWars/GoldWars/Game/GameScene.swift b/GoldWars/GoldWars/Game/GameScene.swift index df15181..164f324 100644 --- a/GoldWars/GoldWars/Game/GameScene.swift +++ b/GoldWars/GoldWars/Game/GameScene.swift @@ -14,11 +14,24 @@ class GameScene: SKScene { var entities = [GKEntity]() var graphs = [String : GKGraph]() var bases = [Base]() - + var player = [Base]() + override func sceneDidLoad() { - + + let maxX = self.size.width + let midY = self.size.height / 2 + + let basePlayer1 = Base(color: SKColor.red, position: CGPoint(x: maxX * 0.1, y: midY), name: "Player1" ) + let basePlayer2 = Base(color: SKColor.blue, position: CGPoint(x: maxX * 0.9, y: midY), name: "Player2" ) + + self.addChild(basePlayer1) + self.addChild(basePlayer2) + player.append(basePlayer1) + player.append(basePlayer2) + createVirginBases() + // Spawn bases - for _ in 1...15 { + /*for _ in 1...15 { let color = PlayerColors.colors.randomElement() let xRange = Int(frame.minX + frame.width * 0.07)...Int(frame.maxX - frame.width * 0.07) let yRange = Int(frame.minY + frame.height * 0.07)...Int(frame.maxY - frame.width * 0.07) @@ -34,7 +47,61 @@ class GameScene: SKScene { addChild(base.spriteNode) bases.append(base) } - + */ + } + + func createVirginBases() { + for i in 0...7 { + let base:Base + let color = SKColor.green + + var position = CGPoint(x: 0, y: 0) + switch i { + case 0...2: + let width = self.size.width * 0.25 + + if i == 0 { + position = CGPoint(x: width, y: self.size.height * 0.25) + } + if i == 1 { + position = CGPoint(x: width, y: self.size.height * 0.5) + } + if i == 2{ + position = CGPoint(x: width, y: self.size.height * 0.75) + } + + case 3...4: + let width = self.size.width * 0.5 + + if i == 3{ + position = CGPoint(x: width, y: self.size.height * 0.333) + } + if i == 4{ + position = CGPoint(x: width, y: self.size.height * 0.666) + } + + case 5...7: + let width = self.size.width * 0.75 + + if i == 5{ + position = CGPoint(x: width, y: self.size.height * 0.25) + } + if i == 6{ + position = CGPoint(x: width, y: self.size.height * 0.5) + } + if i == 7{ + position = CGPoint(x: width, y: self.size.height * 0.75) + } + + default: + break + } + + base = Base(color: color, position: position, name: "Base\(i)") + print(base.position) + bases.append(base) + self.addChild(base) + } } func touchDown(atPoint pos : CGPoint) {