• Advertisement
Sign in to follow this  

Writing a game engine

This topic is 2312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

I'm studying C++ for 1 year now and we need to make a game for school in a few months. We received a game engine for our game from school but I don't like that engine so I want to write my own engine.
Last year I made many projects how to make windows, how to paint lines, how to draw bitmaps, without an engine. And now, I think, I got the basics of everything for writing a game engine.

So I've started with writing and I got some questions about it,

I let the user write their " int WINAPI WinMain(...) {...} " and they include my engine to that project. So my engine got a method Startup and Shutdown. Is this smart to do?
To let the user use those 2 methods he need to ask the GameEngine instance first. I made my GameEngine object on the stack so I don't need to create/delete it. So in 1 method I send it to the user. ( GetInstance(); )
That method is static so the user can use all my other public methods from the GameEngine. Still I don't know if this is a good way to write an engine.. I could use some opinions / better options.

And last, I don't know what to use. Shall I make a Painter class that will paint all my stuff ( text, bitmaps, etc ), or shall I make all my objects independent and make it able that they can paint their self. ( Image1.Paint(); )

Have any of you got some experience with writing a game engine? So yes, am I going in the right direction?


Kind regards,
Jonathan

Share this post


Link to post
Share on other sites
Advertisement
With the engine we received we can only play sounds, draw bitmaps and draw text. Not that much. And I have done all those things in personal projects last year.
And to be honest, I agree with you that my engine will be a lot worse then the engine I have now. But I love to experience with stuff. :-)

I want to have the feeling with this game that -> I <- made it all on my own. Well... the game I "write" is Warcraft2 ( we don't need to be original and create our own game ).

But back to the point, I got an engine of school, so I have an example of an engine. With books, tutorials and forums I'll be able to write an engine in a month. ( I'm guessing a bit )
My engine just need some small extra features. But it will do almost the same as the engine now.

You can say: " why would you write an engine that can do all the stuff you can do with the engine you already have ".
Well: I just want the experience. :-)


Suppose I don't want follow the direction straight back. My game needs to be finished around month June. I think I can do this, but for that I need some help of how I should write my code. Please help me, I want to prove I can do this. :-)


B. Jonathan

Share this post


Link to post
Share on other sites
I'll be able to write an engine in a month.


Trust me, you won't
This is not meant to be rude or anything, but engines are really complex beasts, even when they only have very simple features

Writing different features like drawing something on screen, playing some sounds, etc. can be done rather primitively in a rather short amount of time (note that I'm saying primitively as in not bug-free or stable at all); add these up and you'll already be a couple of weeks in just by writing primitive and buggy features. Throwing all these features together does not give you an engine, an engine should be able to support a variety of projects and should give a developer some freedom in what they want to design, so your engine needs to be able to support that freedom without throwing errors at the developer all the time

To make sure an engine actually works requires a vast amount of debugging and will require you to write countless test cases to cover each aspect of the features your engine supports
So all in all, saying that you can write a good, bug-free and working engine in a month's time with 1 year of C++ experience is quite ridiculous

Share this post


Link to post
Share on other sites
Teachers can react very sensitve to the word "engine", because whatever you can write in 1 month or 6 months, it's not going to be an "engine".

Just write the game. Write reusable code. Those will be your first building blocks for your own "engine" (for the next project).

Have you watched Creating Prelude of the Chambered? At no point of time I saw Notch writing an "engine" there.

Ps: Just speaking out of experience.

Share this post


Link to post
Share on other sites
If you don't yet know what way you'll write the engine, and if you have to come online asking for advice on basic structure for it, that should be sending you a pretty clear warning signal.

Share this post


Link to post
Share on other sites
Writing an engine to write a game is foolhardy at best -- what criteria is lacking in other engines that yours fulfills? Of course, that is not meant to be an insult -- but rarely do you need to roll your own if all you want to do is make a good game.

Writing a game and ending up with an engine is a much more acceptable scenario. But really, what is more important to you -- making this engine or making the game? Because splitting your priorities, especially at this stage, is a very very stupid thing to do -- choose something available and get going if you want that game made; if you want to just make an engine, make the game and scrutinize re-usable parts. There. That's your "engine".

Best of luck! :)

Share this post


Link to post
Share on other sites
Out of curiosity, why don't you like the engine you got from school?

Also, I agree with the comments. Writing an engine is not an easy task. I suggest you focus on the game and use what has been given to you. You say you can write an engine in one month and finish the game in the remaining months... let's assume for a moment that it's an accurate time estimate. That's one extra month you can use for making the game shine. IMO having a polished game will cause a bigger wow factor than having your own engine.

It's also good practice for you if you break in to the industry. Unless you become an engine programmer, you will be using an engine written by another team (or company altogether). Even if you are an engine programmer, you probably won't be writing all the code yourself and will have to deal with code from other developers.

So again, what is wrong with the engine you got from school?

Share this post


Link to post
Share on other sites
Do you get the provided engine's source code?
If so I would write your game with that and find ways to extend the provided functionality as needed by modifying the engine.

There is no shame is saving time by using what is available. You can just spend your time focusing on more interesting aspects of the game.

I like your ambition. Make something cool. biggrin.gif

Share this post


Link to post
Share on other sites
Thanks for all those replies.


Ok, so the engine I received last year is more a 'sort-of-engine'. I have the source code of it ( around 600-700 lines of code )
Last year I searched whole the engine out and looked up for every function that was in there. I even looked up Multi-threading and used that in my game last year.

I am some of the 200 students that is studying more C++ after school. C++ was new to me last year. And the things I learned ( last school year ) are:
- keyword inline
- how to make a Singleton. ( GetInstance() )
- The basics of multi-threading
- How to make a window.
- How to draw lines and bitmaps in that window.
- How to react on events ( mouse / keybord )
- Added an Xbox controller to my computer and wrote the code for it so I can play my game with the controller.

That doens't seem much. But I learned that all after school and I am happy with it :rolleyes:

This school year I want to do;
- write a sort-of-engine -> I just want to write my game with it. This year I use that 'engine' only for myself. No one else will use it now.
- Learn networking and implement it in the 'engine'

I already made a LAN-connection last weekend for networking ( connection via router ).



Maybe the word 'engine' was a bit too much. So if I change that word into 'sort-of-engine'.. I only was to use it for myself. I just need to be able to write a game in it.
After this school year I got 2months vacation so then I'll try so change/improve that 'sort-of-engine'.
I think I'll be able to manage it. And I know how to write an engine by the way. But the are lots of ways and I want to use a good one.



The 'engine' I got from school I don't like because:
- it don't have any performance at all / terrible names for datatypes ( maybe because we need to understand it )
example in header:
Code I use: Object* m_pObject;
Code the 'engine' have: Object* m_MyObjectPtr;
- The WinMain we never wrote because this was already implemented in the engine. Almost no one of my class knows how WinMain works.

These are the 2 things I don't like. I know the priority is to make the game. But I want to do more.. I am already 3weeks ahead with the lessons.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement