Writing a game engine

Started by
116 comments, last by freeworld 12 years, 3 months ago
I guess you might be able to pull out doing both game engine and the game on top in given time, which in my opinion isn't few months when its 7-8 months. From the previous posts I got the idea, that your project must be completed like somewhere around February or something, which obviously isn't a long time. I still think in general it would be good habit to learn to use, what you're given. Anyways I wish you a good luck on your project.
Advertisement
Well my engine can do a bit more now then the given engine. ( I'm not trying to show off now )

Except the given engine got buttons & textboxes but I don't want to have them. ( They are ugly )
I'm using images for 'Buttons'. If the image looks like a button and you can press it: it is a button.

And I'm using threads for my networking to receive information of the 2 players without any lag. I did some changes to my Image class so I can copy the image. This will save me a lot of time. ( an other possibility is making a static Image )

My engine is almost finished for the stuff I want to do. A student said to me to implement xinput, xml, databases, matrices, videos, Direct2D, joystick, lvl editor, etc.
I'm not going to do any of these because this would take a lot of time to implement all of this.
But I might want to implement the possibility to play videos. Always nice to show the intro movie. :)


Kyall, I'll put all code I don't need out the engine when I'm writing the game then. It's saves a lot of time when debugging yes. :)

My engine is almost finished for the stuff I want to do. A student said to me to implement xinput, xml, databases, matrices, videos, Direct2D, joystick, lvl editor, etc.


xinput: not really
xml: not really
databases: not really
matrices: hell yeah
videos: if necessary
Direct2D: will give a big improvement on performance over Win32, if your game is chugging in Win32, make sure you're not wasting resources with offscreen drawing, then if still slow swap to direct2D. I think direct2D is pretty easy to set up and use.
joystick: not really
lvl editor: NO WAY IN HELL

A level editor is can be a massive undertaking and a huge drain on your resources, for your game you should be able to achieve what you want for level editing if you give yourself a free camera and a grid, use the free camera to view your level, and use your grid to see what you need to move. Your grid should have a legend that is visible no matter where you move, like A1, A3, B2, B8 etc. Use a note pad to take notes so you can edit as much stuff that needs editing per pass as possible. Also a tip about making games in general: consistent scale and grids, if you had a level editor, you would use consistent scale and grids anyway.

How ever if you're going to be working with level designers, I'd recommend doing some tools and export scripts for an already popular editing tool that can export the data in a fashion that is usable for the game like blender or 3ds max or something.
I say Code! You say Build! Code! Build! Code! Build! Can I get a woop-woop? Woop! Woop!
Well I think I want to implement videos.
I'll add math when my game is finished. Warcraft 2 don't need physics so I don't need math now.

And so I've been trying to add videos to my engine but I miss something.
I wrote all the code, I can load a video ( I only can't receive the resolution of the video, I don't know how to do that ),
And when I try to play the video I can hear the sounds but no video.. :unsure: The position of the video is x=0 y=0.
This is the message I get:
25yvl3s.jpg


When look how big the resolution was and changed those variables manual. Maybe that's the problem?
How can I receive the width and the height of a video. Using mciSendString(...);

I'm controlling my sounds and videos with mciSendString so I'm not using external library's.


B. Jonathan
I understand that you like to take some risks, as that is how most programmers learn, but I am going to tell you what everyone else has said; you can not do it. I do not mean to be rude, or discourage you in anyway, but building a game engine takes an unbelievable amount of development time to get anything usable. I recommend that you bite your pride and use the schools engine, as it is more than likely tried and true. It has more than likely been recoded and added to many times, and is probably stable.

I'll be able to write an engine in a month[/quote]
The first game engine I wrote took me 3 years of development, and this was while I was building the game that used it. At that point I had 6+ years of C++ and 3 years of Assembly based programming. As I said before; I am not trying to be rude, but you can not write one in a month.

EDIT: If you are really mind set on building your own game engine, I can offer some advice. First off know what the engine has to do specifically. This requires that you build the engine with your game. Because of your time deadline, I would not recommend using anything fancy (by fancy I mean techniques such as Singleton patterns (which are great, but can cause hurt)). Only implement what is required for by the game. A quick glance at your design looks like it will work for a small project.

math when my game is finished[/quote]
Depending on what kind of game you are building, this is going to be needed first. I do not recommend writing your own math library with your time constraint. Use open-source, or pull from the DirectX libraries.

A level editor is can be a massive undertaking and a huge drain on your resources[/quote]
As someone else stated; do not even try it. Game engine tools are a massive undertaking, in part because they require a working game engine. I have heard of people using a modeling package such as Blender or 3DS MAX for level design. This is the route you should take.

As far as your video problem goes, I am not sure what you are using, but I can take a stab based on the error message. It is saying that it can not find the decompresser. This usually means that your code is wrong, or something is missing such as a (.dll) file, or an extension that the code is trying to call.
I already told that I can do more then the provided engine we got from school. You are taking the words 'game engine' to big.

The provided engine can not go fullscreen, can't mirror/scale images, can't play videos, don't have any math, don't have any multi-threading.
I got all the things that engine got + fullscreen + scaling/mirroring + multi-threading.

I'm now trying to implement videos in it. My Game Engine is very very basic. But it is more then the provided one which was even more basic.
So it would be nice to help me with my previous question instead of telling me what I already heard many times in the past 2 weeks. :)


Edit: don't worry about that level editor. If I do that I know i'll fail for my game.
About that code for the video.

// Open the video
if (end == _T(".avi"))
{
sendString << tstring(_T("open \"")) + path + "\" type avivideo alias " + m_Alias + _T(" parent ");
sendString << (int)m_hWnd;
// This won't add a new window
sendString << _T(" style ");
sendString << 0x40000000;
}

// Set the time format
sendString.str(_T(""));
sendString << tstring("set ") + m_Alias + " time format ms";
mciSendString(sendString.str().c_str(), 0, 0, 0);

// Receive duration of video
sendString.str(_T(""));
sendString << tstring("status ") + m_Alias + " length";
mciSendString(sendString.str().c_str(), buffer, 100, 0);

sendString.str(_T(""));
sendString << buffer;
sendString >> m_iDuration; // hold the duration


// Showing the video
tstringstream buf;
buf << _T("put ") + m_Alias + _T(" window at ");
buf << m_PosX;
buf << _T(" ");
buf << m_PosY;
buf << _T(" ");
buf << m_iWidth; // I didn't calculated the width because I don't know how, so Just entered a number .. Someone know how to get the width of the video?
buf << _T(" ");
buf << m_iHeight; // The same like the width
m_CommandQueue.push( buf.str() );



// Play method
void Video::Play()
{
if( m_bPlaying == false )
{
m_bPlaying = true;
m_bPaused = false;

tstringstream buf;
buf << _T("play ") + m_Alias + _T(" from ");
buf << 0;
buf << _T(" notify");
m_CommandQueue.push( buf.str() );
}
else if( m_bPaused )
{
m_bPaused = false;
m_CommandQueue.push( _T("resume ") + m_Alias );
}
}


// Tick method
void Video::Tick()
{
if( !m_CommandQueue.empty() )
{
mciSendString( m_CommandQueue.front().c_str() , 0, 0, 0 );
m_CommandQueue.pop();
}

if( m_bPaused == false && m_bPlaying == true )
{
++m_iCounter;
if( m_iCounter*10 >= m_iDuration ) // When the video is done, replay?
{
m_bPlaying = false;

if( m_bRepeat == true ) Play();
m_iCounter = 0;
}
}
}


EDIT::
Well this is odd. The extension of the video is (.avi) which I want to give an 'avivideo alias'. This is not working.

BUT If I give to that same .avi video an mpegvideo alias it works !!! :blink: This is strange, really strange :blink:


B Jonathan

if (end == _T(".avi"))
{
sendString << tstring(_T("open \"")) + path + "\" type avivideo alias " + m_Alias + _T(" parent ");
sendString << (int)m_hWnd;
// This won't add a new window
sendString << _T(" style ");
sendString << 0x40000000;
}
[/quote]

What are you trying to do there? What is sendString, is it just a char buffer? while do you fill it with

open \"C:\MyVideos\" type avivideo alias ".avi parent
[/quote]

That's assuming, path is a string equaling "C:\MyVideos" and m_Alias is a string ".avi"

Then continue to pump it full of

open \"C:\MyVideos\" type avivideo alias ".avi parent 0xFA3C56C style 0x40000000
[/quote]

Some explanation of what your variables actually are might help.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
sendString is a: stringstream sendstring;
And I fill it with this: "open \"Video1.avi\" type avivideo alias video1 parent (int)hWnd style 0x40000000"
So I give the type,alias,parent and style of the video when I open the video.

- Each times I do 'new Video(..) I increase a static number. My alias of the video I'm allocating at that moment is the path + that static number. So each time I create a new video I'll have as alias: video1, video2, video3, etc.

- My type depends on the extension. If it's .avi = avivideo, if it's .mpeg = mpegvideo, etc

- Wen I tried without that style "0x40000000" I always got a new window for the video, what I don't want. And my teacher said I could use that code so there won't be made a new window. With our without it, it don't solve that strange alias problem.

I can't write it in 1 line. Video is a class and I need to be able to allocate a few videos.
Video* m_pVideo1;
Video* m_pVideo2;

m_pVideo1 = new Video( "path1.avi" );
m_pVideo2 = new Video( "path2.mpeg" );


So I need to open, play, stop, repeat some videos that has a different path, alias.
But it's very strange that my .avi don't want to accept a .avivideo type. I'll try to use as type: .avi, .mpeg without that 'video' at the end.


B. Jonathan

I can't write it in 1 line. Video is a class and I need to be able to allocate a few videos.
Video* m_pVideo1;
Video* m_pVideo2;

m_pVideo1 = new Video( "path1.avi" );
m_pVideo2 = new Video( "path2.mpeg" );



Video fooVideo("barVideo.avi")

There it's on one line, and doesn't have to use pointers.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.

This topic is closed to new replies.

Advertisement