sound support
This commit is contained in:
@@ -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
26
include/sound.h
Normal 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();
|
||||
};
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user