Writing a game engine

Started by
116 comments, last by freeworld 12 years, 3 months ago
I was thinking about 3 ways:

1. Use a Factory class that will load all my Bitmaps/Souds/etc. Then use a Painter class that will paint it all.
With this I should need 3 pointers (or objects) -> GameEngine / Factory / Painter.


2. The second way was to use a Singleton with for the GameEngine.
In that GameEngine I allocate 3 pointers ( ResourceLoader / Painter / InputState ) And I use SIngleton for the class GameEngine.
So if the user want to paint something he can receive the Painter pointer trough the GameEngine instance.
example in WinMain:
Painter* pPainter = GameEngine::GetInstance()->GetPainter();
pPainter->DrawText( "Hello there", xPos, yPos );

Here I got an adventage that I only need to make the pointers once.

3. The third way is to use inheritance.
I write 3 classes ResourceLoader / Painter / InputState
And then for the GameEngine: class GameEngine : public ResourceLoader, public Painter, public InputState { }

The adventage of this is that I can do anything with only the GetInstance().



So.. Is one of these ways good enough? Or are there better ones.
Advertisement
Conversations like this always make me cringe. They remind me of my youth when I wanted to do everything that everyone was telling me not to do because they've already done it and have learnt from it. The key is just that, people who tell us not to do it have learnt not to do it themselves - they were probably just as gung ho as these guys asking for advice.

Yes it's probably better to write a game then end up with an engine but this kid has obviously got a lot of passion for learning and creating so let him make his own 'mistakes' - hell, I've been writing a game engine for years and it's my sanctuary from everything else in life. Will it be cryengine 5? Absolutely not but it gives me great enjoyment.

As a lot of the guys have said, your school grades come first so concentrate on using their engine to make your game, but alongside it, why not write your own engine or at least examine theirs and see how yours could be better.

You remind me of me, I'm as successful as I ever imagined I could be (in finance dev i might add) and that's from learning from my own mistakes, not everyone else's. I say grades first, then engine. You might get bored in 3 weeks but find it out for yourself.

Although saying that, it is very useful if you can have some kind of game genre idea in mind that your engine might 'suit' more.

Good luck and let us know how you get on

Added - before I get jumped on, I'm not saying anyone's advice is wrong, just that OP sounds so passionate about it, he's probably going to do it anyway, so perhaps a different bit of guidance would be better...
This is going to sound rude. Do you know what a game engine is? Define it in your own words.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Me or OP?
...we need to make a game for school in a few months. ...
...
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 )...
Perhaps I'm biased towards being lazy (3 hours-day commute for high school, 5-hours day commute for university)... but I think you should save your time. If the framework you got for this game is 700 lines, odds are your professor expects you to do tic-tac-toe or "snake" games. Nothing much than that.
I appreciate your enthusiasm. Really. However, make sure you'll land on the same metric as other students. Get the job done first, then relax. Nothing is even remotely comparable to figure out you won't hit the deadline.

I want to tell you a few stories - the story of the well-written code I have presented to my professors.
  1. A small echo server. Prof: "I'm sorry I cannot give you more than full grade. As a matter of fact, I think nobody else this year will pass this exam." (as a matter of fact, nobody else passed the exam).
    Long story short: wasted effort.
  2. A web-based, interactive 3D presentation system (like 5 years ago). Prof: "I wasn't expecting this. Every major component of this system is an order of magnitude more complex than you'd need for full grade. I'm going to keep this for your thesis".
    Long story short: wasted effort.
  3. Shit in assembler. Prof: "Pretty much the best code I've seen in the last 10 years".
    Long story short: good to hear, but in the end, other people got full grade as well, and I trashed 2 extra days, wasted effort.
  4. An interactive, in-depth analysis of different shading models, with primordial shader mangling system. I'm not going to say what happened there.
    Long story short: wasted effort.

So... make sure you don't do more work than you really need to.

Previously "Krohm"


[quote name='turbello' timestamp='1322887757' post='4890039']...we need to make a game for school in a few months. ...
...
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 )...
Perhaps I'm biased towards being lazy (3 hours-day commute for high school, 5-hours day commute for university)... but I think you should save your time. If the framework you got for this game is 700 lines, odds are your professor expects you to do tic-tac-toe or "snake" games. Nothing much than that.
I appreciate your enthusiasm. Really. However, make sure you'll land on the same metric as other students. Get the job done first, then relax. Nothing is even remotely comparable to figure out you won't hit the deadline.

