From 7f804f6c62206bdb511e5a7d7828f816d1fe2388 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 31 May 2024 11:44:55 +0200 Subject: [PATCH] :sparkles: Update: GameScene for width and height assets --- .../Components/Scene/GameScene.swift | 62 ++++++++++++------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/DouShouQi_App/DouShouQi_App/Components/Scene/GameScene.swift b/DouShouQi_App/DouShouQi_App/Components/Scene/GameScene.swift index 1fce3ad..91954e4 100644 --- a/DouShouQi_App/DouShouQi_App/Components/Scene/GameScene.swift +++ b/DouShouQi_App/DouShouQi_App/Components/Scene/GameScene.swift @@ -20,7 +20,7 @@ class GameScene : SKScene { .wolf: SpriteMeeple(imageNamed: AppImages.Wolf, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), .leopard: SpriteMeeple(imageNamed: AppImages.Leopard, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), .lion: SpriteMeeple(imageNamed: AppImages.Lion, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), - .tiger: SpriteMeeple(imageNamed: "", size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), + .tiger: SpriteMeeple(imageNamed: AppImages.Tigger, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), .elephant: SpriteMeeple(imageNamed: AppImages.Elephant, size: CGSize(width: 100, height: 100), backgroundColor: Colors.MeepleP1!), ], .player2: [ @@ -30,7 +30,7 @@ class GameScene : SKScene { .wolf: SpriteMeeple(imageNamed: AppImages.Wolf, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), .leopard: SpriteMeeple(imageNamed: AppImages.Leopard, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), .lion: SpriteMeeple(imageNamed: AppImages.Lion, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), - .tiger: SpriteMeeple(imageNamed: "", size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), + .tiger: SpriteMeeple(imageNamed: AppImages.Tigger, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), .elephant: SpriteMeeple(imageNamed: AppImages.Elephant, size: CGSize(width: 100, height: 100), backgroundColor: .blue, imageRotation: 180), ], ] @@ -51,32 +51,46 @@ class GameScene : SKScene { } initializeBoard(game.board) - displayBoard(game.board) + //displayBoard(game.board) } func initializeBoard(_ board: Board) { - let player1Animals: [Animal] = [.rat, .cat, .dog, .wolf, .leopard, .lion, .tiger, .elephant] - let player2Animals: [Animal] = [.rat, .cat, .dog, .wolf, .leopard, .lion, .tiger, .elephant] - - for (index, animal) in player1Animals.enumerated() { - pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 0) - pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1) - } - - for (index, animal) in player2Animals.enumerated() { - pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: board.nbRows - 1) - pieces[.player2]?[animal]?.cellPosition = CGPoint(x: index, y: board.nbRows - 2) - } + let player1AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat] + let player1AnimalsLigne2: [Animal] = [.cat, .dog] + let player1AnimalsLigne3: [Animal] = [.leopard, .lion] + + let player2AnimalsLigne1: [Animal] = [.elephant, .wolf, .tiger, .rat] + let player2AnimalsLigne2: [Animal] = [.cat, .dog] + let player2AnimalsLigne3: [Animal] = [.leopard, .lion] + + for (index, animal) in player1AnimalsLigne1.enumerated() { + pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index-3, y: -2) + pieces[.player1]?[animal]?.cellPosition = CGPoint(x: index, y: 1) } - - - func displayBoard(_ board: Board) { - for row in 0..