summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--assets/units/soldier/fire.oggbin0 -> 57257 bytes
-rw-r--r--assets_src/fire_1.aup91
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f1a4.aubin0 -> 221504 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f22c.aubin0 -> 358416 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f374.aubin0 -> 577720 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f4a4.aubin0 -> 358416 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f53d.aubin0 -> 577720 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1f75c.aubin0 -> 358416 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1fa8c.aubin0 -> 221504 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1fbcd.aubin0 -> 611160 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1fc64.aubin0 -> 611160 bytes
-rw-r--r--assets_src/fire_1_data/eff/d1f/eff1fe16.aubin0 -> 358416 bytes
-rw-r--r--src/audio.cpp37
-rw-r--r--src/common.hpp11
-rw-r--r--src/game/assets.cpp2
-rw-r--r--src/game/game.hpp6
-rw-r--r--src/game/units.cpp5
18 files changed, 154 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 7719800..00c243d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CC ?= gcc
CFLAGS += -g3 -O0 -Wall -std=gnu++14
CPPFLAGS += -MMD
-LDFLAGS += -lstdc++ -lm -lsfml-system -lsfml-window -lsfml-graphics
+LDFLAGS += -lstdc++ -lm -lsfml-system -lsfml-window -lsfml-graphics -lsfml-audio
PP_BOLD := $(shell tput bold)
PP_RESET := $(shell tput sgr0)
@@ -17,6 +17,7 @@ SRC := src/game/assets.cpp \
src/game/text.cpp \
src/game/units.cpp \
src/game/worldgen.cpp \
+ src/audio.cpp \
src/main.cpp \
src/path_finder.cpp \
src/procgen.cpp \
diff --git a/assets/units/soldier/fire.ogg b/assets/units/soldier/fire.ogg
new file mode 100644
index 0000000..00e5a8a
--- /dev/null
+++ b/assets/units/soldier/fire.ogg
Binary files differ
diff --git a/assets_src/fire_1.aup b/assets_src/fire_1.aup
new file mode 100644
index 0000000..f604c62
--- /dev/null
+++ b/assets_src/fire_1.aup
@@ -0,0 +1,91 @@
+<?xml version="1.0" standalone="no" ?>
+<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
+<project xmlns="http://audacity.sourceforge.net/xml/" projname="fire_1_data" version="1.3.0" audacityversion="2.2.2" sel0="0.0000000000" sel1="0.0000000000" vpos="256" h="0.0000000000" zoom="367.5161297402" rate="44100.0" snapto="off" selectionformat="hh:mm:ss + milliseconds" frequencyformat="Hz" bandwidthformat="octaves">
+ <tags/>
+ <wavetrack name="ZOOM0017" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="96000" gain="1.995262" pan="0.0" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="54594">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1fa8c.au" len="54594" min="-0.66308" max="0.552195" rms="0.172965"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="96000" gain="1.995262" pan="0.0" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="54594">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f1a4.au" len="54594" min="-0.655082" max="0.634338" rms="0.189657"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="0" rate="96000" gain="1.995262" pan="-0.4" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="88051">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f22c.au" len="88051" min="-0.24699" max="0.186106" rms="0.038291"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="0" rate="96000" gain="1.995262" pan="-0.4" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="88051">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f75c.au" len="88051" min="-0.202912" max="0.142635" rms="0.023829"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="0" linked="1" mute="0" solo="0" height="152" minimized="0" isSelected="0" rate="96000" gain="1.0" pan="0.7" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="88051">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f4a4.au" len="88051" min="-0.482843" max="0.449684" rms="0.069413"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="1" linked="0" mute="0" solo="0" height="152" minimized="0" isSelected="0" rate="96000" gain="1.0" pan="0.7" colorindex="0">
+ <waveclip offset="0.00000000" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="88051">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1fe16.au" len="88051" min="-0.539785" max="0.40026" rms="0.076058"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="0" linked="1" mute="0" solo="0" height="148" minimized="0" isSelected="0" rate="96000" gain="11.220184" pan="0.0" colorindex="0">
+ <waveclip offset="0.16054167" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="292572">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f374.au" len="142106" min="-0.026846" max="0.023621" rms="0.006061"/>
+ </waveblock>
+ <waveblock start="142106">
+ <simpleblockfile filename="eff1fc64.au" len="150466" min="-0.027534" max="0.024314" rms="0.002717"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+ <wavetrack name="ZOOM0017" channel="1" linked="0" mute="0" solo="0" height="152" minimized="0" isSelected="0" rate="96000" gain="11.220184" pan="0.0" colorindex="0">
+ <waveclip offset="0.16054167" colorindex="0">
+ <sequence maxsamples="262144" sampleformat="262159" numsamples="292572">
+ <waveblock start="0">
+ <simpleblockfile filename="eff1f53d.au" len="142106" min="-0.018493" max="0.016251" rms="0.004227"/>
+ </waveblock>
+ <waveblock start="142106">
+ <simpleblockfile filename="eff1fbcd.au" len="150466" min="-0.017515" max="0.014472" rms="0.001905"/>
+ </waveblock>
+ </sequence>
+ <envelope numpoints="0"/>
+ </waveclip>
+ </wavetrack>
+</project>
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f1a4.au b/assets_src/fire_1_data/eff/d1f/eff1f1a4.au
new file mode 100644
index 0000000..e00219f
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f1a4.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f22c.au b/assets_src/fire_1_data/eff/d1f/eff1f22c.au
new file mode 100644
index 0000000..97e52fa
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f22c.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f374.au b/assets_src/fire_1_data/eff/d1f/eff1f374.au
new file mode 100644
index 0000000..17f92f9
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f374.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f4a4.au b/assets_src/fire_1_data/eff/d1f/eff1f4a4.au
new file mode 100644
index 0000000..eeda46c
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f4a4.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f53d.au b/assets_src/fire_1_data/eff/d1f/eff1f53d.au
new file mode 100644
index 0000000..55fdce0
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f53d.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1f75c.au b/assets_src/fire_1_data/eff/d1f/eff1f75c.au
new file mode 100644
index 0000000..2c54a49
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1f75c.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1fa8c.au b/assets_src/fire_1_data/eff/d1f/eff1fa8c.au
new file mode 100644
index 0000000..9443738
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1fa8c.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1fbcd.au b/assets_src/fire_1_data/eff/d1f/eff1fbcd.au
new file mode 100644
index 0000000..632f24a
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1fbcd.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1fc64.au b/assets_src/fire_1_data/eff/d1f/eff1fc64.au
new file mode 100644
index 0000000..1a9e38c
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1fc64.au
Binary files differ
diff --git a/assets_src/fire_1_data/eff/d1f/eff1fe16.au b/assets_src/fire_1_data/eff/d1f/eff1fe16.au
new file mode 100644
index 0000000..5e8a485
--- /dev/null
+++ b/assets_src/fire_1_data/eff/d1f/eff1fe16.au
Binary files differ
diff --git a/src/audio.cpp b/src/audio.cpp
new file mode 100644
index 0000000..012c396
--- /dev/null
+++ b/src/audio.cpp
@@ -0,0 +1,37 @@
+/*
+This file is part of Minitrem.
+
+Minitrem is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+Minitrem is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitrem. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "common.hpp"
+
+namespace audio {
+
+void sound_t::load(const char *path)
+{
+ printf("load %s\n", path);
+ buffer.loadFromFile(path);
+}
+
+static std::list<sf::Sound> playing_sounds;
+
+void sound_t::play(void)
+{
+ auto sound = playing_sounds.emplace(playing_sounds.end());
+ sound->setBuffer(buffer);
+ sound->play();
+}
+
+} // namespace audio
diff --git a/src/common.hpp b/src/common.hpp
index 87706c8..846b166 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -25,6 +25,7 @@ along with Minitrem. If not, see <http://www.gnu.org/licenses/>.
#include <sstream>
#include <stack>
#include <SFML/Graphics.hpp>
+#include <SFML/Audio.hpp>
#include "math.hpp"
#define COUNT(A) (sizeof(A) / sizeof((A)[0]))
@@ -377,6 +378,16 @@ namespace render {
};
}
+namespace audio {
+ class sound_t {
+ sf::SoundBuffer buffer;
+
+ public:
+ void load(const char *path);
+ void play(void);
+ };
+}
+
extern render::state_t *debug_render;
// Divide and round to minus infinity.
diff --git a/src/game/assets.cpp b/src/game/assets.cpp
index 1aed662..ef7be9b 100644
--- a/src/game/assets.cpp
+++ b/src/game/assets.cpp
@@ -40,6 +40,8 @@ void load(void)
soldier.legs_walking.load("assets/units/soldier/legs_walking", 2, 2);
soldier.dead.load("assets/units/soldier/dead_", 1);
+ soldier.fire.load("assets/units/soldier/fire.ogg");
+
spider.idle.load("assets/units/spider/idle", 2, 2, 2);
spider.walking.load("assets/units/spider/walking", 2, 2, 2);
spider.dead.load("assets/units/spider/dead_", 1);
diff --git a/src/game/game.hpp b/src/game/game.hpp
index 0143edb..85e3849 100644
--- a/src/game/game.hpp
+++ b/src/game/game.hpp
@@ -54,6 +54,8 @@ namespace game {
render::animated_texture_t body_panic;
render::oriented_sprite_4M2_t legs_idle, legs_walking;
render::animated_texture_t dead;
+
+ audio::sound_t fire;
} soldier_assets_t;
typedef struct {
@@ -194,6 +196,10 @@ namespace game {
die_t hit_die;
} cs;
+ struct {
+ audio::sound_t *attack = NULL;
+ } sounds;
+
bool dead = false;
double death_time = -INFINITY;
int health = 1, max_health = 1;
diff --git a/src/game/units.cpp b/src/game/units.cpp
index d072f20..edb41ec 100644
--- a/src/game/units.cpp
+++ b/src/game/units.cpp
@@ -221,6 +221,9 @@ void unit_t::try_attack(unit_t *target)
size_t hit_roll;
size_t dmg_roll;
+ if (sounds.attack)
+ sounds.attack->play();
+
ss << name << " " << text::get(text::UNIT_ATTACK) << " " << target->name << ": ";
hit_roll = game->roll(die_t(20));
@@ -300,6 +303,8 @@ unit_soldier_t::unit_soldier_t(game::state_t *game) : unit_t(game, UNIT_SOLDIER)
health = max_health = 20;
cs.armor_class = 10;
cs.hit_die = die_t(8);
+
+ sounds.attack = &assets::soldier.fire;
}
void unit_soldier_t::check_area(void)