merged herbglitch/master with local changes

This commit is contained in:
herbglitch 2024-01-19 01:19:17 -07:00
commit a0c02c0dcd
26 changed files with 329 additions and 38 deletions

16
include/arc/audio/audio.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef ARC_AUDIO_H_
#define ARC_AUDIO_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ARC_Audio ARC_Audio;
void ARC_Audio_Play(ARC_Audio *audio);
#ifdef __cplusplus
}
#endif
#endif // !ARC_AUDIO_H_

View file

@ -0,0 +1,22 @@
#ifndef ARC_AUDIO_CONFIG_H_
#define ARC_AUDIO_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "arc/std/string.h"
typedef struct ARC_Config ARC_Config;
void ARC_AudioConfig_Init(ARC_Config *config);
uint8_t ARC_Audio_Read(ARC_Config *config, ARC_String *string, void **value);
void ARC_Audio_Delete(ARC_Config *config, ARC_String *string, void *value);
#ifdef __cplusplus
}
#endif
#endif //ARC_AUDIO_CONFIG_H_

View file

@ -0,0 +1,12 @@
#ifndef ARC_SDL_AUDIO_H_
#define ARC_SDL_AUDIO_H_
#ifdef ARC_SDL
#include <SDL2/SDL_mixer.h>
typedef struct ARC_Audio {
Mix_Chunk *chunk;
} ARC_Audio;
#endif // !ARC_SDL
#endif // !ARC_SDL_AUDIO_H_

View file

@ -12,7 +12,7 @@ extern "C" {
void ARC_Circle_Render(ARC_Circle *circle, ARC_Renderer *renderer, ARC_Color *color);
// void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color);
void ARC_Circle_RenderFill(ARC_Circle *circle, ARC_Renderer *renderer, ARC_Color *color);
#ifdef __cplusplus
}

View file

@ -9,6 +9,8 @@ struct ARC_Sprite {
ARC_Spritesheet *spritesheet;
ARC_Array *frames;
uint32_t *frameIndex;
//TODO: temp
uint8_t opacity;
};
#endif // !ARC_SDL

View file

@ -42,6 +42,18 @@ void ARC_Sprite_Destroy(ARC_Sprite *sprite);
*/
void ARC_Sprite_Copy(ARC_Sprite **newSprite, ARC_Sprite *oldSprite);
//TODO: temp
/**
* @brief sets ARC_Sprite's opacity
*
* @param sprite ARC_Sprite that is changing opacity
* @param opacity new opacity for ARC_Sprite
*
* @note this is temp because opacity probably should be a value
* bigger than 255
*/
void ARC_Sprite_SetOpacity(ARC_Sprite *sprite, uint8_t opacity);
/**
* @brief renders ARC_Sprite type
*
@ -94,6 +106,15 @@ void ARC_Sprite_SetFrameIndex(ARC_Sprite *sprite, uint32_t index);
*/
void ARC_Sprite_IterateFrame(ARC_Sprite *sprite);
/**
* @brief gets ARC_Sprite's current frame
*
* @param sprite ARC_Sprite to get frame from
*
* @return index ARC_Sprite's current frame index
*/
uint32_t ARC_Sprite_GetFrameIndex(ARC_Sprite *sprite);
/**
* @brief returns the current bounds based on the ARC_Sprite's frames
*

View file

@ -0,0 +1,59 @@
#ifndef ARC_GRAPHICS_VIEW_H_
#define ARC_GRAPHICS_VIEW_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "arc/graphics/renderer.h"
#include "arc/math/rectangle.h"
typedef struct ARC_View {
ARC_Renderer *renderer;
ARC_Rect bounds;
} ARC_View;
/**
* @brief a function for ARC_View where contents of the function will be rendered within a view
*
* @param data data to be used within ARC_View_RenderFn
*/
typedef void (* ARC_View_RenderFn)(void *data);
/**
* @brief creates ARC_View type
*
* @param view ARC_View to initialize
* @param renderer ARC_Renderer the view will render to
* @param bounds ARC_Rect bounds of the view within the renderer
*/
void ARC_View_Create(ARC_View **view, ARC_Renderer *renderer, ARC_Rect bounds);
/**
* @brief destroys ARC_View type
*/
void ARC_View_Destroy(ARC_View *view);
/**
* @brief renders callbacks contents within an ARC_View
*
* @param view ARC_View to be renedered to
* @param renderFn function which contents will render to given ARC_View
* @param data data to be used in renderFn
*/
void ARC_View_Render(ARC_View *view, ARC_View_RenderFn renderFn, void *data);
/**
* @brief gets bounds from ARC_View type
*
* @param view ARC_View to get bounds from
*
* @return bounds of the view
*/
ARC_Rect ARC_View_GetBounds(ARC_View *view);
#ifdef __cplusplus
}
#endif
#endif // !ARC_GRAPHICS_VIEW_H_

