I'm creating a game as a small project and i'm trying to make it so after ever 5 points the walls will generate more but when playing the game, it crashes at reaching around 24 points with the the error "fatal error: Array index out of range"
GameScene.swift
if pointsLabel.number % kNumberOfPointsPerLevel == 0 {
currentLevel++
wallGenerator.stopGenerating()
wallGenerator.startGeneratingWallsEvery(kLevelGenerationTimes[currentLevel])
}
Constants.swift
let kNumberOfPointsPerLevel = 5
let kLevelGenerationTimes: [NSTimeInterval] = [1.0, 0.8, 0.6, 0.4, 0.3]