Block Breaker, so far

More interested in the coding aspect, than creating assets for this particular project, I used the provided assets, but I downloaded an image for the title screen. I also worked out a level selector, to choose which level you play next…

I am posting the sceneLoader code I used for the Start, Level Selector, and Quit fuctions… I dont think my level selection method is very efficient, and If I had more levels, I believe it would be very cumbersome. I believe the answer would be to use an Index of the scenes, but I am not sure if that is correct, or how to implement the math to select a higher range of numbers for say 10 levels.

public class SceneLoader : MonoBehaviour
{
public void LoadLevelSelect()
{
SceneManager.LoadScene(“2. Level Select”);
}

public void LoadStartingScene()
{
    SceneManager.LoadScene(0);
}
public void LoadLevel1()
{
    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(currentSceneIndex + 1);
}
public void LoadLevel2()
{
    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(currentSceneIndex + 2);
}

public void QuitGame()
{
    Application.Quit();
}

}

1 Like

Privacy & Terms