Class Game
Represent an AngeliA game
Constructors
Game(params string[])
Create a game instance with command-line arguments
Declaration
public Game(params string[] args)
Fields
Fonts
Instance pool for all available font
Declaration
public static readonly List<FontData> Fonts
MusicPool
Instance pool for all available background music
Declaration
public static readonly Dictionary<int, MusicData> MusicPool
SoundPool
Instance pool for all available sound effect
Declaration
public static readonly Dictionary<int, SoundData> SoundPool
Properties
BuiltInFontCount
Declaration
public static int BuiltInFontCount { get; }
CurrentBGM
Instance that represent the background music
Declaration
public static object CurrentBGM { get; protected set; }
CurrentMonitor
Get index of the monitor which this application window currently in
Declaration
public static int CurrentMonitor { get; }
CurrentMusicID
Audio ID of the current loaded background music
Declaration
public static int CurrentMusicID { get; }
CursorInScreen
True if the mouse cursor is currently inside application window
Declaration
public static bool CursorInScreen { get; }
CursorVisible
True if the mouse cursor is currently visible
Declaration
public static bool CursorVisible { get; }
DoodleFrame
Doodle pixels should be rendered of the global frame is less or equal to (this value + 1)
Declaration
protected int DoodleFrame { get; }
DoodleOnTopOfUiFrame
Doodle pixels should cover the UI rendering layer if current global frame less than this value
Declaration
protected int DoodleOnTopOfUiFrame { get; }
DoodleScreenPadding
Border size in screen space for the doodle canvas
Declaration
public static Int4 DoodleScreenPadding { get; set; }
FontCount
Total count of loaded fonts
Declaration
public static int FontCount { get; }
GamepadLeftStickDirection
Get the specific direction of the left gamepad stick
Declaration
public static Float2 GamepadLeftStickDirection { get; }
GamepadRightStickDirection
Get the specific direction of the right gamepad stick
Declaration
public static Float2 GamepadRightStickDirection { get; }
GizmosOnTopOfUiFrame
Gizmos should cover the UI rendering layer if current global frame less than this value
Declaration
protected int GizmosOnTopOfUiFrame { get; }
GlobalFrame
Frame number that grows every 1/60 second
Declaration
public static int GlobalFrame { get; }
IgnoreArtworkPixels
True if the application don't need pixel data from artwork sheet
Declaration
public static bool IgnoreArtworkPixels { get; }
IsGamepadAvailable
True if any gamepad device is currently available to use
Declaration
public static bool IsGamepadAvailable { get; }
IsKeyboardAvailable
True is the keyboard device is currently available to use
Declaration
public static bool IsKeyboardAvailable { get; }
IsMouseAvailable
True if the mouse device is currently available to use
Declaration
public static bool IsMouseAvailable { get; }
IsMouseLeftHolding
True if the mouse left button is currently holding
Declaration
public static bool IsMouseLeftHolding { get; }
IsMouseMidHolding
True if the mouse middle button is currently holding
Declaration
public static bool IsMouseMidHolding { get; }
IsMouseRightHolding
True if the mouse right button is currently holding
Declaration
public static bool IsMouseRightHolding { get; }
IsMusicPlaying
True if the background music is currently playing
Declaration
public static bool IsMusicPlaying { get; }
IsPausing
True if the game is currently pausing
Declaration
public static bool IsPausing { get; }
IsPlaying
True if the game is currently not pausing
Declaration
public static bool IsPlaying { get; }
IsToolApplication
True if the application should be treated as tool instead of game
Declaration
public static bool IsToolApplication { get; }
IsWindowDecorated
If the application window has title bar and border frame or not
Declaration
public static bool IsWindowDecorated { get; set; }
IsWindowFocused
True if the application window is currently focused
Declaration
public static bool IsWindowFocused { get; }
IsWindowMaximized
If the application window is currently maximized
Declaration
public static bool IsWindowMaximized { get; set; }
IsWindowMinimized
If the application window is currently minimized
Declaration
public static bool IsWindowMinimized { get; set; }
IsWindowResizable
If the application window can be resize by the user
Declaration
public static bool IsWindowResizable { get; set; }
IsWindowTopmost
If the application window renders on top of all other windows
Declaration
public static bool IsWindowTopmost { get; set; }
MonitorHeight
Height of the monitor which the application currently inside
Declaration
public static int MonitorHeight { get; }
MonitorWidth
Width of the monitor which the application currently inside
Declaration
public static int MonitorWidth { get; }
MouseScreenPosition
Mouse position in screen space. (0,0) means top-left corner
Declaration
public static Int2 MouseScreenPosition { get; }
MouseScrollDelta
Mouse wheel scrolling value at current frame. Return negative value when the page scrolls down (the content appears to move upward)
Declaration
public static int MouseScrollDelta { get; }
MusicVolume
Volume amount for the background music (0 for mute, 1000 for loudest)
Declaration
public static int MusicVolume { get; set; }
PauselessFrame
Frame number that still grows when the game is pausing
Declaration
public static int PauselessFrame { get; }
ProcedureAudioVolume
Audio volume used by internal script
Declaration
public static int ProcedureAudioVolume { get; set; }
ScaledMusicVolume
Music volume that effect by the internal procedure audio volume
Declaration
public static float ScaledMusicVolume { get; }
ScaledSoundVolume
Sound volume that effect by the internal procedure audio volume
Declaration
public static float ScaledSoundVolume { get; }
ScreenEffectPadding
Border size of all screen effects
Declaration
public static Int4 ScreenEffectPadding { get; set; }
ScreenHeight
Height of the application window
Declaration
public static int ScreenHeight { get; }
ScreenWidth
Width of the application window
Declaration
public static int ScreenWidth { get; }
SettleFrame
Frame number that could be reset by the stage
Declaration
public static int SettleFrame { get; }
ShowingDoodle
True if the doodle pixels are displaying at this frame
Declaration
public static bool ShowingDoodle { get; }
SoundVolume
Volume amount for the sound effect (0 for mute, 1000 for loudest)
Declaration
public static int SoundVolume { get; set; }
Methods
CancelDoodleOnTopOfUI()
Do not make doodle pixels cover UI rendering layer anymore.
Declaration
public static void CancelDoodleOnTopOfUI()
CancelForceTargetFramerate()
Do not override the target framerate anymore
Declaration
public static void CancelForceTargetFramerate()
CancelGizmosOnTopOfUI()
Do not make gizmos cover UI rendering layer anymore.
Declaration
public static void CancelGizmosOnTopOfUI()
CenterCursor()
Move the mouse cursor to the center of screen. This works when mouse cursor is hidding.
Declaration
public static void CenterCursor()
ClearAndUnloadAudioPool()
Reset audio pool and unload the data in the memory
Declaration
public static void ClearAndUnloadAudioPool()
CreateNewFontData()
Create a new instance of the internal data for font
Declaration
protected abstract FontData CreateNewFontData()
DoodleRect(FRect, Color32)
Doodle the given color as pixels into the screen-space canvas. Pixels remains on screen until you hide all doodle or reset the canvas.
Declaration
public static void DoodleRect(FRect screenRect, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
FRect | screenRect | Rect position in screen space |
DoodleRectSwap(FRect, Color32)
Doodle the given color as pixels into the screen-space canvas. Pixels remains on screen until you hide all doodle or reset the canvas.
Declaration
public static void DoodleRectSwap(FRect screenRect, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
FRect | screenRect | Rect position in screen space that swap around when out of range |
DoodleWorld(IBlockSquad, FRect, IRect, int, bool, bool, bool, bool)
Doodle the given map data on screen based on summary tint from rendering sheet
Declaration
public static void DoodleWorld(IBlockSquad squad, FRect screenRect, IRect worldUnitRange, int z, bool ignoreLevel = false, bool ignoreBG = false, bool ignoreEntity = false, bool ignoreElement = true)
Parameters
Type | Name | Description |
---|---|---|
IBlockSquad | squad | Source of the map block data |
FRect | screenRect | Position rect in screen space for the given world-unit-range |
IRect | worldUnitRange | Rect range on the map in unit space |
int | z | Position Z on the map |
bool | ignoreLevel | True if level blocks should be ignored |
bool | ignoreBG | True if background blocks should be ignored |
bool | ignoreEntity | True if entity blocks should be ignored |
bool | ignoreElement | True if element blocks should be ignored |
DrawGizmosFrame(IRect, Color32, Int4, Int4)
Draw a holo rectangle as gizmos for current frame
Declaration
public static void DrawGizmosFrame(IRect rect, Color32 color, Int4 thickness, Int4 gap = default)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | color | Color tint |
Int4 | thickness | Border size in global space |
Int4 | gap | How big the fracture part in the middle in global space |
DrawGizmosFrame(IRect, Color32, int, int)
Draw a holo rectangle as gizmos for current frame
Declaration
public static void DrawGizmosFrame(IRect rect, Color32 color, int thickness, int gap = 0)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | color | Color tint |
int | thickness | Border size in global space |
int | gap | How big the fracture part in the middle in global space |
DrawGizmosLine(int, int, int, int, int, Color32)
Draw a line as gizmos for current frame
Declaration
public static void DrawGizmosLine(int startX, int startY, int endX, int endY, int thickness, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
int | startX | Start point of the line in global space |
int | startY | Start point of the line in global space |
int | endX | End point of the line in global space |
int | endY | End point of the line in global space |
int | thickness | Thickness in global space |
Color32 | color | Color tint |
DrawGizmosRect(IRect, Color32)
Draw a rectangle as gizmos for current frame
Declaration
public static void DrawGizmosRect(IRect rect, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | color | Color tint |
DrawGizmosRect(IRect, Color32, Color32)
Draw a rectangle as gizmos for current frame
Declaration
public static void DrawGizmosRect(IRect rect, Color32 colorT, Color32 colorB)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | colorT | Color tint |
Color32 | colorB | Color tint |
DrawGizmosRect(IRect, Color32, Color32, Color32, Color32)
Draw a rectangle as gizmos for current frame
Declaration
public static void DrawGizmosRect(IRect rect, Color32 colorTL, Color32 colorTR, Color32 colorBL, Color32 colorBR)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | colorTL | Color tint |
Color32 | colorTR | Color tint |
Color32 | colorBL | Color tint |
Color32 | colorBR | Color tint |
DrawGizmosTexture(IRect, FRect, object, Color32, bool, bool, bool)
Draw the given texture as gizmos for current frame
Declaration
public static void DrawGizmosTexture(IRect rect, FRect uv, object texture, Color32 tint, bool inverse = false, bool flipX = false, bool flipY = false)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position |
FRect | uv | Which part of this texture should be draw. (0, 0, 1, 1) means all of them. (0, 0, 0.5f, 1) means left half. |
Color32 | tint | Color tint |
bool | inverse | True if the texture display as the inversed color of the current rendered pixel on screen. |
DrawGizmosTexture(IRect, FRect, object, bool, bool, bool)
Draw the given texture as gizmos for current frame
Declaration
public static void DrawGizmosTexture(IRect rect, FRect uv, object texture, bool inverse = false, bool flipX = false, bool flipY = false)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position |
FRect | uv | Which part of this texture should be draw. (0, 0, 1, 1) means all of them. (0, 0, 0.5f, 1) means left half. |
bool | inverse | True if the texture display as the inversed color of the current rendered pixel on screen. |
DrawGizmosTexture(IRect, object, Color32, bool, bool, bool)
Draw the given texture as gizmos for current frame
Declaration
public static void DrawGizmosTexture(IRect rect, object texture, Color32 tint, bool inverse = false, bool flipX = false, bool flipY = false)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position |
Color32 | tint | Color tint |
bool | inverse | True if the texture display as the inversed color of the current rendered pixel on screen. |
DrawGizmosTexture(IRect, object, bool, bool, bool)
Draw the given texture as gizmos for current frame
Declaration
public static void DrawGizmosTexture(IRect rect, object texture, bool inverse = false, bool flipX = false, bool flipY = false)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position |
bool | inverse | True if the texture display as the inversed color of the current rendered pixel on screen. |
FillPixelsIntoTexture(Color32[], object)
Set the given pixel data into the given texture instance.
Declaration
public static void FillPixelsIntoTexture(Color32[] pixels, object texture)
FillResizedTexture(object, object, bool)
Copy data from source texture into target texture. Stretch resize the content if two textures have different size.
Declaration
public static void FillResizedTexture(object sourceTexture, object targetTexture, bool nearestNeighbor = true)
True if the misaligned pixels should be averaged with it's nearby pixels
ForAllPressingCharsThisFrame()
Iterate through all pressing character at current frame. Not include non-character keys
Declaration
public static IEnumerable<char> ForAllPressingCharsThisFrame()
ForAllPressingKeysThisFrame()
Iterate through all pressing keyboard keys at current frame. Include non-character keys
Declaration
public static IEnumerable<KeyboardKey> ForAllPressingKeysThisFrame()
ForceDoodleOnTopOfUI(int)
Make doodle pixels cover UI rendering layer for given frames long.
Declaration
public static void ForceDoodleOnTopOfUI(int duration = 0)
ForceGizmosOnTopOfUI(int)
Make gizmos cover UI rendering layer for given frames long.
Declaration
public static void ForceGizmosOnTopOfUI(int duration = 0)
ForceTargetFramerate(int, int)
Override the target framerate for specified frames long
Declaration
public static void ForceTargetFramerate(int framerate, int duration = 1)
GetCameraRectFromViewRect(IRect)
Calculate the camera rect based on given view rect
Declaration
public static IRect GetCameraRectFromViewRect(IRect viewRect)
GetCharPressed()
Get the current pressing charcter and remove it from internal queue. Return '\0' if no character is pressed.
Declaration
protected abstract char GetCharPressed()
GetCharSprite(int, char, out CharSprite)
Get artwork sprite for rendering a text character
Declaration
public static bool GetCharSprite(int fontIndex, char c, out CharSprite result)
Returns
Type | Description |
---|---|
bool | True if the sprite is successfuly required |
GetClipboardText()
Text content of the current system clipboard
Declaration
public static string GetClipboardText()
GetEffectEnable(int)
True if the given screen effect is currently enabled.
Declaration
public static bool GetEffectEnable(int effectIndex)
Parameters
Type | Name | Description |
---|---|---|
int | effectIndex | Use Const.SCREEN_EFFECT_XXXX for this index |
GetKeyPressed()
Get the current pressing keyboard key and remove it from internal queue. Return null if no key is pressed.
Declaration
protected abstract KeyboardKey? GetKeyPressed()
GetMonitorHeight(int)
Get height of the current monitor. Use Game.CurrentMonitor to get the monitor index
Declaration
public static int GetMonitorHeight(int monitor)
GetMonitorWidth(int)
Get width of the current monitor. Use Game.CurrentMonitor to get the monitor index
Declaration
public static int GetMonitorWidth(int monitor)
GetPixelsFromTexture(object)
Create a new instance of Color32 array from the given texture
Declaration
public static Color32[] GetPixelsFromTexture(object texture)
Returns
Type | Description |
---|---|
Color32[] | Return [] when invalid. Don't throw exception. |
GetResizedTexture(object, int, int, bool)
Create a new instance of texture which is the resized version of the given texture.
Declaration
public static object GetResizedTexture(object texture, int newWidth, int newHeight, bool nearestNeighbor = true)
True if the misaligned pixels should be averaged with it's nearby pixels
Returns
Type | Description |
---|---|
object | Return null if invalid. Don't throw exception. |
GetScreenRenderingTexture()
Get the instance of the internal texture that holds the pixel data on screen
Declaration
public static object GetScreenRenderingTexture()
GetTargetFramerate()
Declaration
public static int GetTargetFramerate()
GetTextureFromPixels(Color32[], int, int)
Create a new instance of texture from given pixels data.
Declaration
public static object GetTextureFromPixels(Color32[] pixels, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Color32[] | pixels | Pixel data. 0 means bottom-left corner. 1 makes it goes right for 1 pixel. |
int | width | Width of the pixel data in pixel |
int | height | Heigh of the pixel data in pixel |
Returns
Type | Description |
---|---|
object | Never return null and Don't throw exception. |
GetTextureID(object)
Get internal ID of the given texture instance.
Declaration
public static uint? GetTextureID(object texture)
GetTextureSize(object)
Get the size in pixel of the given texture instance
Declaration
public static Int2 GetTextureSize(object texture)
Returns
Type | Description |
---|---|
Int2 | Return default when invalid. Don't throw exception. |
GetViewWidthFromViewHeight(int)
Calculate view rect width based on given view rect height
Declaration
public static int GetViewWidthFromViewHeight(int viewHeight)
GetWindowPosition()
Get application window position. (0,0) is top-left corner
Declaration
public static Int2 GetWindowPosition()
HideCursor()
Make the mouse cursor disappear (not only for the current frame)
Declaration
public static void HideCursor()
HideDoodle()
Do not display doodled pixels
Declaration
public static void HideDoodle()
IgnoreGizmos(int)
Hide all gizmos for given frames long.
Declaration
public static void IgnoreGizmos(int duration = 0)
Initialize()
Call this function once to initialize the game. Must be called before any Update function called.
Declaration
public void Initialize()
InvokeFileDropped(string)
Invoke OnFileDropped event
Declaration
protected void InvokeFileDropped(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path | Path of the dropped file |
InvokeGameQuitting()
Invoke the OnGameQuitting event
Declaration
protected void InvokeGameQuitting()
InvokeGameTryingToQuit()
Invoke the OnGameTryingToQuit event
Declaration
protected bool InvokeGameTryingToQuit()
Returns
Type | Description |
---|---|
bool | True if the game should quit |
InvokeWindowFocusChanged(bool)
Invoke OnGameFocus/OnGameLostFocus event
Declaration
protected void InvokeWindowFocusChanged(bool focus)
IsGamepadKeyHolding(GamepadKey)
True if the given gamepad button is currently holding
Declaration
public static bool IsGamepadKeyHolding(GamepadKey key)
IsGamepadLeftStickHolding(Direction4)
True if the left gamepad stick is tilting to given direction
Declaration
public static bool IsGamepadLeftStickHolding(Direction4 direction)
IsGamepadRightStickHolding(Direction4)
True if the right gamepad stick is tilting to given direction
Declaration
public static bool IsGamepadRightStickHolding(Direction4 direction)
IsKeyboardKeyHolding(KeyboardKey)
True if the given keyboard key is currently holding
Declaration
public static bool IsKeyboardKeyHolding(KeyboardKey key)
IsTextureReady(object)
True if the given texture instance is ready to use
Declaration
public static bool IsTextureReady(object texture)
LoadFontsIntoPool(string, bool)
Load font file into system pool from given folder
Declaration
public static void LoadFontsIntoPool(string rootPath, bool builtIn)
True if the fonts are used for built-in font
MakeWindowFocused()
Make the application window focused
Declaration
public static void MakeWindowFocused()
OpenUrl(string)
Open the given url with OS default application
Declaration
public static void OpenUrl(string url)
PassEffect(int, int)
Active screen effect for given frames long.
Declaration
public static void PassEffect(int effectIndex, int duration = 0)
Parameters
Type | Name | Description |
---|---|---|
int | effectIndex | Use Const.SCREEN_EFFECT_XXXX for this index |
PassEffect_Greyscale(int)
Enable greyscale screen effect
Declaration
public static void PassEffect_Greyscale(int duration = 0)
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_Greyscale(1);
}
}
PassEffect_Invert(int)
Enable invert screen effect
Declaration
public static void PassEffect_Invert(int duration = 0)
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_Invert(1);
}
}
PassEffect_RetroDarken(float, float, int)
Enable darken screen effect and set the params
Declaration
public static void PassEffect_RetroDarken(float amount, float step = 8, int duration = 0)
Parameters
Type | Name | Description |
---|---|---|
float | amount | 0 means no darken, 1 means full darken |
float | step | How intermittent the darken should be. Default 8 steps. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_RetroDarken(
QTest.Float("amount", 0f, 0f, 1f),
QTest.Float("step", 8f, 2f, 16f),
1
);
}
}
PassEffect_RetroLighten(float, float, int)
Enable lighten screen effect and set the params
Declaration
public static void PassEffect_RetroLighten(float amount, float step = 8, int duration = 0)
Parameters
Type | Name | Description |
---|---|---|
float | amount | 0 means no lighten, 1 means full lighten |
float | step | How intermittent the lighten should be. Default 8 steps. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_RetroLighten(
QTest.Float("amount", 0f, 0f, 1f),
QTest.Float("step", 8f, 2f, 16f),
1
);
}
}
PassEffect_Tint(Color32, int)
Enable color tint screen effect and set the params
Declaration
public static void PassEffect_Tint(Color32 color, int duration = 0)
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
var color = new Color32(
(byte)QTest.Int("r", 255, 0, 255),
(byte)QTest.Int("g", 255, 0, 255),
(byte)QTest.Int("b", 255, 0, 255)
);
Game.PassEffect_Tint(color, 1);
}
}
PassEffect_Vignette(float, float, float, float, float, int)
Enable vignette screen effect and set the params
Declaration
public static void PassEffect_Vignette(float radius, float feather, float offsetX, float offsetY, float round, int duration = 0)
Parameters
Type | Name | Description |
---|---|---|
float | radius | Size of the circle view. 0 means no view. 1 means the view covers whole screen. |
float | feather | How smooth is the edge of the circle view. 0 means sharp edge. 1 means smooth edge. |
float | offsetX | Position offset of the circle view. 0 means view's center at left edge of screen. 1 for right edge. |
float | offsetY | Position offset of the circle view. 0 means view's center at bottom edge of screen. 1 for top edge. |
float | round | How perfect the circle view is. 0 means the aspect ratio is the same with window aspect ratio. 1 means perfect circle. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_Vignette(
QTest.Float("radius", 1f, 0f, 1f),
QTest.Float("feather", 0f, 0f, 1f),
QTest.Float("x", 0f, -1f, 1f),
QTest.Float("y", 0f, -1f, 1f),
QTest.Float("round", 0f, 0f, 1f),
1
);
}
}
PauseGame()
Pause the game from playing
Declaration
public static void PauseGame()
PauseMusic()
Pause the background music
Declaration
public static void PauseMusic()
PlayMusic(int, bool)
Load the music file, create the stream and play it as the background music
Declaration
public static void PlayMusic(int id, bool fromStart = false)
Parameters
Type | Name | Description |
---|---|---|
int | id | ID of the audio |
bool | fromStart | True if seek the music to start |
PlaySound(int, float, float, float)
Play a sound
Declaration
public static void PlaySound(int id, float volume = 1, float pitch = 1, float pan = 0.5)
Parameters
Type | Name | Description |
---|---|---|
int | id | Audio ID |
PngBytesToTexture(byte[])
Create a new instance of texture from a byte array load from png file.
Declaration
public static object PngBytesToTexture(byte[] bytes)
Returns
Type | Description |
---|---|
object | Never return null and Don't throw exception. |
QuitApplication()
Make the application quit without any confirmation
Declaration
public static void QuitApplication()
ResetDoodle()
Clear the doodle pixels canvas
Declaration
public static void ResetDoodle()
RestartGame()
Invoke the OnGameRestart event. The game-play logic will be reset after this is called
Declaration
public static void RestartGame()
SetClipboardText(string)
Set the text content of the system clipboard
Declaration
public static void SetClipboardText(string text)
SetCursor(int)
Set the appearance of the mouse cursor. Use Const.CURSOR_XXX for the index param
Declaration
public static void SetCursor(int index)
SetCursorToNormal()
Set the mouse cursor to default
Declaration
public static void SetCursorToNormal()
SetDoodleOffset(Float2)
Set position offset of the doodle pixels. x=1 means right shift the whole screen width.
Declaration
public static void SetDoodleOffset(Float2 screenOffset)
SetDoodleZoom(float)
Set zoom amount of the doodle pixels. 1 means general size. 2 means zoom-in to double the size.
Declaration
public static void SetDoodleZoom(float zoom)
SetEffectEnable(int, bool)
Make given screen effect enable of disable.
Declaration
public static void SetEffectEnable(int effectIndex, bool enable)
Parameters
Type | Name | Description |
---|---|---|
int | effectIndex | Use Const.SCREEN_EFFECT_XXXX for this index |
SetEventWaiting(bool)
Set to true to make the application only repaint when a user input happens
Declaration
public static void SetEventWaiting(bool enable)
SetMusicVolume(int)
Set volume for the background music (0 means mute, 1000 means loudest)
Declaration
public static void SetMusicVolume(int volume)
SetSoundVolume(int)
Set volume for all sound effects
Declaration
public static void SetSoundVolume(int volume)
SetWindowIcon(int)
Set the icon of the application window using a loaded artwork sprite from the main sheet
Declaration
public static void SetWindowIcon(int spriteID)
SetWindowMinSize(int)
Set the minimal size limitation of the application window
Declaration
public static void SetWindowMinSize(int size)
SetWindowPosition(int, int)
Set application window position. (0,0) is top-left corner
Declaration
public static void SetWindowPosition(int x, int y)
SetWindowSize(int, int)
Set application window size. Use Game.GetMonitorWidth and Game.GetMonitorHeight to get the size of screen size
Declaration
public static void SetWindowSize(int x, int y)
SetWindowTitle(string)
Set to title text of the application window
Declaration
public static void SetWindowTitle(string title)
Settle()
Mark the game frame as settled.
Declaration
public static void Settle()
ShowCursor()
Make the mouse cursor appear (not only for the current frame)
Declaration
public static void ShowCursor()
ShowDoodle(int)
Display the doodled pixels
Declaration
public static void ShowDoodle(int duration = 0)
StopAllSounds()
Stop all sound effects that currently playing
Declaration
public static void StopAllSounds()
StopMusic()
Stop the music stream and unload from memory
Declaration
public static void StopMusic()
SyncAudioPool(params string[])
Update audio files between system pool and file
Declaration
public static void SyncAudioPool(params string[] universeRoots)
Parameters
Type | Name | Description |
---|---|---|
string[] | universeRoots | Folder path of the universe |
SyncFontsWithPool(string)
Reload font file if any font is modified
Declaration
public static bool SyncFontsWithPool(string rootPath)
TextureToPngBytes(object)
Encode the given texture instance into png byte array.
Declaration
public static byte[] TextureToPngBytes(object texture)
Returns
Type | Description |
---|---|
byte[] | Return [] when invalid. Don't throw exception. |
UnloadFontsFromPool(bool)
Unload fonts from system pool
Declaration
public static void UnloadFontsFromPool(bool ignoreBuiltIn = true)
UnloadTexture(object)
Unload the given texture instance from memory
Declaration
public static void UnloadTexture(object texture)
UnpauseGame()
Continue game from pausing
Declaration
public static void UnpauseGame()
UnpauseMusic()
Resume the background music
Declaration
public static void UnpauseMusic()
Update()
Call this function 60 times per second. Only call this after Initialize has been called.
Declaration
public void Update()
_AfterAllLayersUpdate()
This function is called after all rendering layer get updated
Declaration
protected abstract void _AfterAllLayersUpdate()
_BeforeAllLayersUpdate()
This function is called before any rendering layer get updated
Declaration
protected abstract void _BeforeAllLayersUpdate()
_CenterCursor()
Move the mouse cursor to the center of screen. This works when mouse cursor is hidding.
Declaration
protected abstract void _CenterCursor()
_CursorInScreen()
True if the mouse cursor is currently inside application window
Declaration
protected abstract bool _CursorInScreen()
_CursorVisible()
True if the mouse cursor is currently visible
Declaration
protected abstract bool _CursorVisible()
_DoodleRect(FRect, Color32)
Doodle the given color as pixels into the screen-space canvas. Pixels remains on screen until you hide all doodle or reset the canvas.
Declaration
protected abstract void _DoodleRect(FRect screenRect, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
FRect | screenRect | Rect position in screen space |
_DoodleWorld(IBlockSquad, FRect, IRect, int, bool, bool, bool, bool)
Doodle the given map data on screen based on summary tint from rendering sheet
Declaration
protected abstract void _DoodleWorld(IBlockSquad squad, FRect screenRect, IRect worldUnitRange, int z, bool ignoreLevel = false, bool ignoreBG = false, bool ignoreEntity = false, bool ignoreElement = true)
Parameters
Type | Name | Description |
---|---|---|
IBlockSquad | squad | Source of the map block data |
FRect | screenRect | Position rect in screen space for the given world-unit-range |
IRect | worldUnitRange | Rect range on the map in unit space |
int | z | Position Z on the map |
bool | ignoreLevel | True if level blocks should be ignored |
bool | ignoreBG | True if background blocks should be ignored |
bool | ignoreEntity | True if entity blocks should be ignored |
bool | ignoreElement | True if element blocks should be ignored |
_DrawGizmosLine(int, int, int, int, int, Color32)
Draw a line as gizmos for current frame
Declaration
protected abstract void _DrawGizmosLine(int startX, int startY, int endX, int endY, int thickness, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
int | startX | Start point of the line in global space |
int | startY | Start point of the line in global space |
int | endX | End point of the line in global space |
int | endY | End point of the line in global space |
int | thickness | Thickness in global space |
Color32 | color | Color tint |
_DrawGizmosRect(IRect, Color32)
Draw a rectangle as gizmos for current frame
Declaration
protected abstract void _DrawGizmosRect(IRect rect, Color32 color)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | color | Color tint |
_DrawGizmosRect(IRect, Color32, Color32)
Draw a rectangle as gizmos for current frame
Declaration
protected abstract void _DrawGizmosRect(IRect rect, Color32 colorT, Color32 colorB)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | colorT | Color tint |
Color32 | colorB | Color tint |
_DrawGizmosRect(IRect, Color32, Color32, Color32, Color32)
Draw a rectangle as gizmos for current frame
Declaration
protected abstract void _DrawGizmosRect(IRect rect, Color32 colorTL, Color32 colorTR, Color32 colorBL, Color32 colorBR)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position in global space |
Color32 | colorTL | Color tint |
Color32 | colorTR | Color tint |
Color32 | colorBL | Color tint |
Color32 | colorBR | Color tint |
_DrawGizmosTexture(IRect, FRect, object, Color32, bool, bool, bool)
Draw the given texture as gizmos for current frame
Declaration
protected abstract void _DrawGizmosTexture(IRect rect, FRect uv, object texture, Color32 tint, bool inverse, bool flipX, bool flipY)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Rect position |
FRect | uv | Which part of this texture should be draw. (0, 0, 1, 1) means all of them. (0, 0, 0.5f, 1) means left half. |
Color32 | tint | Color tint |
bool | inverse | True if the texture display as the inversed color of the current rendered pixel on screen. |
_Effect_SetDarkenParams(float, float)
Enable darken screen effect and set the params
Declaration
protected abstract void _Effect_SetDarkenParams(float amount, float step)
Parameters
Type | Name | Description |
---|---|---|
float | amount | 0 means no darken, 1 means full darken |
float | step | How intermittent the darken should be. Default 8 steps. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_RetroDarken(
QTest.Float("amount", 0f, 0f, 1f),
QTest.Float("step", 8f, 2f, 16f),
1
);
}
}
_Effect_SetLightenParams(float, float)
Enable lighten screen effect and set the params
Declaration
protected abstract void _Effect_SetLightenParams(float amount, float step)
Parameters
Type | Name | Description |
---|---|---|
float | amount | 0 means no lighten, 1 means full lighten |
float | step | How intermittent the lighten should be. Default 8 steps. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_RetroLighten(
QTest.Float("amount", 0f, 0f, 1f),
QTest.Float("step", 8f, 2f, 16f),
1
);
}
}
_Effect_SetTintParams(Color32)
Enable color tint screen effect and set the params
Declaration
protected abstract void _Effect_SetTintParams(Color32 color)
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
var color = new Color32(
(byte)QTest.Int("r", 255, 0, 255),
(byte)QTest.Int("g", 255, 0, 255),
(byte)QTest.Int("b", 255, 0, 255)
);
Game.PassEffect_Tint(color, 1);
}
}
_Effect_SetVignetteParams(float, float, float, float, float)
Enable vignette screen effect and set the params
Declaration
protected abstract void _Effect_SetVignetteParams(float radius, float feather, float offsetX, float offsetY, float round)
Parameters
Type | Name | Description |
---|---|---|
float | radius | Size of the circle view. 0 means no view. 1 means the view covers whole screen. |
float | feather | How smooth is the edge of the circle view. 0 means sharp edge. 1 means smooth edge. |
float | offsetX | Position offset of the circle view. 0 means view's center at left edge of screen. 1 for right edge. |
float | offsetY | Position offset of the circle view. 0 means view's center at bottom edge of screen. 1 for top edge. |
float | round | How perfect the circle view is. 0 means the aspect ratio is the same with window aspect ratio. 1 means perfect circle. |
Examples
using AngeliA;
namespace AngeliaGame;
public class Example {
[OnGameUpdate]
internal static void OnGameUpdate () {
Game.PassEffect_Vignette(
QTest.Float("radius", 1f, 0f, 1f),
QTest.Float("feather", 0f, 0f, 1f),
QTest.Float("x", 0f, -1f, 1f),
QTest.Float("y", 0f, -1f, 1f),
QTest.Float("round", 0f, 0f, 1f),
1
);
}
}
_FillPixelsIntoTexture(Color32[], object)
Set the given pixel data into the given texture instance.
Declaration
protected abstract void _FillPixelsIntoTexture(Color32[] pixels, object texture)
_FillResizedTexture(object, object, bool)
Copy data from source texture into target texture. Stretch resize the content if two textures have different size.
Declaration
protected abstract void _FillResizedTexture(object sourceTexture, object targetTexture, bool nearestNeighbor = true)
True if the misaligned pixels should be averaged with it's nearby pixels
_GetCharSprite(int, char, out CharSprite)
Get artwork sprite for rendering a text character
Declaration
protected abstract bool _GetCharSprite(int fontIndex, char c, out CharSprite result)
Returns
Type | Description |
---|---|
bool | True if the sprite is successfuly required |
_GetClipboardText()
Text content of the current system clipboard
Declaration
protected abstract string _GetClipboardText()
_GetCurrentMonitor()
Get index of the monitor which this application window currently in
Declaration
protected abstract int _GetCurrentMonitor()
_GetCurrentMusicID()
Audio ID of the current loaded background music
Declaration
protected abstract int _GetCurrentMusicID()
_GetEffectEnable(int)
True if the given screen effect is currently enabled.
Declaration
protected abstract bool _GetEffectEnable(int effectIndex)
Parameters
Type | Name | Description |
---|---|---|
int | effectIndex | Use Const.SCREEN_EFFECT_XXXX for this index |
_GetFontCount()
Total count of loaded fonts
Declaration
protected abstract int _GetFontCount()
_GetGamepadLeftStickDirection()
Get the specific direction of the left gamepad stick
Declaration
protected abstract Float2 _GetGamepadLeftStickDirection()
_GetGamepadRightStickDirection()
Get the specific direction of the right gamepad stick
Declaration
protected abstract Float2 _GetGamepadRightStickDirection()
_GetMonitorHeight(int)
Get height of the current monitor. Use Game.CurrentMonitor to get the monitor index
Declaration
protected abstract int _GetMonitorHeight(int monitor)
_GetMonitorWidth(int)
Get width of the current monitor. Use Game.CurrentMonitor to get the monitor index
Declaration
protected abstract int _GetMonitorWidth(int monitor)
_GetMouseScreenPosition()
Mouse position in screen space. (0,0) means top-left corner
Declaration
protected abstract Int2 _GetMouseScreenPosition()
_GetMouseScrollDelta()
Mouse wheel scrolling value at current frame. Return negative value when the page scrolls down (the content appears to move upward)
Declaration
protected abstract int _GetMouseScrollDelta()
_GetPixelsFromTexture(object)
Create a new instance of Color32 array from the given texture
Declaration
protected abstract Color32[] _GetPixelsFromTexture(object texture)
Returns
Type | Description |
---|---|
Color32[] | Return [] when invalid. Don't throw exception. |
_GetResizedTexture(object, int, int, bool)
Create a new instance of texture which is the resized version of the given texture.
Declaration
protected abstract object _GetResizedTexture(object texture, int newWidth, int newHeight, bool nearestNeighbor = true)
True if the misaligned pixels should be averaged with it's nearby pixels
Returns
Type | Description |
---|---|
object | Return null if invalid. Don't throw exception. |
_GetScreenHeight()
Height of the application window
Declaration
protected abstract int _GetScreenHeight()
_GetScreenRenderingTexture()
Declaration
protected abstract object _GetScreenRenderingTexture()
_GetScreenWidth()
Width of the application window
Declaration
protected abstract int _GetScreenWidth()
_GetTextureFromPixels(Color32[], int, int)
Create a new instance of texture from given pixels data.
Declaration
protected abstract object _GetTextureFromPixels(Color32[] pixels, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Color32[] | pixels | Pixel data. 0 means bottom-left corner. 1 makes it goes right for 1 pixel. |
int | width | Width of the pixel data in pixel |
int | height | Heigh of the pixel data in pixel |
Returns
Type | Description |
---|---|
object | Never return null and Don't throw exception. |
_GetTextureID(object)
Get internal ID of the given texture instance.
Declaration
protected abstract uint? _GetTextureID(object texture)
_GetTextureSize(object)
Get the size in pixel of the given texture instance
Declaration
protected abstract Int2 _GetTextureSize(object texture)
Returns
Type | Description |
---|---|
Int2 | Return default when invalid. Don't throw exception. |
_GetWindowDecorated()
True if the application window is currently having Title bar and border frame
Declaration
protected abstract bool _GetWindowDecorated()
_GetWindowMaximized()
True if the application window is currently maximized
Declaration
protected abstract bool _GetWindowMaximized()
_GetWindowMinimized()
True if the application window is currently minimized
Declaration
protected abstract bool _GetWindowMinimized()
_GetWindowPosition()
Get application window position. (0,0) is top-left corner
Declaration
protected abstract Int2 _GetWindowPosition()
_GetWindowResizable()
True if the application window can be resize by the user
Declaration
protected abstract bool _GetWindowResizable()
_GetWindowTopmost()
True if the application window renders on top of all other windows
Declaration
protected abstract bool _GetWindowTopmost()
_HideCursor()
Make the mouse cursor disappear (not only for the current frame)
Declaration
protected abstract void _HideCursor()
_IgnoreGizmos(int)
Hide all gizmos for given frames long.
Declaration
protected abstract void _IgnoreGizmos(int duration = 0)
_IsGamepadAvailable()
True if any gamepad device is currently available to use
Declaration
protected abstract bool _IsGamepadAvailable()
_IsGamepadKeyHolding(GamepadKey)
True if the given gamepad button is currently holding
Declaration
protected abstract bool _IsGamepadKeyHolding(GamepadKey key)
_IsGamepadLeftStickHolding(Direction4)
True if the left gamepad stick is tilting to given direction
Declaration
protected abstract bool _IsGamepadLeftStickHolding(Direction4 direction)
_IsGamepadRightStickHolding(Direction4)
True if the right gamepad stick is tilting to given direction
Declaration
protected abstract bool _IsGamepadRightStickHolding(Direction4 direction)
_IsKeyboardAvailable()
True is the keyboard device is currently available to use
Declaration
protected abstract bool _IsKeyboardAvailable()
_IsKeyboardKeyHolding(KeyboardKey)
True if the given keyboard key is currently holding
Declaration
protected abstract bool _IsKeyboardKeyHolding(KeyboardKey key)
_IsMouseAvailable()
True if the mouse device is currently available to use
Declaration
protected abstract bool _IsMouseAvailable()
_IsMouseLeftHolding()
True if the mouse left button is currently holding
Declaration
protected abstract bool _IsMouseLeftHolding()
_IsMouseMidHolding()
True if the mouse middle button is currently holding
Declaration
protected abstract bool _IsMouseMidHolding()
_IsMouseRightHolding()
True if the mouse right button is currently holding
Declaration
protected abstract bool _IsMouseRightHolding()
_IsMusicPlaying()
True if the background music is currently playing
Declaration
protected abstract bool _IsMusicPlaying()
_IsTextureReady(object)
True if the given texture instance is ready to use
Declaration
protected abstract bool _IsTextureReady(object texture)
_IsWindowFocused()
True if the application window is currently focused
Declaration
protected abstract bool _IsWindowFocused()
_LoadSound(string)
Load a audio file as sound effect
Declaration
protected abstract object _LoadSound(string filePath)
_LoadSoundAlias(object)
Copy a sound instance that shares the same audio data with given sound object
Declaration
protected abstract object _LoadSoundAlias(object source)
_MakeWindowFocused()
Make the application window focused
Declaration
protected abstract void _MakeWindowFocused()
_OnLayerUpdate(int, Cell[], int)
This function holds the logic to draw all rendering cells for the current frame.
Declaration
protected abstract void _OnLayerUpdate(int layerIndex, Cell[] cells, int cellCount)
Parameters
Type | Name | Description |
---|---|---|
int | layerIndex | Index of the rendering layer |
Cell[] | cells | All rendering cells that may need to be drawn |
int | cellCount | How many rendering cells need to be drawn |
_OpenUrl(string)
Open the given url with OS default application
Declaration
protected abstract void _OpenUrl(string url)
_PauseMusic()
Pause the background music
Declaration
protected abstract void _PauseMusic()
_PlayMusic(int, bool)
Load the music file, create the stream and play it as the background music
Declaration
protected abstract void _PlayMusic(int id, bool fromStart)
Parameters
Type | Name | Description |
---|---|---|
int | id | ID of the audio |
bool | fromStart | True if seek the music to start |
_PlaySound(int, float, float, float)
Play a sound
Declaration
protected abstract void _PlaySound(int id, float volume, float pitch, float pan)
Parameters
Type | Name | Description |
---|---|---|
int | id | Audio ID |
_PngBytesToTexture(byte[])
Create a new instance of texture from a byte array load from png file.
Declaration
protected abstract object _PngBytesToTexture(byte[] bytes)
Returns
Type | Description |
---|---|
object | Never return null and Don't throw exception. |
_QuitApplication()
Make the application quit without any confirmation
Declaration
protected abstract void _QuitApplication()
_ResetDoodle()
Clear the doodle pixels canvas
Declaration
protected abstract void _ResetDoodle()
_SetClipboardText(string)
Set the text content of the system clipboard
Declaration
protected abstract void _SetClipboardText(string text)
_SetCursor(int)
Set the appearance of the mouse cursor. Use Const.CURSOR_XXX for the index param
Declaration
protected abstract void _SetCursor(int index)
_SetCursorToNormal()
Set the mouse cursor to default
Declaration
protected abstract void _SetCursorToNormal()
_SetDoodleOffset(Float2)
Set position offset of the doodle pixels. x=1 means right shift the whole screen width.
Declaration
protected abstract void _SetDoodleOffset(Float2 screenOffset)
_SetDoodleZoom(float)
Set zoom amount of the doodle pixels. 1 means general size. 2 means zoom-in to double the size.
Declaration
protected abstract void _SetDoodleZoom(float zoom)
_SetEffectEnable(int, bool)
Make given screen effect enable of disable.
Declaration
protected abstract void _SetEffectEnable(int effectIndex, bool enable)
Parameters
Type | Name | Description |
---|---|---|
int | effectIndex | Use Const.SCREEN_EFFECT_XXXX for this index |
_SetEventWaiting(bool)
Set to true to make the application only repaint when a user input happens
Declaration
protected abstract void _SetEventWaiting(bool enable)
_SetFullscreen(bool)
Set to true to make the application fullscreen
Declaration
protected abstract void _SetFullscreen(bool fullScreen)
_SetMusicVolume(int)
Set volume for the background music (0 means mute, 1000 means loudest)
Declaration
protected abstract void _SetMusicVolume(int volume)
_SetSoundVolume(int)
Set volume for all sound effects
Declaration
protected abstract void _SetSoundVolume(int volume)
_SetWindowDecorated(bool)
Set to true to make the application window have title bar and border frame
Declaration
protected abstract void _SetWindowDecorated(bool decorated)
_SetWindowIcon(int)
Set the icon of the application window using a loaded artwork sprite from the main sheet
Declaration
protected abstract void _SetWindowIcon(int spriteID)
_SetWindowMaximized(bool)
Set to true to make the application window is currently maximized
Declaration
protected abstract void _SetWindowMaximized(bool maximized)
_SetWindowMinSize(int)
Set the minimal size limitation of the application window
Declaration
protected abstract void _SetWindowMinSize(int size)
_SetWindowMinimized(bool)
Set to true to make the application window is currently minimized
Declaration
protected abstract void _SetWindowMinimized(bool minimized)
_SetWindowPosition(int, int)
Set application window position. (0,0) is top-left corner
Declaration
protected abstract void _SetWindowPosition(int x, int y)
_SetWindowResizable(bool)
Set to true to make the application window can be resize by the user
Declaration
protected abstract void _SetWindowResizable(bool resizable)
_SetWindowSize(int, int)
Set application window size. Use Game.GetMonitorWidth and Game.GetMonitorHeight to get the size of screen size
Declaration
protected abstract void _SetWindowSize(int x, int y)
_SetWindowTitle(string)
Set to title text of the application window
Declaration
protected abstract void _SetWindowTitle(string title)
_SetWindowTopmost(bool)
Set to true to make the application window renders on top of all other windows
Declaration
protected abstract void _SetWindowTopmost(bool topmost)
_ShowCursor()
Make the mouse cursor appear (not only for the current frame)
Declaration
protected abstract void _ShowCursor()
_StopAllSounds()
Stop all sound effects that currently playing
Declaration
protected abstract void _StopAllSounds()
_StopMusic()
Stop the music stream and unload from memory
Declaration
protected abstract void _StopMusic()
_TextureToPngBytes(object)
Encode the given texture instance into png byte array.
Declaration
protected abstract byte[] _TextureToPngBytes(object texture)
Returns
Type | Description |
---|---|
byte[] | Return [] when invalid. Don't throw exception. |
_UnPauseMusic()
Resume the background music
Declaration
protected abstract void _UnPauseMusic()
_UnloadMusic(object)
Unload the bgm object from memory
Declaration
protected abstract void _UnloadMusic(object music)
_UnloadSound(SoundData)
Unload the sound object from memory
Declaration
protected abstract void _UnloadSound(SoundData sound)
_UnloadTexture(object)
Unload the given texture instance from memory
Declaration
protected abstract void _UnloadTexture(object texture)