Browse Source

cAudio now submodule, some minifixes, updated readme

master
Otto Naderer 3 months ago
parent
commit
6a85967fff
  1. 3
      .gitmodules
  2. 18
      README.md
  3. 1
      ext/cAudio
  4. 5
      prj/flasim.pro
  5. 2
      src/Aircraft.cpp
  6. 4
      src/Dispatcher.cpp
  7. 2
      src/Dispatcher.hpp
  8. 2
      src/FireUnit.cpp
  9. 22
      src/FlaSimApp.cpp
  10. 1
      src/FlaSimApp.hpp
  11. 2
      src/Globals.cpp

3
.gitmodules

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

18
README.md

@ -1,6 +1,6 @@
# 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
@ -15,7 +15,19 @@ About the visual content shown in the game: I did some parts myself (cannon mode
## Building flasim
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.
cd to the 'prj' folder and run qmake to get a Makefile out of flasim.pro. Build the game using 'make'. Done.
The game is written in QtCreator and hence uses the qmake build system. You should have gcc, qmake, irrlicht and OpenAL installed and handy.
### 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

1
ext/cAudio

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

5
prj/flasim.pro

@ -6,9 +6,10 @@ Debug:TARGET = flasimD
TEMPLATE = app
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

2
src/Aircraft.cpp

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

4
src/Dispatcher.cpp

@ -72,7 +72,7 @@ const Dispatcher::Aircrafts &Dispatcher::getAircrafts() const
bool Dispatcher::evalShot(const core::line3df& l)
{
bool ret = false;
for (auto a : aircrafts)
for (auto& a : aircrafts)
{
if (a->isGood() && a->evalShot(l))
{
@ -112,5 +112,5 @@ void Dispatcher::dispatchAircraft()
line3df l;
l.start = vector3df(start.X, alt, start.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)));
}

2
src/Dispatcher.hpp

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

2
src/FireUnit.cpp

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

22
src/FlaSimApp.cpp

@ -64,7 +64,7 @@ void FlaSimApp::execute()
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)
{
@ -81,7 +81,14 @@ bool FlaSimApp::OnEvent(const irr::SEvent &e)
Globals::getDispatcher()->stop();
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);
}
@ -112,3 +119,16 @@ void FlaSimApp::drawScreenSpace()
info += L"\nPOINTS: "; info += Globals::getDispatcher()->getPoints();
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();
}

1
src/FlaSimApp.hpp

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

2
src/Globals.cpp

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

Loading…
Cancel
Save