cmdfx 0.2.0
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
24#define MAX_REGISTERED_SCENES 1024
25
33typedef struct CmdFX_Scene {
43 int uid;
50 int width;
57 int height;
70 char** data;
84 char*** ansiData;
93 int x;
102 int y;
109 int z;
111
117
123
137CmdFX_Scene* Scene_create(int width, int height);
138
156CmdFX_Scene* Scene_createFilled(int width, int height, char c, char* ansi, int z);
157
176CmdFX_Scene* Scene_createFromData(char** data, char*** ansiData);
177
188
202int Scene_draw(CmdFX_Scene* scene, int x, int y);
203
225int Scene_drawPortion(CmdFX_Scene* scene, int x, int y, int sx, int sy, int width, int height);
226
243
255
268int Scene_isOnTopAt(CmdFX_Scene* scene, int x, int y);
269
281
294int Scene_isOnBottomAt(CmdFX_Scene* scene, int x, int y);
295
306
317
329int Scene_switchTo(CmdFX_Scene* scene, int x, int y);
330
341
348
354
365
376
390int Scene_drawRegistered(int uid, int x, int y);
391
403int Scene_switchToRegistered(int uid, int x, int y);
404
420int Scene_scroll(int uid, int dx, int dy);
421
429
440
450
451// Scene Data Manipulation
452
467int Scene_setData(CmdFX_Scene* scene, char** data);
468
487int Scene_setChar(CmdFX_Scene* scene, int x, int y, char c);
488
503int Scene_setAnsiData(CmdFX_Scene* scene, char*** ansiData);
504
519int Scene_appendAnsiData(CmdFX_Scene* scene, char*** ansiData);
520
536int Scene_setForeground(CmdFX_Scene* scene, int x, int y, int width, int height, int rgb);
537
549
565int Scene_setBackground(CmdFX_Scene* scene, int x, int y, int width, int height, int rgb);
566
578
579#ifdef __cplusplus
580}
581#endif
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.
int Scene_getDrawnScenesCount()
Gets the number of scenes that are drawn on the screen.
CmdFX_Scene * Scene_getSceneAt(int x, int y)
Gets the scene at the specified position 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.
CmdFX_Scene ** Scene_getDrawnScenes()
Gets a list of all scenes that are drawn on the screen.
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.
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:33
char ** data
Represents the data of the scene.
Definition scenes.h:70
int z
Represents the Z index of the scene.
Definition scenes.h:109
int uid
The unique identifier for the scene.
Definition scenes.h:43
int x
Gets the x-coordinate of the scene.
Definition scenes.h:93
int width
Represents the width of the scene.
Definition scenes.h:50
int y
Gets the y-coordinate of the scene.
Definition scenes.h:102
int height
Represents the height of the scene.
Definition scenes.h:57
char *** ansiData
Represents the ANSI data of the scene.
Definition scenes.h:84