quick fixes right before presentation, added readme

This commit is contained in:
ottona 2018-11-19 01:07:50 +01:00
parent 73b9141d3b
commit c8b31268ee
15 changed files with 42 additions and 9 deletions

View File

@ -1,2 +1,21 @@
# 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.
## Controls
You'll need a joystick to play the game. The game starts out with no enemies so you can get used to steering the cannons. Joystick button 1 fires, button 2 reloads the guns (15 seconds penalty). Pressing F9 activates the game mode which spawns a plane every 45 secs (so scan your horizon!), F10 quits game mode (same as when 'aircraft remain' is zero), F12 quits the game.
Successfully engaging a plane rewards you with 1000 points plus bonus for the distance (the further out the more points). Relevant info is shown in the top-left corner.
## About the game
The game uses the irrlicht graphics engine for the eye and cAudio for the ear. It's quite of simple complexity and might hence serve as a good example for someone learning about game and/or graphics programming.
About the visual content shown in the game: I did some parts myself (cannon model, crosshairs, terrain), all other stuff is from free content websites.
## 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.
Questions? Reach me at otto@socialnerds.org

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

BIN
res/smoke.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
res/smoke1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -57,7 +57,13 @@ bool Aircraft::evalShot(const irr::core::line3df &shotline)
{
// got hit for the first time: do smokey?
auto pman = Globals::getSceneManager()->addParticleSystemSceneNode(true, model);
pman->getEmitter()->setMinStartSize(dimension2df(80.f, 80.f));
pman->getEmitter()->setMaxStartSize(dimension2df(120.f, 120.f));
pman->getEmitter()->setDirection(vector3df(0.f, 0.f, 0.f));
pman->setMaterialTexture(0, Globals::getVideoDriver()->getTexture("../res/smoke.png"));
pman->setMaterialTexture(1, Globals::getVideoDriver()->getTexture("../res/smoke1.png"));
pman->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
pman->setMaterialFlag(video::EMF_LIGHTING, false);
}
healthy = false;

View File

@ -5,6 +5,7 @@ namespace cAudio
class IAudioSource;
}
//! Sends an aircraft along a line in a given time. Handles hits and smoke - that all
class Aircraft
{
public:

View File

@ -20,7 +20,7 @@ Dispatcher::~Dispatcher()
void Dispatcher::start()
{
lastDispatchMS = Globals::getDevice()->getTimer()->getRealTime();
lastDispatchMS = Globals::getDevice()->getTimer()->getRealTime() - 40000;
active = true;
aircraftsRemaining = 5;
points = 0;
@ -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() * 30000.f)));
aircrafts.push_back(std::make_shared<Aircraft>(l, 30000 + static_cast<u32>(rand->frand() * 15000.f)));
}

View File

@ -3,6 +3,7 @@
#include <irrlicht.h>
//! Spawns aircraft, conducts hit-testing and points counting
class Dispatcher
{
public:

View File

@ -42,7 +42,7 @@ FireUnit::FireUnit()
mflashR->setVisible(false);
fireSound = Globals::getAudioManager()->create("fireSound", "../res/gunburst.wav", false);
screenSize = Globals::getVideoDriver()->getScreenSize();
}
FireUnit::~FireUnit()
@ -143,6 +143,11 @@ void FireUnit::draw()
{
auto drv = Globals::getVideoDriver();
auto& res = drv->getScreenSize();
if (screenSize != res)
{
screenSize = res;
cam->setAspectRatio(static_cast<f32>(res.Width) / static_cast<f32>(res.Height));
}
drv->draw2DImage(crosshair, position2di(res.Width / 2 - 128, res.Height / 2 - 128), recti(0, 0, 256, 256), nullptr, video::SColor(255,255,255,255), true );
@ -182,6 +187,4 @@ void FireUnit::draw()
stripsRemaining = 5;
}
}
//drv->draw3DLine(shotline.start, shotline.end);
//cout << tgt.X << ' ' << tgt.Y << ' ' << tgt.Z << endl;
}

View File

@ -8,6 +8,7 @@ namespace cAudio
class IAudioSource;
}
//! Cannon control, input handling
class FireUnit : public irr::IEventReceiver
{
public:
@ -35,6 +36,7 @@ private:
irr::u32 reloadUntil;
class cAudio::IAudioSource* fireSound;
irr::core::dimension2du screenSize;
};
#endif // FIREUNIT_HPP

View File

@ -42,8 +42,6 @@ FlaSimApp::FlaSimApp()
{
cout << "Joystick support is enabled and " << joystickInfo.size() << " joystick(s) are present." << endl;
}
}
FlaSimApp::~FlaSimApp()

View File

@ -1,5 +1,6 @@
#include "FireUnit.hpp"
//! Main app class
class FlaSimApp : public irr::IEventReceiver
{
public:

View File

@ -10,7 +10,8 @@ Globals* Globals::instance = nullptr;
Globals::Globals()
{
dev = createDevice(video::EDT_OPENGL, core::dimension2du(1600, 900), 32, false, false, true);
dev = createDevice(video::EDT_OPENGL, core::dimension2du(1366, 768), 32, false, false, true);
dev->setResizable(true);
drv = dev->getVideoDriver();
sman = dev->getSceneManager();
dispatcher = new Dispatcher();

View File

@ -24,7 +24,7 @@ namespace irr
}
}
//! Globally used stuff (mostly irrlicht-related) packed in a singleton
class Globals
{
public:

View File

@ -1,5 +1,6 @@
#include <irrlicht.h>
//! Super simple scene node animator that makes the camera look along the cannon
class TurretCamAnimator : public irr::scene::ISceneNodeAnimator
{
public: