cAudio now submodule, some minifixes, updated readme

This commit is contained in:
ottona 2021-08-05 16:00:19 +02:00
parent 825992c2b0
commit 6a85967fff
11 changed files with 50 additions and 12 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "ext/cAudio"]
path = ext/cAudio
url = https://github.com/R4stl1n/cAudio.git

View File

@ -1,6 +1,6 @@
# flasim # flasim
FlaSim is a mini game I did as a birthday party gag. It lets you manually control an anti-aircraft cannon with your joystick. Five jets are then randomly spawned (one after the other) as targets to be engaged by the player. FlaSim is a mini game I did as a birthday party gag. It lets you manually control an anti-aircraft cannon with your joystick. Five jets are then randomly spawned (one after the other) as targets to be engaged by the player. There is a [blog post](https://polylux.eu/blog/4/) about the implementation aspects of the game.
## Controls ## Controls
@ -15,7 +15,19 @@ About the visual content shown in the game: I did some parts myself (cannon mode
## Building flasim ## Building flasim
Currently only Linux works, should have a windows buildability in a couple of days. Currently only Linux works, should have a windows buildability in a couple of days.
The game is written in QtCreator and hence uses the qmake build system. You should have gcc, qmake, irrlicht and cAudio installed and handy. The game is written in QtCreator and hence uses the qmake build system. You should have gcc, qmake, irrlicht and OpenAL installed and handy.
cd to the 'prj' folder and run qmake to get a Makefile out of flasim.pro. Build the game using 'make'. Done.
### Prerequirements
1. Fetch the submodules.
1. `cd` into `ext/cAudio` and issue `cmake -DCAUDIO_BUILD_EAX_PLUGIN=ON -DCAUDIO_BUILD_MP3DECODER_PLUGIN=OFF -DCAUDIO_ENABLE_OGG=OFF -DCAUDIO_BUILD_SAMPLES=OFF -DCAUDIO_DEPENDENCIES_DIR=Dependencies64 -DCAUDIO_STATIC=ON`
1. `make` cAudio
### Build flasim
`cd` to the `prj` folder and run qmake to get a Makefile out of `flasim.pro`. Build the game using `make`. Done.
Questions? Reach me at otto@socialnerds.org Questions? Reach me at otto@socialnerds.org

1
ext/cAudio Submodule

@ -0,0 +1 @@
Subproject commit ce5d03905a01c89c8d64dea9c3aa1cf63647d794

View File

@ -6,9 +6,10 @@ Debug:TARGET = flasimD
TEMPLATE = app TEMPLATE = app
unix:INCLUDEPATH += /usr/include/irrlicht unix:INCLUDEPATH += /usr/include/irrlicht
win32:INCLUDEPATH += ../pharus/external/irrlicht INCLUDEPATH += ../ext/cAudio/cAudio/include ../ext/cAudio/include
unix:LIBS += -lIrrlicht -lcAudio unix:LIBS += -L../ext/cAudio/cAudio
unix:LIBS += -lIrrlicht -lopenal -lcAudio
DESTDIR = ../bin DESTDIR = ../bin

View File

@ -1,7 +1,7 @@
#include "Aircraft.hpp" #include "Aircraft.hpp"
#include <iostream> #include <iostream>
#include <cAudio/cAudio.h> #include <cAudio.h>
#include "Globals.hpp" #include "Globals.hpp"

View File

@ -72,7 +72,7 @@ const Dispatcher::Aircrafts &Dispatcher::getAircrafts() const
bool Dispatcher::evalShot(const core::line3df& l) bool Dispatcher::evalShot(const core::line3df& l)
{ {
bool ret = false; bool ret = false;
for (auto a : aircrafts) for (auto& a : aircrafts)
{ {
if (a->isGood() && a->evalShot(l)) if (a->isGood() && a->evalShot(l))
{ {
@ -112,5 +112,5 @@ void Dispatcher::dispatchAircraft()
line3df l; line3df l;
l.start = vector3df(start.X, alt, start.Y); l.start = vector3df(start.X, alt, start.Y);
l.end = vector3df(end.X, alt, end.Y); l.end = vector3df(end.X, alt, end.Y);
aircrafts.push_back(std::make_shared<Aircraft>(l, 30000 + static_cast<u32>(rand->frand() * 15000.f))); aircrafts.push_back(std::make_unique<Aircraft>(l, 30000 + static_cast<u32>(rand->frand() * 15000.f)));
} }

View File

@ -7,7 +7,7 @@
class Dispatcher class Dispatcher
{ {
public: public:
typedef std::vector< std::shared_ptr<class Aircraft> > Aircrafts; typedef std::vector< std::unique_ptr<class Aircraft> > Aircrafts;
Dispatcher(); Dispatcher();
~Dispatcher(); ~Dispatcher();

View File

@ -1,7 +1,7 @@
#include "FireUnit.hpp" #include "FireUnit.hpp"
#include <iostream> #include <iostream>
#include <cAudio/cAudio.h> #include <cAudio.h>
#include "Globals.hpp" #include "Globals.hpp"
#include "Dispatcher.hpp" #include "Dispatcher.hpp"

View File

@ -64,7 +64,7 @@ void FlaSimApp::execute()
bool FlaSimApp::OnEvent(const irr::SEvent &e) bool FlaSimApp::OnEvent(const irr::SEvent &e)
{ {
if (e.EventType == EET_KEY_INPUT_EVENT) if (e.EventType == EET_KEY_INPUT_EVENT && e.KeyInput.PressedDown)
{ {
if (e.KeyInput.Key == KEY_F12) if (e.KeyInput.Key == KEY_F12)
{ {
@ -81,7 +81,14 @@ bool FlaSimApp::OnEvent(const irr::SEvent &e)
Globals::getDispatcher()->stop(); Globals::getDispatcher()->stop();
return true; return true;
} }
if (e.KeyInput.Key == KEY_KEY_T)
{
saveScreenshot();
return true;
}
} }
// if we reach here, relay event to the fireunit
return fireUnit.OnEvent(e); return fireUnit.OnEvent(e);
} }
@ -112,3 +119,16 @@ void FlaSimApp::drawScreenSpace()
info += L"\nPOINTS: "; info += Globals::getDispatcher()->getPoints(); info += L"\nPOINTS: "; info += Globals::getDispatcher()->getPoints();
Globals::getFont()->draw(info, core::recti(10, 10, 100, 100), video::SColor(255, 255, 255, 255)); Globals::getFont()->draw(info, core::recti(10, 10, 100, 100), video::SColor(255, 255, 255, 255));
} }
void FlaSimApp::saveScreenshot()
{
video::IImage* scrn = nullptr;
core::stringc fname = "";
fname += dev->getTimer()->getRealTime();
io::path filename = fname.c_str();
filename += ".png";
scrn = drv->createScreenShot();
drv->writeImageToFile(scrn, filename);
scrn->drop();
}

View File

@ -13,6 +13,7 @@ public:
private: private:
void drawScreenSpace(); void drawScreenSpace();
void saveScreenshot();
irr::IrrlichtDevice *dev; irr::IrrlichtDevice *dev;
irr::scene::ISceneManager *sman; irr::scene::ISceneManager *sman;

View File

@ -2,7 +2,7 @@
#include "Dispatcher.hpp" #include "Dispatcher.hpp"
#include <irrlicht.h> #include <irrlicht.h>
#include <cAudio/cAudio.h> #include <cAudio.h>
using namespace irr; using namespace irr;