View file

@ -64,6 +64,7 @@ typedef enum ARC_KeyboardKey {
ARC_KEY_SPACE,
ARC_KEY_ESC,
ARC_KEY_ENTER,
} ARC_Keyboard_Key;
ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_KeyboardKey key);

View file

@ -22,6 +22,8 @@ typedef struct ARC_FPoint {
float y;
} ARC_FPoint;
ARC_FPoint ARC_FPoint_Lerp(ARC_FPoint *start, ARC_FPoint *end, float t);
#ifdef __cplusplus
}
#endif

View file

@ -87,6 +87,18 @@ uint8_t ARC_String_Equals(ARC_String *first, ARC_String *second);
*/
uint8_t ARC_String_EqualsCString(ARC_String *string, const char *cstring, uint64_t length);
/**
* @brief check if ARC_String and cstring match
*
* @param string ARC_string to check
* @param offset postion based on string to start comparing against cstring
* @param cstring cstring to check
* @param length length of cstring
*
* @return 1 if match, 0 if they don't match
*/
uint8_t ARC_String_SubstringEqualsCString(ARC_String *string, uint64_t offset, const char *cstring, uint64_t length);
/**
* @brief checks if string is alphabetic
*
@ -157,39 +169,39 @@ uint64_t ARC_String_FindBack(ARC_String *string, ARC_String *substring);
/**
* @brief strips the ends based on a given char
*
* @param original the string which whill have the matching char stripped from
* @param stripped where to store the string which has witespace stripped
* will be null if there is an error
* @param original the string which whill have the matching char stripped from
* @param charToStrip the char that will be stripped from the ends
*/
void ARC_String_StripEnds(ARC_String *original, ARC_String **stripped, char charToStrip);
void ARC_String_StripEnds(ARC_String **stripped, ARC_String *original, char charToStrip);
/**
* @brief strips whitespace from a ARC_String
*
* @param original the string which whill have whitespace stripped from
* @param stripped where to store the string which has witespace stripped
* will be null if there is an error
* @param original the string which whill have whitespace stripped from
*/
void ARC_String_StripWhitespace(ARC_String *original, ARC_String **stripped);
void ARC_String_StripWhitespace(ARC_String **stripped, ARC_String *original);
/**
* @brief strips the whitespace from the ends of a string
*
* @param original the string which whill have the whitespace stripped from its ends
* @param stripped where to store the string which has witespace stripped from the ends
* will be null if there is an error
* @param original the string which whill have the whitespace stripped from its ends
*/
void ARC_String_StripEndsWhitespace(ARC_String *original, ARC_String **stripped);
void ARC_String_StripEndsWhitespace(ARC_String **stripped, ARC_String *original);
/**
* @brief merges two strings together
*
* @param combined new ARC_String of combined strings frist + second
* @param first first part of string to combine
* @param second second part of string to combine
* @param combined new ARC_String of combined strings frist + second
*/
void ARC_String_Merge(ARC_String *first, ARC_String *second, ARC_String **combined);
void ARC_String_Merge(ARC_String **combined, ARC_String *first, ARC_String *second);
/**
* @brief copy a subtring from a givin ARC_String