adding a new board

pull/25/head
Johan LACHENAL 10 months ago
parent 373c1416e7
commit e97f476bf6

@ -1,7 +1,7 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "board.png", "filename" : "Group 1-2.png",
"idiom" : "universal", "idiom" : "universal",
"scale" : "1x" "scale" : "1x"
}, },

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

@ -11,6 +11,7 @@ import DouShouQiModel
class GameScene : SKScene { class GameScene : SKScene {
var isGameOver = false
let imageBoard:SKSpriteNode = SKSpriteNode(imageNamed: "board") let imageBoard:SKSpriteNode = SKSpriteNode(imageNamed: "board")
var game:Game = try! Game(withRules: ClassicRules(), andPlayer1: HumanPlayer(withName: "Bot1", andId: .player1)!, andPlayer2: RandomPlayer(withName: "Bot2", andId: .player2)!) var game:Game = try! Game(withRules: ClassicRules(), andPlayer1: HumanPlayer(withName: "Bot1", andId: .player1)!, andPlayer2: RandomPlayer(withName: "Bot2", andId: .player2)!)

@ -67,7 +67,8 @@ struct GameView: View {
default: default:
msg="Game over !" msg="Game over !"
} }
// foreach gameScene.pieces
gameScene.isGameOver = true
actionEndGame(scene: gameScene,message: msg) actionEndGame(scene: gameScene,message: msg)
} }

@ -38,12 +38,12 @@ class SpriteMoople : SKNode {
override var isUserInteractionEnabled: Bool { override var isUserInteractionEnabled: Bool {
get { return true } get { return refGameScene?.isGameOver == false }
set {} set { }
} }
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if isUserInteractionEnabled == false { return }
let movePoss: [ Move ] = refGameScene!.game.rules.getMoves(in: refGameScene!.game.board,of:refGameScene!.game.rules.getNextPlayer(),fromRow: Int(self.cellPosition.x),andColumn: Int(self.cellPosition.y)) let movePoss: [ Move ] = refGameScene!.game.rules.getMoves(in: refGameScene!.game.board,of:refGameScene!.game.rules.getNextPlayer(),fromRow: Int(self.cellPosition.x),andColumn: Int(self.cellPosition.y))
for pos in movePoss { for pos in movePoss {
let rect = SKShapeNode(rectOf: CGSize(width: 90, height: 90)) let rect = SKShapeNode(rectOf: CGSize(width: 90, height: 90))
@ -56,10 +56,12 @@ class SpriteMoople : SKNode {
} }
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
if isUserInteractionEnabled == false { return }
self.position = touches.first?.location(in: parent!) ?? CGPoint(x: 0, y: 0) self.position = touches.first?.location(in: parent!) ?? CGPoint(x: 0, y: 0)
} }
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
if isUserInteractionEnabled == false { return }
let localisation = touches.first?.location(in: parent!) let localisation = touches.first?.location(in: parent!)
// Clean rect // Clean rect

Loading…
Cancel
Save