cmdfx 0.2.1
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
scenes.h
Go to the documentation of this file.
1
11
12#pragma once
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
25#define MAX_REGISTERED_SCENES 1024
26
34typedef struct CmdFX_Scene {
44 int uid;
51 int width;
58 int height;
71 char** data;
85 char*** ansiData;
94 int x;
103 int y;
110 int z;
112
118
124
138CmdFX_Scene* Scene_create(int width, int height);
139
157CmdFX_Scene* Scene_createFilled(int width, int height, char c, char* ansi, int z);
158
177CmdFX_Scene* Scene_createFromData(char** data, char*** ansiData);
178
189
203int Scene_draw(CmdFX_Scene* scene, int x, int y);
204
226int Scene_drawPortion(CmdFX_Scene* scene, int x, int y, int sx, int sy, int width, int height);
227
244
256
269int Scene_isOnTopAt(CmdFX_Scene* scene, int x, int y);
270
282
295int Scene_isOnBottomAt(CmdFX_Scene* scene, int x, int y);
296
307
318
330int Scene_switchTo(CmdFX_Scene* scene, int x, int y);
331
342
349
355
367
378
389
403int Scene_drawRegistered(int uid, int x, int y);
404
416int Scene_switchToRegistered(int uid, int x, int y);
417
433int Scene_scroll(int uid, int dx, int dy);
434
442
453
463
464// Scene Data Manipulation
465
480int Scene_setData(CmdFX_Scene* scene, char** data);
481
500int Scene_setChar(CmdFX_Scene* scene, int x, int y, char c);
501
516int Scene_setAnsiData(CmdFX_Scene* scene, char*** ansiData);
517
532int Scene_appendAnsiData(CmdFX_Scene* scene, char*** ansiData);
533
549int Scene_setForeground(CmdFX_Scene* scene, int x, int y, int width, int height, int rgb);
550
562
578int Scene_setBackground(CmdFX_Scene* scene, int x, int y, int width, int height, int rgb);
579
591
592#ifdef __cplusplus
593}
594#endif
int Canvas_getDrawnScenesCount()
Gets the number of scenes that are drawn on the screen.
int Scene_register(CmdFX_Scene *scene)
Registers a scene with the Scene Engine.
int Scene_isOnTopAt(CmdFX_Scene *scene, int x, int y)
Checks if the specified scene is on top at the specified position on the screen.
int Scene_isOnTop(CmdFX_Scene *scene)
Checks if the specified scene is on top of the screen.
int Scene_setBackground(CmdFX_Scene *scene, int x, int y, int width, int height, int rgb)
Fills the background of the scene with the specified RGB color.
void tickCmdFXSceneEngine()
Ticks the CmdFX Scene Engine.
int Scene_unregister(CmdFX_Scene *scene)
Unregisters a scene with the Scene Engine.
int Scene_drawRegistered(int uid, int x, int y)
Draws a registered scene at the specified position on the screen.
int Scene_isOnBottomAt(CmdFX_Scene *scene, int x, int y)
Checks if the specified scene is on the bottom at the specified position on the screen.
int Scene_appendAnsiData(CmdFX_Scene *scene, char ***ansiData)
Appends the ANSi data to the current ansi data, setting it if it is not currently set.
CmdFX_Scene * Scene_createFilled(int width, int height, char c, char *ansi, int z)
Creates a filled scene with a specified width, height, and character.
int endCmdFXSceneEngine()
Ends the CmdFX Scene Engine.
int Scene_setChar(CmdFX_Scene *scene, int x, int y, char c)
Sets the character at the specified position in the scene.
CmdFX_Scene * Scene_createFromData(char **data, char ***ansiData)
Creates a scene from a 2D array of characters and ANSI strings.
int Scene_setBackgroundAll(CmdFX_Scene *scene, int rgb)
Fills the entirety of the background of the scene with the specified RGB color.
int Scene_draw(CmdFX_Scene *scene, int x, int y)
Draws a scene at the specified position on the screen.
int Scene_setData(CmdFX_Scene *scene, char **data)
Sets the data of the scene.
CmdFX_Scene ** Scene_getRegisteredScenes()
Gets a list of all registered scenes.
CmdFX_Scene * Scene_create(int width, int height)
Creates an empty scene with a specified width and height.
int Scene_drawPortion(CmdFX_Scene *scene, int x, int y, int sx, int sy, int width, int height)
Draws a portion of a scene at the specified position on the screen.
int Scene_setForeground(CmdFX_Scene *scene, int x, int y, int width, int height, int rgb)
Fills the foreground of the scene with the specified RGB color.
CmdFX_Scene * Scene_getSceneAt(int x, int y)
Gets the scene at the specified position on the screen.
CmdFX_Scene ** Canvas_getDrawnScenes()
Gets a list of all scenes that are drawn on the screen.
int Scene_scroll(int uid, int dx, int dy)
Scrolls the scene by the specified amount.
int beginCmdFXSceneEngine()
Begins the CmdFX Scene Engine.
int Scene_remove(CmdFX_Scene *scene)
Removes a scene from the screen.
int Scene_isOnBottom(CmdFX_Scene *scene)
Checks if the specified scene is on the bottom of the screen.
int Scene_getRegisteredScenesCount()
Gets the number of registered scenes.
int Scene_free(CmdFX_Scene *scene)
Destroys the scene, freeing the memory allocated.
int Scene_setForegroundAll(CmdFX_Scene *scene, int rgb)
Fills the entirety of the foreground of the scene with the specified RGB color.
int Scene_isEmpty(CmdFX_Scene *scene)
Checks if the specified scene is empty.
int Scene_switchTo(CmdFX_Scene *scene, int x, int y)
Removes all of the currently drawn scenes, only leaving this scene.
int Scene_setAnsiData(CmdFX_Scene *scene, char ***ansiData)
Sets the ANSI data of the scene.
CmdFX_Scene * Scene_getRegisteredScene(int uid)
Gets a registered scene by its unique identifier.
int Scene_switchToRegistered(int uid, int x, int y)
Removes all of the currently drawn scenes, only leaving the registered scene with the specified uniqu...
int Scene_clear(CmdFX_Scene *scene)
Clears a scene of its data.
Represents a CmdFX Scene.
Definition scenes.h:34
char ** data
Represents the data of the scene.
Definition scenes.h:71
int z
Represents the Z index of the scene.
Definition scenes.h:110
int uid
The unique identifier for the scene.
Definition scenes.h:44
int x
Gets the x-coordinate of the scene.
Definition scenes.h:94
int width
Represents the width of the scene.
Definition scenes.h:51
int y
Gets the y-coordinate of the scene.
Definition scenes.h:103
int height
Represents the height of the scene.
Definition scenes.h:58
char *** ansiData
Represents the ANSI data of the scene.
Definition scenes.h:85