Skip to content

Programming Reference

Jeremy Glazebrook edited this page Oct 26, 2023 · 2 revisions

Programming Reference Materials In this article you can learn about the game actually works.

Level Generation

Learn all about how to make a level in Collapse!

Level Generation Rulesets

internal struct Collapse.Provider.GenerationRuleset

image

Generation rulesets expose the following values to tweak the gameplay experience:

  1. Jellyfish, Anchors, and **Bubbles **Enabled
  2. How many rows there are on the board to start off
  3. Green, Blue, Yellow, and Purple blocks being enabled/disabled for spawning in
  4. Green, Blue, Yellow, and Purple bubbles being enabled/disabled for spawning in
  5. How fast new blocks spawn in (Each tick is this much time elapsed from the last)
  6. How many lines are needed to spawn in to complete the board.

Using the BoardProvider

internal class BoardProvider : IProvider See: BoardProvider.cs

GlacierEngine exposes Providers which will handle aspects of the game's mechanics so it can remain organized. It is highly recommended to use the BoardProvider as opposed to directly accessing the LevelGenerator; however, it is at your discretion.

Adding Levels to the BoardProvider

image

You can define your own GenerationRuleset per level by editing the rulesets Dictionary in the BoardProvider


public GameBoard Generate(int Level) in: BoardProvider.cs

This will use the rulesets Dictionary to load the level by the defined GenerationRuleset for the provided Level number.

Invoking the LevelGenerator Directly

internal bool GenerateNew(GenerationRuleset ruleset, out GameBoard board) See: LevelGeneration.cs

Attempts to generate a new GameBoard using the given GenerationRuleset data.

Using New Levels

internal class GameplayScreen : GameObject See: GameplayScreen

image

The GameplayScreen hosts the Gameplay for Collapse.

As you can see above, the StartGame function will clean-up the previous session and load the new level. If your levels require custom logic to be loaded, you should do so in this function.

Since GameBoard inherits GameObject it can be added to the GlacierEngine object graph using the GameObjectManager referenced in the above example.