ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
GameLib Class Reference

Public Member Functions

int Open (int width, int height, const char *title, bool center=false, bool resizable=false)
bool IsClosed () const
void Update ()
void WaitFrame (int fps)
double GetDeltaTime () const
double GetFPS () const
double GetTime () const
int GetWidth () const
int GetHeight () const
uint32_t * GetFramebuffer ()
void WinResize (int width, int height)
void SetMaximized (bool maximized)
void SetTitle (const char *title)
void ShowFps (bool show)
void ShowMouse (bool show)
void AspectLock (bool lock, uint32_t color=COLOR_BLACK)
int ShowMessage (const char *text, const char *title=NULL, int buttons=MESSAGEBOX_OK)
void Clear (uint32_t color=COLOR_BLACK)
void SetPixel (int x, int y, uint32_t color)
uint32_t GetPixel (int x, int y) const
void SetClip (int x, int y, int w, int h)
void ClearClip ()
void GetClip (int *x, int *y, int *w, int *h) const
int GetClipX () const
int GetClipY () const
int GetClipW () const
int GetClipH () const
void Screenshot (const char *filename)
void DrawLine (int x1, int y1, int x2, int y2, uint32_t color)
void DrawRect (int x, int y, int w, int h, uint32_t color)
void FillRect (int x, int y, int w, int h, uint32_t color)
void DrawCircle (int cx, int cy, int r, uint32_t color)
void FillCircle (int cx, int cy, int r, uint32_t color)
void DrawEllipse (int cx, int cy, int rx, int ry, uint32_t color)
void FillEllipse (int cx, int cy, int rx, int ry, uint32_t color)
void DrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3, uint32_t color)
void FillTriangle (int x1, int y1, int x2, int y2, int x3, int y3, uint32_t color)
void DrawText (int x, int y, const char *text, uint32_t color)
void DrawNumber (int x, int y, int number, uint32_t color)
void DrawTextScale (int x, int y, const char *text, uint32_t color, int w, int h)
void DrawPrintf (int x, int y, uint32_t color, const char *fmt,...)
void DrawPrintfScale (int x, int y, uint32_t color, int w, int h, const char *fmt,...)
void DrawTextFont (int x, int y, const char *text, uint32_t color, const char *fontName, int fontSize)
void DrawTextFont (int x, int y, const char *text, uint32_t color, int fontSize)
void DrawPrintfFont (int x, int y, uint32_t color, const char *fontName, int fontSize, const char *fmt,...)
void DrawPrintfFont (int x, int y, uint32_t color, int fontSize, const char *fmt,...)
int GetTextWidthFont (const char *text, const char *fontName, int fontSize)
int GetTextWidthFont (const char *text, int fontSize)
int GetTextHeightFont (const char *text, const char *fontName, int fontSize)
int GetTextHeightFont (const char *text, int fontSize)
int CreateSprite (int width, int height)
int LoadSpriteBMP (const char *filename)
int LoadSprite (const char *filename)
void FreeSprite (int id)
void DrawSprite (int id, int x, int y)
void DrawSpriteEx (int id, int x, int y, int flags)
void DrawSpriteRegion (int id, int x, int y, int sx, int sy, int sw, int sh)
void DrawSpriteRegionEx (int id, int x, int y, int sx, int sy, int sw, int sh, int flags=0)
void DrawSpriteScaled (int id, int x, int y, int w, int h, int flags=0)
void DrawSpriteRotated (int id, int cx, int cy, double angleDeg, int flags=0)
void DrawSpriteFrame (int id, int x, int y, int frameW, int frameH, int frameIndex, int flags=0)
void DrawSpriteFrameScaled (int id, int x, int y, int frameW, int frameH, int frameIndex, int w, int h, int flags=0)
void DrawSpriteFrameRotated (int id, int cx, int cy, int frameW, int frameH, int frameIndex, double angleDeg, int flags=0)
void SetSpritePixel (int id, int x, int y, uint32_t color)
uint32_t GetSpritePixel (int id, int x, int y) const
int GetSpriteWidth (int id) const
int GetSpriteHeight (int id) const
void SetSpriteColorKey (int id, uint32_t color)
uint32_t GetSpriteColorKey (int id) const
int CreateTilemap (int cols, int rows, int tileSize, int tilesetId)
bool SaveTilemap (const char *filename, int mapId) const
int LoadTilemap (const char *filename, int tilesetId)
void FreeTilemap (int mapId)
void SetTile (int mapId, int col, int row, int tileId)
int GetTile (int mapId, int col, int row) const
int GetTilemapCols (int mapId) const
int GetTilemapRows (int mapId) const
int GetTileSize (int mapId) const
int WorldToTileCol (int mapId, int x) const
int WorldToTileRow (int mapId, int y) const
int GetTileAtPixel (int mapId, int x, int y) const
void FillTileRect (int mapId, int col, int row, int cols, int rows, int tileId)
void ClearTilemap (int mapId, int tileId=-1)
void DrawTilemap (int mapId, int x, int y, int flags=0)
void DrawGrid (int x, int y, int rows, int cols, int cellSize, uint32_t color)
void FillCell (int gridX, int gridY, int row, int col, int cellSize, uint32_t color)
bool IsKeyDown (int key) const
bool IsKeyPressed (int key) const
bool IsKeyReleased (int key) const
int GetMouseX () const
int GetMouseY () const
bool IsMouseDown (int button) const
bool IsMousePressed (int button) const
bool IsMouseReleased (int button) const
int GetMouseWheelDelta () const
bool IsActive () const
int PlayBeep (int frequency, int duration, int repeat=1, int volume=1000)
int PlayWAV (const char *filename, int repeat=1, int volume=1000)
int PlayPCM (const int16_t *pcm, int nchannels, int nsamples, int sample_rate, int repeat=1, int volume=1000)
int StopWAV (int channel)
int IsPlaying (int channel)
int SetVolume (int channel, int volume)
void StopAll ()
int SetMasterVolume (int volume)
int GetMasterVolume () const
bool PlayMusic (const char *filename, bool loop=true)
void StopMusic ()
bool IsMusicPlaying () const
void SetScene (int scene)
int GetScene () const
bool IsSceneChanged () const
int GetPreviousScene () const
bool Button (int x, int y, int w, int h, const char *text, uint32_t color)
bool Checkbox (int x, int y, const char *text, bool *checked)
bool RadioBox (int x, int y, const char *text, int *value, int index)
bool ToggleButton (int x, int y, int w, int h, const char *text, bool *toggled, uint32_t color)
int Open (int width, int height, const char *title, bool center=false, bool resizable=false)
bool IsClosed () const
void Update ()
void WaitFrame (int fps)
double GetDeltaTime () const
double GetFPS () const
double GetTime () const
int GetWidth () const
int GetHeight () const
uint32_t * GetFramebuffer ()
void WinResize (int width, int height)
void SetMaximized (bool maximized)
void SetTitle (const char *title)
void ShowFps (bool show)
void ShowMouse (bool show)
void AspectLock (bool lock, uint32_t color=COLOR_BLACK)
int ShowMessage (const char *text, const char *title=NULL, int buttons=MESSAGEBOX_OK)
void Clear (uint32_t color=COLOR_BLACK)
void SetPixel (int x, int y, uint32_t color)
uint32_t GetPixel (int x, int y) const
void SetClip (int x, int y, int w, int h)
void ClearClip ()
void GetClip (int *x, int *y, int *w, int *h) const
int GetClipX () const
int GetClipY () const
int GetClipW () const
int GetClipH () const
void Screenshot (const char *filename)
void DrawLine (int x1, int y1, int x2, int y2, uint32_t color)
void DrawRect (int x, int y, int w, int h, uint32_t color)
void FillRect (int x, int y, int w, int h, uint32_t color)
void DrawCircle (int cx, int cy, int r, uint32_t color)
void FillCircle (int cx, int cy, int r, uint32_t color)
void DrawEllipse (int cx, int cy, int rx, int ry, uint32_t color)
void FillEllipse (int cx, int cy, int rx, int ry, uint32_t color)
void DrawTriangle (int x1, int y1, int x2, int y2, int x3, int y3, uint32_t color)
void FillTriangle (int x1, int y1, int x2, int y2, int x3, int y3, uint32_t color)
void DrawText (int x, int y, const char *text, uint32_t color)
void DrawNumber (int x, int y, int number, uint32_t color)
void DrawTextScale (int x, int y, const char *text, uint32_t color, int w, int h)
void DrawPrintf (int x, int y, uint32_t color, const char *fmt,...)
void DrawPrintfScale (int x, int y, uint32_t color, int w, int h, const char *fmt,...)
void DrawTextFont (int x, int y, const char *text, uint32_t color, const char *fontName, int fontSize)
void DrawTextFont (int x, int y, const char *text, uint32_t color, int fontSize)
void DrawPrintfFont (int x, int y, uint32_t color, const char *fontName, int fontSize, const char *fmt,...)
void DrawPrintfFont (int x, int y, uint32_t color, int fontSize, const char *fmt,...)
int GetTextWidthFont (const char *text, const char *fontName, int fontSize)
int GetTextWidthFont (const char *text, int fontSize)
int GetTextHeightFont (const char *text, const char *fontName, int fontSize)
int GetTextHeightFont (const char *text, int fontSize)
int CreateSprite (int width, int height)
int LoadSpriteBMP (const char *filename)
int LoadSprite (const char *filename)
void FreeSprite (int id)
void DrawSprite (int id, int x, int y)
void DrawSpriteEx (int id, int x, int y, int flags)
void DrawSpriteRegion (int id, int x, int y, int sx, int sy, int sw, int sh)
void DrawSpriteRegionEx (int id, int x, int y, int sx, int sy, int sw, int sh, int flags=0)
void DrawSpriteScaled (int id, int x, int y, int w, int h, int flags=0)
void DrawSpriteRotated (int id, int cx, int cy, double angleDeg, int flags=0)
void DrawSpriteFrame (int id, int x, int y, int frameW, int frameH, int frameIndex, int flags=0)
void DrawSpriteFrameScaled (int id, int x, int y, int frameW, int frameH, int frameIndex, int w, int h, int flags=0)
void DrawSpriteFrameRotated (int id, int cx, int cy, int frameW, int frameH, int frameIndex, double angleDeg, int flags=0)
void SetSpritePixel (int id, int x, int y, uint32_t color)
uint32_t GetSpritePixel (int id, int x, int y) const
int GetSpriteWidth (int id) const
int GetSpriteHeight (int id) const
void SetSpriteColorKey (int id, uint32_t color)
uint32_t GetSpriteColorKey (int id) const
bool IsKeyDown (int key) const
bool IsKeyPressed (int key) const
bool IsKeyReleased (int key) const
int GetMouseX () const
int GetMouseY () const
bool IsMouseDown (int button) const
bool IsMousePressed (int button) const
bool IsMouseReleased (int button) const
int GetMouseWheelDelta () const
bool IsActive () const
int PlayBeep (int frequency, int duration, int repeat=1, int volume=1000)
int PlayWAV (const char *filename, int repeat=1, int volume=1000)
int PlayPCM (const int16_t *pcm, int nchannels, int nsamples, int sample_rate, int repeat=1, int volume=1000)
int StopWAV (int channel)
int IsPlaying (int channel)
int SetVolume (int channel, int volume)
void StopAll ()
int SetMasterVolume (int volume)
int GetMasterVolume () const
bool PlayMusic (const char *filename, bool loop=true)
void StopMusic ()
bool IsMusicPlaying () const
int CreateTilemap (int cols, int rows, int tileSize, int tilesetId)
bool SaveTilemap (const char *filename, int mapId) const
int LoadTilemap (const char *filename, int tilesetId)
void FreeTilemap (int mapId)
void SetTile (int mapId, int col, int row, int tileId)
int GetTile (int mapId, int col, int row) const
int GetTilemapCols (int mapId) const
int GetTilemapRows (int mapId) const
int GetTileSize (int mapId) const
int WorldToTileCol (int mapId, int x) const
int WorldToTileRow (int mapId, int y) const
int GetTileAtPixel (int mapId, int x, int y) const
void FillTileRect (int mapId, int col, int row, int cols, int rows, int tileId)
void ClearTilemap (int mapId, int tileId=-1)
void DrawTilemap (int mapId, int x, int y, int flags=0)
void DrawGrid (int x, int y, int rows, int cols, int cellSize, uint32_t color)
void FillCell (int gridX, int gridY, int row, int col, int cellSize, uint32_t color)
bool Button (int x, int y, int w, int h, const char *text, uint32_t color)
bool Checkbox (int x, int y, const char *text, bool *checked)
bool RadioBox (int x, int y, const char *text, int *value, int index)
bool ToggleButton (int x, int y, int w, int h, const char *text, bool *toggled, uint32_t color)
void SetScene (int scene)
int GetScene () const
bool IsSceneChanged () const
int GetPreviousScene () const

Static Public Member Functions

static bool SaveInt (const char *filename, const char *key, int value)
static bool SaveFloat (const char *filename, const char *key, float value)
static bool SaveString (const char *filename, const char *key, const char *value)
static int LoadInt (const char *filename, const char *key, int defaultValue=0)
static float LoadFloat (const char *filename, const char *key, float defaultValue=0.0f)
static const char * LoadString (const char *filename, const char *key, const char *defaultValue="")
static bool HasSaveKey (const char *filename, const char *key)
static bool DeleteSaveKey (const char *filename, const char *key)
static bool DeleteSave (const char *filename)
static int Random (int minVal, int maxVal)
static bool RectOverlap (int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
static bool CircleOverlap (int cx1, int cy1, int r1, int cx2, int cy2, int r2)
static bool PointInRect (int px, int py, int x, int y, int w, int h)
static float Distance (int x1, int y1, int x2, int y2)
static bool SaveInt (const char *filename, const char *key, int value)
static bool SaveFloat (const char *filename, const char *key, float value)
static bool SaveString (const char *filename, const char *key, const char *value)
static int LoadInt (const char *filename, const char *key, int defaultValue=0)
static float LoadFloat (const char *filename, const char *key, float defaultValue=0.0f)
static const char * LoadString (const char *filename, const char *key, const char *defaultValue="")
static bool HasSaveKey (const char *filename, const char *key)
static bool DeleteSaveKey (const char *filename, const char *key)
static bool DeleteSave (const char *filename)
static int Random (int minVal, int maxVal)
static bool RectOverlap (int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2)
static bool CircleOverlap (int cx1, int cy1, int r1, int cx2, int cy2, int r2)
static bool PointInRect (int px, int py, int x, int y, int w, int h)
static float Distance (int x1, int y1, int x2, int y2)

The documentation for this class was generated from the following files: