ModCS.Game
Functions related to the main game loop. Stored in the ModCS.Game object.
Warning
The main game loop does not include:
- The inventory screen
- The stage select screen
- Minimap screen
- Credits
- Pause screen
Functions such as ModCS.Game.Act() and ModCS.Game.Draw() will not run during these screens.
ModCS.Game.GetMode()
ModCS.Game.GetMode()
Return a number that represents the current game mode.
| Value | Game mode |
|---|---|
| 1 | Opening sequence. |
| 2 | Title screen. |
| 3 | Action. |
ModCS.Game.IsNew()
ModCS.Game.IsNew()
Returns true if the 'New' option in the title screen was selected. Returns false otherwise.
ModCS.Game.Init()
This function is called whenever a game mode is started.
Example
This example will clear a variable foo on every game mode start.
1 2 3 4 | |
ModCS.Game.CanControl()
ModCS.Game.CanControl()
Returns false during a <KEY or <PRI. Returns true otherwise.
ModCS.Game.CanAct()
ModCS.Game.CanAct()
Returns false during a <PRI. Returns true otherwise.
ModCS.Game.GetGameFlags()
ModCS.Game.GetGameFlags()
Returns the current "Game Flags" value. This is the value checked for "CanControl()" and "CanAct()" as well.
ModCS.Game.SetGameFlags()
ModCS.Game.SetGameFlags(num)
Set the current "Game Flags" value to num.
ModCS.Game.Random()
ModCS.Game.Random(min, max)
Returns a random value between min and max using the games Random function.
ModCS.Game.Random2()
ModCS.Game.Random2(min, max)
Returns a random value between min and max, using the games random function except multipling the input by 512, then giving the result divided by 512, to account for Pixel Unit positions.
ModCS.Game.Random3()
ModCS.Game.Random3(min, max)
Returns a random value between min and max, using the games random function except multipling the input by 512, then giving the result. To account for scenarios where you need to use Pixel Unit style math but need the full integer value.
ModCS.Game.SetBit()
ModCS.Game.SetBit(value, bit)
Sets a bit on value, with the usage of value = ModCS.Game.SetBit(value, bit).
Example
This example will set the players collision flag to "being in water".
1 | |
ModCS.Game.UnsetBit()
ModCS.Game.UnsetBit(value, bit)
Unsets a bit on value, with the usage of value = ModCS.Game.UnsetBit(value, bit).
Example
This example will unset the players collision flag from "being in water".
1 | |
ModCS.Game.CheckBit()
ModCS.Game.CheckBit(value, bit)
Checks if the value used has the bit set.
Example
This example will check if the players collision flag is "being in water".
1 2 3 | |
ModCS.Game.Act()
This function is called every frame before anything is updated or drawn in the main game loop.
Example
This example will add 1 to a variable foo every frame.
1 2 3 4 | |
ModCS.Game.Update()
This function is called every frame before anything is drawn in the main game loop. It differentiates from ModCS.Game.Act only on when exactly it's ran.
ModCS.Game.Draw()
This function is called every frame after everything is drawn in the main game loop.
Example
This example will draw the value of the variable foo using ModCS.PutNumber.
1 2 3 4 | |
There are also other draw functions for other specific situations. They are listed here:
ModCS.Game.DrawBelowStageBack()
ModCS.Game.DrawAboveStageBack()
ModCS.Game.DrawBelowStageFront()
ModCS.Game.DrawAboveStageFront()
ModCS.Game.DrawBelowPlayer()
ModCS.Game.DrawAbovePlayer()
ModCS.Game.DrawBelowFade()
ModCS.Game.DrawAboveFade()
ModCS.Game.DrawBelowTextBox()
ModCS.Game.DrawAboveTextBox()
ModCS.Game.DrawHUD() -- Only draws when the hud is supposed to be drawn as well