Skip to content

Commit

Permalink
Fix grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa Mae committed Mar 22, 2024
1 parent d7bbbde commit 4958490
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Binary file not shown.
11 changes: 4 additions & 7 deletions TowerForge/TowerForge/Grid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ class Grid: UnitSelectionNodeDelegate {
let screenHeight = self.height
let tileSize = CGSize(width: screenHeight / CGFloat(noOfRows), height: screenHeight / CGFloat(noOfRows))

guard let tileSet = SKTileSet(named: "GridTile") else {
fatalError("Cannot find tile set")
}

// Calculate the number of columns needed to cover the screen width
let numberOfColumns = Int(ceil(screenWidth / tileSize.width))

for row in 0..<noOfRows {
for col in 0..<numberOfColumns {
let node = TFSpriteNode(imageName: "Road_Grid", height: tileSize.height, width: tileSize.width)
let node = TFSpriteNode(imageName: "road-tile", height: tileSize.height, width: tileSize.width)
node.anchorPoint = CGPoint(x: 0, y: 0)
node.position = CGPoint(x: CGFloat(CGFloat(row) * tileSize.width),
y: CGFloat(CGFloat(col) * tileSize.width))
node.position = CGPoint(x: CGFloat(CGFloat(col) * tileSize.width),
y: CGFloat(CGFloat(row) * tileSize.height))
node.zPosition = -100
scene.addChild(node)
}
Expand Down

0 comments on commit 4958490

Please sign in to comment.