-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alpha 1.0
- Loading branch information
Showing
55 changed files
with
3,890 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
log.txt | ||
test_log.txt | ||
Spylike-v* | ||
lib/bin | ||
lib/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "lib/PDCurses"] | ||
path = lib/PDCurses | ||
url = https://github.com/wmcbrine/PDCurses.git | ||
[submodule "lib/miniaudio"] | ||
path = lib/miniaudio | ||
url = https://github.com/mackron/miniaudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#define MINIAUDIO_IMPLEMENTATION | ||
#include "logger.h" | ||
#include "miniaudio.h" | ||
|
||
#include "audio.h" | ||
|
||
#include <memory> | ||
|
||
extern SpylikeLogger LOGGER; | ||
|
||
void AudioManager::on_event(Event& e) { | ||
if (e.type == "AUDIO_PlayMusic") { | ||
SpylikeEvents::AudioPlayEvent& ap = dynamic_cast<SpylikeEvents::AudioPlayEvent&>(e); | ||
playMusic(ap.sound, ap.volume); | ||
} | ||
else if (e.type == "AUDIO_PauseMusic") { | ||
pauseMusic(); | ||
} | ||
} | ||
|
||
MiniaudioManager::MiniaudioManager(std::string rootPath) : rootPath{rootPath} { | ||
LOGGER.log("Initalizing audio manager", DEBUG); | ||
engine = new ma_engine; | ||
ma_result result = ma_engine_init(NULL, engine); | ||
if (result != MA_SUCCESS) throw "Error initalizing audio engine."; | ||
} | ||
|
||
void MiniaudioManager::playMusic(std::string track, float volume) { | ||
LOGGER.log("Playing music " + track, DEBUG); | ||
if (playing) stopMusic(); | ||
playing = true; | ||
cMusic = new ma_sound; | ||
std::string path = rootPath + "music/" + track; | ||
const char* path_str = path.c_str(); | ||
ma_result res = ma_sound_init_from_file(engine, path_str, 0, NULL, NULL, cMusic); | ||
ma_sound_set_volume(cMusic, volume); | ||
ma_sound_set_looping(cMusic, true); | ||
ma_sound_start(cMusic); | ||
} | ||
|
||
void MiniaudioManager::playSound(std::string sound, float volume) { | ||
const char* path = (rootPath + "sound/" + sound).c_str(); | ||
ma_engine_play_sound(engine, path, NULL); | ||
} | ||
|
||
void MiniaudioManager::stopMusic() { | ||
LOGGER.log("Stopping music", DEBUG); | ||
if (cMusic && engine && playing) { | ||
ma_sound_uninit(cMusic); | ||
delete cMusic; | ||
} | ||
cMusic = nullptr; | ||
playing = false; | ||
} | ||
|
||
void MiniaudioManager::pauseMusic() { | ||
LOGGER.log("Pausing music", DEBUG); | ||
if (cMusic) ma_sound_stop(cMusic); | ||
} | ||
|
||
void MiniaudioManager::resumeMusic() { | ||
if (cMusic) ma_sound_start(cMusic); | ||
} | ||
|
||
void MiniaudioManager::setMusicVolume(float volume) { | ||
if (cMusic) ma_sound_set_volume(cMusic, volume); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
STANDARD EVENT TYPES | ||
|
||
Input: | ||
INPUT_KeyPress : Of type KeyInputEvent. For any keypress, emitted by InputManager. | ||
|
||
Graphics: | ||
CAMERA_MoveUp: Moves the camera up by one unit. (CameraEvent) | ||
CAMERA_MoveDown: Moves the camera down by one unit. (CameraEvent) | ||
CAMERA_MoveRight: Moves the camera right by one unit. (CameraEvent) | ||
CAMERA_MoveLeft: Moves the camera left by one unit. (CameraEvent) | ||
CAMERA_Move: Moves the camera to pos specified in CameraEvent.pos. | ||
|
||
Audio: | ||
AUDIO_PlayMusic: Plays the music with filepath [rootPath]/AudioPlayEvent.sound and volume AudioPlayEvent.volume | ||
AUDIO_PauseMusic: Pauses any currently playing music | ||
|
||
Game: | ||
GAME_PlayerDeath: Emitted when the Player reaches 0 health (or some other death-causing event) | ||
GAME_PlayerHurt: Emitted when the player is hurt, PlayerHurtEvent.health gives *current* health (after hurt) | ||
MENU_Show: Shows the menu with id specified in MenuEvent.menuID | ||
MENU_Close: Closes any active menus | ||
MENU_ButtonClick: Calls when any button is clicked, ID given in MenuButtonEvent.buttonID | ||
Standard button ID behaviors: Buttons with id "close" close the menu | ||
LEVEL_change: Changes the level to LevelChangeEvent.levelPath | ||
GAME_KeyCollect: The key for the final boss door was collected. | ||
GAME_DoorRequest: Event for the door to check whether it can be opened. | ||
GAME_DoorResponse: Response from the game manager about GAME_DoorRequest, result in bool DoorResponse.result. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.