font and sound

This commit is contained in:
huaqo-games
2025-03-25 21:04:02 +01:00
parent 8384967e55
commit da4f065fb4
175 changed files with 43 additions and 7 deletions
+5
View File
@@ -16,10 +16,15 @@ typedef struct {
const char* path;
} SoundtrackAsset;
typedef struct {
const char* path;
} SoundAsset;
typedef struct {
const TextureAsset *textureAssets;
const ShaderAsset *shaderAssets;
const SoundtrackAsset *soundtrackAssets;
const SoundAsset *soundAssets;
} Assets;
#endif // ASSET_H
+11 -1
View File
@@ -14,6 +14,7 @@ typedef struct
Sprite sprite;
Vector2 notClicked;
Vector2 clicked;
bool isHovered;
} ImageButton;
typedef struct
@@ -72,18 +73,27 @@ void PrintImageButton(const ImageButton btn) {
printf(" clicked: x = %f, y = %f\n", btn.clicked.x, btn.clicked.y);
}
int isImageButtonClicked(ImageButton *b){
int isImageButtonClicked(ImageButton *b, Sound soundHover, Sound soundClick){
if (CheckCollisionPointRec(GetMousePosition(), b->sprite.destRec)) {
if (!b->isHovered) {
PlaySound(soundHover);
b->isHovered = true;
}
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)){
UpdateSpriteSourceRec(&b->sprite, &b->clicked);
}
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
PlaySound(soundClick);
b->isHovered = false;
UpdateSpriteSourceRec(&b->sprite, &b->notClicked);
return true;
}
} else {
UpdateSpriteSourceRec(&b->sprite, &b->notClicked);
b->isHovered = false;
}
return false;
}