AC_PREREQ([2.60])
-AC_INIT([Yoink], [0.1], [chaz@dogcows.com], [yoink])
+AC_INIT([Yoink], [0.1], [onefriedrice@brokenzipper.com], [yoink])
AC_CANONICAL_TARGET
AC_CHECK_HEADERS([SDL/SDL_image.h],,
[missing="$missing SDL_image"])
-AC_CHECK_HEADERS([SDL/SDL_sound.h],,
- [missing="$missing SDL_sound"])
+AC_CHECK_HEADERS([vorbis/codec.h vorbis/vorbisfile.h],,
+ [missing="$missing libvorbis"])
if test "x$missing" != x
then
# Checks for libraries.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
- [missing="$missing SDL_image"])
-
-AC_SEARCH_LIBS([Sound_Init], [SDL_sound],,
- [missing="$missing SDL_sound"])
-
if test x$WIN32 == xyes
then
# autoconf library search macro doesn't find opengl32 on windows because it uses
# different name hashing, but it links fine; assume it's there
LIBS="$LIBS -lglu32 -lopengl32"
else
- AC_SEARCH_LIBS([gluPerspective], [GLU MesaGLU],,
+ AC_SEARCH_LIBS([gluDisk], [GLU MesaGLU],,
[missing="$missing GLU"])
- AC_SEARCH_LIBS([glBegin], [GL MesaGL],,
+ AC_SEARCH_LIBS([glEnable], [GL MesaGL],,
[missing="$missing OpenGL"])
fi
-AC_SEARCH_LIBS([alGenBuffers], [openal openal32],,
+AC_SEARCH_LIBS([alEnable], [openal openal32],,
[missing="$missing OpenAL"])
AC_SEARCH_LIBS([alutInit], [alut],,
[missing="$missing ALUT"])
+AC_SEARCH_LIBS([IMG_Load], [SDL_image],,
+ [missing="$missing SDL_image"])
+
+AC_SEARCH_LIBS([ov_open], [vorbisfile],,
+ [missing="$missing libvorbis"])
+
AC_SEARCH_LIBS([clock_gettime], [rt],
[AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
[Define to 1 if you have the 'clock_gettime' function.])])
.SH NAME
Yoink \- An alien-smashing action game.
.SH SYNOPSIS
-.B yoink [-h|--help] [-v|--version] [OPTION=VALUE]...
+.B yoink [-h|--help] [OPTION=VALUE]...
.br
.SH DESCRIPTION
.PP
.TP
.B -h, --help
display this help and exit
-.TP
-.B -v, --version
-output version information and exit
.br
.SH TIPS
.PP
edit and save options in-game, any options you have passed as arguments during
the invocation of the game will be saved to the
.I $HOME/.yoinkrc
-configuration file. You may have to go into that file and remove any options
-you didn't intend to set. When passing options as arguments, you must use the
-fully qualified name of the option if it exists in a subgroup. For example:
+configuration file. If this is not what you intended, you may have to go into
+that file and remove any options you didn't intend to set. When passing options
+as arguments, you must use the fully qualified name of the option if it exists
+in a subgroup. For example:
.PP
.TP
yoink video.fullscreen=true
RDEPEND="media-libs/freealut
media-libs/libsdl[opengl]
- media-libs/sdl-image[png]
- media-libs/sdl-sound[vorbis]
+ media-libs/libvorbis
media-libs/openal
+ media-libs/sdl-image[png]
virtual/opengl"
DEPEND="${RDEPEND}
dev-libs/boost
dev-util/pkgconfig"
-RESTRICT="mirror"
-
src_prepare() {
sed -i \
-e "s/-Werror//g" \
BuildRequires: boost-devel
BuildRequires: SDL-devel
BuildRequires: SDL_image-devel
-BuildRequires: SDL_sound-devel
+BuildRequires: libvorbis-devel
BuildRequires: mesa-libGL-devel
BuildRequires: openal-devel
BuildRequires: freealut-devel
Requires: SDL
Requires: SDL_image
-Requires: SDL_sound
+Requires: libvorbis
Requires: openal
Requires: freealut
%description
Mf::Scalar mag = x.length();
Mf::Scalar d = 50.0;
- current.force = -5 * (current.position - Mf::Vector2(500.0, 200.0))
- - 2.0 * current.velocity;
+ current.force = Mf::Vector2(0.0, -2000.0);
+ //current.force += -15.0 * x - 1.5 * current.velocity;
+ current.force += -20.0 * (mag - d) * (x / mag) - 2.0 * current.velocity;
+ current.force += userForce;
current.recalculate();
std::cout << "force: " << current.momentum << std::endl;
{
// really just for heroine...
- Mf::Scalar force = 500.0;
+ Mf::Scalar force = 4000.0;
Mf::Vector2 left = Mf::Vector2(-force, 0.0);
Mf::Vector2 right = Mf::Vector2(force, 0.0);
#include <SDL/SDL.h>
#include "fastevents.h"
-#include <SDL/SDL_sound.h>
#include <AL/alut.h>
#include "Dispatcher.hh"
logError("fast events error: %s", FE_GetError());
throw Exception(Exception::SDL_ERROR);
}
- if (Sound_Init() == 0)
- {
- logError("sound initialization failed: %s", Sound_GetError());
- throw Exception(Exception::SDL_ERROR);
- }
alutInit(&argc, argv);
Settings& settings = Settings::getInstance();
video.reset();
alutExit();
- Sound_Quit();
FE_Quit();
SDL_Quit();
}
*******************************************************************************/
+#include <cstdio>
#include <string>
#include <queue>
#include <vector>
-#include <SDL/SDL.h>
-#include <SDL/SDL_sound.h>
#include <AL/al.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisfile.h>
#include "Log.hh"
#include "Mippleton.hh"
struct Sound::Impl
{
- static ALenum getAudioFormat(const Sound_AudioInfo& audioInfo)
+ static ALenum getAudioFormat(const vorbis_info* audioInfo)
{
- if (audioInfo.format == AUDIO_U8 || audioInfo.format == AUDIO_S8)
- {
- if (audioInfo.channels == 1) return AL_FORMAT_MONO8;
- else return AL_FORMAT_STEREO8;
- }
- else
- {
- if (audioInfo.channels == 1) return AL_FORMAT_MONO16;
- else return AL_FORMAT_STEREO16;
- }
+ if (audioInfo->channels == 1) return AL_FORMAT_MONO16;
+ else return AL_FORMAT_STEREO16;
}
class Buffer;
class Buffer : public Mippleton<Buffer>
{
- Sound_Sample* sound;
+ FILE* soundFile;
+ OggVorbis_File oggStream;
+ ALenum audioFormat;
+ ALsizei audioFreq;
std::vector<ALuint> objects;
public:
Buffer(const std::string& name) :
Mippleton<Buffer>(name),
- sound(0)
+ soundFile(0)
{
openFile();
}
objects.pop_back();
}
- if (sound) Sound_FreeSample(sound);
+ if (soundFile)
+ {
+ ov_clear(&oggStream);
+ }
}
void openFile()
{
- if (sound) Sound_FreeSample(sound);
+ if (soundFile)
+ {
+ ov_clear(&oggStream);
+ soundFile = 0;
+ }
- sound = Sound_NewSampleFromFile(Sound::getPath(getName()).c_str(),
- 0, BUFFER_SIZE);
+ //soundFile = Sound_NewSampleFromFile(soundFile::getPath(getName()).c_str(),
+ //0, BUFFER_SIZE);
+ soundFile = fopen(Sound::getPath(getName()).c_str(), "rb");
- if (!sound)
+ if (!soundFile)
{
- logWarning("error while loading sound %s: %s",
- getName().c_str(), Sound_GetError());
+ logWarning("error while loading sound %s", getName().c_str());
throw Exception(Exception::FILE_NOT_FOUND);
}
- logDebug("buffer size: %d", sound->buffer_size);
- logDebug(" channels: %d", sound->actual.channels);
- logDebug(" format: %d", sound->actual.format);
- logDebug(" frequency: %d", sound->actual.rate);
+ int result = ov_open(soundFile, &oggStream, NULL, 0);
+
+ if (result < 0)
+ {
+ fclose(soundFile);
+ soundFile = 0;
+
+ logWarning("error while loading oggvorbis stream %s",
+ getName().c_str());
+ throw Exception(Exception::BAD_AUDIO_FORMAT);
+ }
+
+ vorbis_info* vorbisInfo = ov_info(&oggStream, -1);
+ audioFormat = getAudioFormat(vorbisInfo);
+ audioFreq = vorbisInfo->rate;
+
+ logDebug(" version: %d", vorbisInfo->version);
+ logDebug(" channels: %d", vorbisInfo->channels);
+ logDebug(" frequency: %d", vorbisInfo->rate);
}
void loadAll(ALuint source)
{
- if (!sound) openFile();
- if (!sound) return;
+ if (!soundFile) openFile();
+ if (!soundFile) return;
+
+ char data[BUFFER_SIZE];
+ int size = 0;
- unsigned decoded = Sound_DecodeAll(sound);
- if (decoded == 0)
+ //unsigned decoded = Sound_DecodeAll(soundFile);
+ for (;;)
+ {
+ int section;
+ int result = ov_read(&oggStream, data + size,
+ BUFFER_SIZE - size, 0, 2, 1, §ion);
+
+ if (result > 0)
+ {
+ size += result;
+ }
+ else
+ {
+ if (result < 0) logWarning("vorbis playback error");
+ break;
+ }
+ }
+ if (size == 0)
{
logWarning("decoded no bytes from %s", getName().c_str());
//throw Exception(Exception::FILE_NOT_FOUND);
ALuint obj;
alGenBuffers(1, &obj);
- alBufferData(obj, getAudioFormat(sound->actual), sound->buffer,
- sound->buffer_size, sound->actual.rate);
+ alBufferData(obj, audioFormat, data, size, audioFreq);
objects.push_back(obj);
alSourcei(source, AL_BUFFER, obj);
- // don't need t his anymore
- Sound_FreeSample(sound);
- sound = 0;
+ // don't need this anymore
+ ov_clear(&oggStream);
+ soundFile = 0;
}
void beginStream(ALuint source, int nBuffers = 4)
{
- if (!sound) openFile();
- if (!sound) return;
+ if (!soundFile) openFile();
+ if (!soundFile) return;
ALuint objs[nBuffers];
alGenBuffers(nBuffers, objs);
// that buffer doesn't belong to us
if (it == objects.end()) return STREAM_WRONG;
- unsigned bytes = Sound_Decode(sound);
+ char data[BUFFER_SIZE];
+ int size = 0;
+
+ //unsigned bytes = Sound_Decode(soundFile);
+ while (size < BUFFER_SIZE)
+ {
+ int section;
+ int result = ov_read(&oggStream, data + size,
+ BUFFER_SIZE - size, 0, 2, 1, §ion);
+
+ if (result > 0)
+ {
+ size += result;
+ }
+ else
+ {
+ if (result < 0) logWarning("vorbis playback error");
+ break;
+ }
+ }
- if (bytes == 0) return STREAM_EOF;
+ if (size == 0) return STREAM_EOF;
- alBufferData(buffer, getAudioFormat(sound->actual), sound->buffer,
- bytes, sound->actual.rate);
+ alBufferData(buffer, audioFormat, data, size, audioFreq);
return STREAM_OK;
}
inline void rewind()
{
- if (!sound) openFile();
- else Sound_Rewind(sound);
+ if (!soundFile) openFile();
+ else ov_raw_seek(&oggStream, 0);
}
YoinkApp::YoinkApp(int argc, char* argv[]) :
Mf::Engine(argc, argv, configFiles(), PACKAGE_STRING, iconFile()),
- music("BeatTheCube"),
+ music("NightFusionIntro"),
punchSound("RobotPunch")
{
Mf::dispatcher::addHandler("video.context_recreated",
void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
{
- dt *= 0.7;
+ //dt *= 0.7;
music.update(t, dt);
fadeIn.update(dt);