I've been studing C++ for about a year now. (Steve Hellers book)
I've learned enough to start putting together my first game. (a 3d chat room)
I apply the things I learn from the book, to what I need in my game, but run into problems attempting to switch from "coding from scratch" to using an already made lib. I use Irrlicht for the graphics. (and currently for the collision as well)
I have my map done, lit, textured, and ready to go. I've made my main.cpp and compiled it. It looks great, movement is good, and so on. Problem is, I still have to add a proper collision and networking lib to this, and my main.cpp is getting quite large and hard to read.
What I want to do is to break up what I have into seperate cpp files.
IE:
main.cpp //game init, etc...
Game.cpp //map files, doors, elevators, etc...
Collision.cpp //apply all the collision here
Network.cpp // etc...
Sound.cpp // well, you get the hint
My goal is to make this simple enough to expand as I need to. I want to expand on my little chatroom later down the road, but the current state of my main.cpp is just getting out of hand.
All the tutorials, books, and other peoples code that I've looked at, seem to me like "reenventing the wheel".
I don't want to rewrite the sound engine so that my main will look just like it does now.
An example of adding audiere sound to an environment:
#include "audiere.h"
using namespace audiere;
//initialize audio
AudioDevicePtr audiereDevice;
OutputStreamPtr stream;
audiereDevice = OpenDevice();
if (!audiereDevice)
return 1;
stream = OpenSound(audiereDevice.get(), "YOURSOUNDFILE.wav", true);
if (!stream)
return 2;
stream->setRepeat(true);
stream->setVolume(0.15f); // 15% volume
stream->play();
How could I take this and put it in it's own class so that I can just call it in my main.cpp?
(this file would have all the different sounds listed by name, such as:
stream1=OpenSound(audiereDevice.get(), "YOURSOUNDFILE1.wav", true);
stream2=OpenSound(audiereDevice.get(), "YOURSOUNDFILE2.wav", true);
etc.....
I don't want to rewrite audiere. I just want to be able to use it in my program by calling it's name. I just don't know how, and all attempts I've made just fail.
Can anyone give me some pointers?
I know this has been a long post, I do appreciate your reading, I just wanted to make sure to get my point across as to what I needed.