I want to tell you a few stories - the story of the well-written code I have presented to my professors.
  1. A small echo server. Prof: "I'm sorry I cannot give you more than full grade. As a matter of fact, I think nobody else this year will pass this exam." (as a matter of fact, nobody else passed the exam).
    Long story short: wasted effort.
  2. A web-based, interactive 3D presentation system (like 5 years ago). Prof: "I wasn't expecting this. Every major component of this system is an order of magnitude more complex than you'd need for full grade. I'm going to keep this for your thesis".
    Long story short: wasted effort.
  3. Shit in assembler. Prof: "Pretty much the best code I've seen in the last 10 years".
    Long story short: good to hear, but in the end, other people got full grade as well, and I trashed 2 extra days, wasted effort.
  4. An interactive, in-depth analysis of different shading models, with primordial shader mangling system. I'm not going to say what happened there.
    Long story short: wasted effort.

So... make sure you don't do more work than you really need to.
[/quote]

If you learned anything doing those things then it wasn't wasted effort though, but i'd definitly agree that it is a bad idea to risk missing a deadline due to being overly abitious, if you've allready completed the assignment however it is definitly a good idea to try to take things further if you have time, learning is never a bad thing.
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
@RobMaddison:

Thanks for standing behind me :wink:
And yes I am going to do it.

Last year I learned not to do too much at a time. Normally I would have done networking then but I didn't because then I would fail my game. I am a very good planner and I got a lot of free time now. So now it's the time to learn many new things. But I don't want to learn bad ways of programming so I'm asking for a bit help in the right direction.


@freeworld:

An engine in my words. A (big)piece of code that makes it able to write an application with methods in that engine. Stuff that makes it easier to draw lines, bitmaps, the window.
I would like to avoid to write HDC, PAINTSTRUCT, WNDCLASSEX, etc in my game code. The engine must handle everything.


@Krohm:

Experience is so not a waste. Like networking: I want to use WinSock and not RakNet. Some people said to me " Why would you learn to work with WInsock, you will never use it again later ". I replied " I just want to have the experience. "
My teachers don't expect tic-tac-toe. That is too easy for them. Last year I made a Dragonball Z - Supersonic warrios and I had 17/20. And my game wasn't even the best sadly enough. I want to have the best game this year.



I understand the point that some of you think I won't be able to reach the deadline. But I love to take risks, it makes life so much interesting. if I fail I'll learned my lesson. But I got a great confidence that I will succeed. :rolleyes: Atleast if I get some help.. :wink:

Conversations like this always make me cringe. They remind me of my youth when I wanted to do everything that everyone was telling me not to do because they've already done it and have learnt from it. The key is just that, people who tell us not to do it have learnt not to do it themselves - they were probably just as gung ho as these guys asking for advice.

Yes it's probably better to write a game then end up with an engine but this kid has obviously got a lot of passion for learning and creating so let him make his own 'mistakes' - hell, I've been writing a game engine for years and it's my sanctuary from everything else in life. Will it be cryengine 5? Absolutely not but it gives me great enjoyment.

As a lot of the guys have said, your school grades come first so concentrate on using their engine to make your game, but alongside it, why not write your own engine or at least examine theirs and see how yours could be better.

You remind me of me, I'm as successful as I ever imagined I could be (in finance dev i might add) and that's from learning from my own mistakes, not everyone else's. I say grades first, then engine. You might get bored in 3 weeks but find it out for yourself.

Although saying that, it is very useful if you can have some kind of game genre idea in mind that your engine might 'suit' more.

Good luck and let us know how you get on

Added - before I get jumped on, I'm not saying anyone's advice is wrong, just that OP sounds so passionate about it, he's probably going to do it anyway, so perhaps a different bit of guidance would be better...

A game engine is just a library of code and tools that can be reused on another game. As such, there is no need to 'make' one -- just make a game and re-factor that into an 'engine'. Unless you have experience, you're not likely to be able to correctly wage which parts will be reused later on and so there is no real way for you to make a good engine -- you mash together general tools and code but all that will do is confuse your codebase (since you will try to keep it generalized so you can reuse it, instead of specialized; which would serve the game better and still allow for reusable parts to be picked out later on).

[quote name='Krohm' timestamp='1323163180' post='4891030']
[quote name='turbello' timestamp='1322887757' post='4890039']...we need to make a game for school in a few months. ...
...
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 )...
Perhaps I'm biased towards being lazy (3 hours-day commute for high school, 5-hours day commute for university)... but I think you should save your time. If the framework you got for this game is 700 lines, odds are your professor expects you to do tic-tac-toe or "snake" games. Nothing much than that.
I appreciate your enthusiasm. Really. However, make sure you'll land on the same metric as other students. Get the job done first, then relax. Nothing is even remotely comparable to figure out you won't hit the deadline.

I want to tell you a few stories - the story of the well-written code I have presented to my professors.
  1. A small echo server. Prof: "I'm sorry I cannot give you more than full grade. As a matter of fact, I think nobody else this year will pass this exam." (as a matter of fact, nobody else passed the exam).
    Long story short: wasted effort.
  2. A web-based, interactive 3D presentation system (like 5 years ago). Prof: "I wasn't expecting this. Every major component of this system is an order of magnitude more complex than you'd need for full grade. I'm going to keep this for your thesis".
    Long story short: wasted effort.
  3. Shit in assembler. Prof: "Pretty much the best code I've seen in the last 10 years".
    Long story short: good to hear, but in the end, other people got full grade as well, and I trashed 2 extra days, wasted effort.
  4. An interactive, in-depth analysis of different shading models, with primordial shader mangling system. I'm not going to say what happened there.
    Long story short: wasted effort.

So... make sure you don't do more work than you really need to.
[/quote]

If you learned anything doing those things then it wasn't wasted effort though, but i'd definitly agree that it is a bad idea to risk missing a deadline due to being overly abitious, if you've allready completed the assignment however it is definitly a good idea to try to take things further if you have time, learning is never a bad thing.
[/quote]
Agreed, though I think the lesson here is "do the minimal amount of work for the grade, and do the rest for your own learning experience". Though it always bugged me how easily teachers handed out A+ grades for things that really weren't that complex or time consuming.

I was once given 6+ months to make a (paraphrased quote): "game where you walk around in a 3d environment with no textures and only one primary light source". Well geez teach, that sure seems like a tough nut to crack! biggrin.gif
"I will personally burn everything I've made to the fucking ground if I think I can catch them in the flames."
~ Gabe
"I don't mean to rush you but you are keeping two civilizations waiting!"
~ Cavil, BSG.
"If it's really important to you that other people follow your True Brace Style, it just indicates you're inexperienced. Go find something productive to do."
[size=2]~ Bregma

"Well, you're not alone.


There's a club for people like that. It's called Everybody and we meet at the bar[size=2].

"

[size=2]~

[size=1]Antheus
Look above and you see the last post.

What I want to add:
The ways I have in mind in code.
http://pastebin.com/VUMEjVpC

I understand the point that some of you think I won't be able to reach the deadline. But I love to take risks, it makes life so much interesting. if I fail I'll learned my lesson. But I got a great confidence that I will succeed. :rolleyes: Atleast if I get some help.. :wink:


I really don't get why you would do this. Have you even talked to your teacher about using a self-built engine? In my experience teachers or professors do not appreciate it if you use an alternative to the software they provide, unless explicitly stated otherwise. It takes much more work for them to grade your code since they'll first have to figure out how the software you used functions, and in a lot of cases they will even refuse to grade it because of this

Also, I think you don't quite fully grasp what an engine is and what it's supposed to provide (based on your post describing your framework); as DarklyDreaming said, mashing together a bunch of tools probably won't give you a usable engine. It requires detailed knowledge of what it takes to build an actual game, and last time I checked the only way to getting that knowledge is by, you know, writing games

Going from 'zero' to 'hero' in engine development in a single month is also something that's just absolutely not feasible, a month is a very very very small amount of time when it comes to software development, and if you still have to learn everything along the road (which is always paired with lots of mistakes) you're just setting yourself up for failure

Look, if you want to write an engine that's fine, but wasting 1 month of valuable time which you could spend on actually completing your assignment as dictated by your teacher on quickly mashing a buggy engine together is just irresponsible if you're actually determined on passing
Also don't assume you would get a lot of help on your engine, the general consensus is 'Write games, not engines', and this especially applies to beginners. Adding the aspect of the 1 month timeframe for developing it will make getting help even more difficult

I gets all your texture budgets!

This topic is closed to new replies.

Advertisement