sound support

This commit is contained in:
2024-09-08 11:53:58 +01:00
parent d0377a5b7c
commit 9e7ba471ae
10 changed files with 121 additions and 10 deletions

View File

@@ -5,12 +5,14 @@
#include <SDL.h>
#include <string>
#include <vector>
#include "sound.h"
class Engine
{
private:
const char* ctitle;
int frameStart = 0;
bool soundInitialized = false;
public:
Input input;
@@ -19,6 +21,7 @@ class Engine
SDL_Renderer *renderer;
Engine(std::string title, int width, int height);
void initSound();
void clear(SDL_Color color);
void startFrame();
void render();

26
include/sound.h Normal file
View File

@@ -0,0 +1,26 @@
#include <SDL_mixer.h>
class Music
{
private:
Mix_Music* music;
public:
Music(const char* path);
void play(int loops = -1);
void pause();
void stop();
void resume();
void setVolume(int volume);
~Music();
};
class Effect
{
private:
Mix_Chunk* effect;
public:
Effect(const char* path);
void setVolume(int volume);
void play(int loops = 0, int channel = -1);
~Effect();
};

View File

@@ -21,6 +21,7 @@ class Sprite
void draw(SDL_Renderer* renderer, std::string frame, bool autoRect = true, bool flip = false);
void addFrame(std::string name, SDL_Rect rect);
void move(int_vec2 position);
void setPos(int_vec2 position);
int_vec2 getSize(std::string frame);
void autorect(std::string frame);
~Sprite();