I have been trying to make an easy incremental game, just to learn, and i couldnt figure out how to use timer to give the user "coins" every second. This question might have been asked a lot but all the solutions tutorials etc i read were too hard/outdated/not valid for my case.
edit: current code
import Foundation
import Darwin
//vars
var copperCoins = 0
var copperGrowth = 1
//intro
print("Simple incremental game!")
print("Copper coins: \(copperCoins)")
//while runs
while true
{
let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
copperCoins += copperGrowth
}
}