Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Writing a game engine


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
117 replies to this topic

#1 turbello   Members   -  Reputation: 115

Like
1Likes
Like

Posted 02 December 2011 - 10:49 PM

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

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14196

Like
6Likes
Like

Posted 03 December 2011 - 01:43 AM

You have a deadline of a few months and have only been studying for 1 year. There is a very small chance that you would be able to write a “better” game engine with the same features as theirs plus the actual game on top of it.

Additionally, the chances are absolute that your engine will not be better than theirs. That is not an insult, but a fact. Everyone makes a crappy engine the first time.
Engines are all I make and my first one, with 8 years of C++ experience and 3 or 4 of professional game-development experience (and 5 or 4 prior years of hobby game programming) at the time, was crappy.


The right direction to go is straight back to the folder containing the engine they gave you.
Save engine programming for hobby time. Not for the graded deadline time.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 turbello   Members   -  Reputation: 115

Like
1Likes
Like

Posted 03 December 2011 - 05:04 AM

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

#4 Radikalizm   Crossbones+   -  Reputation: 2973

Like
3Likes
Like

Posted 03 December 2011 - 05:50 AM

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

I gets all your texture budgets!


#5 froop   Members   -  Reputation: 636

Like
2Likes
Like

Posted 03 December 2011 - 07:30 AM

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.

#6 mhagain   Crossbones+   -  Reputation: 8269

Like
1Likes
Like

Posted 03 December 2011 - 08:18 AM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#7 DarklyDreaming   Members   -  Reputation: 366

Like
0Likes
Like

Posted 03 December 2011 - 08:28 AM

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! :)
"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."
~ Bregma

"Well, you're not alone.

There's a club for people like that. It's called Everybody and we meet at the bar."

~ Antheus


#8 gsamour   Members   -  Reputation: 140

Like
1Likes
Like

Posted 03 December 2011 - 09:57 AM

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?

#9 HappyCoder   Members   -  Reputation: 2872

Like
0Likes
Like

Posted 05 December 2011 - 04:28 PM

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. Posted Image

#10 turbello   Members   -  Reputation: 115

Like
0Likes
Like

Posted 05 December 2011 - 11:30 PM

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.

#11 turbello   Members   -  Reputation: 115

Like
0Likes
Like

Posted 05 December 2011 - 11:40 PM

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.

#12 RobMaddison   Members   -  Reputation: 769

Like
0Likes
Like

Posted 06 December 2011 - 02:45 AM

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...

#13 freeworld   Members   -  Reputation: 329

Like
0Likes
Like

Posted 06 December 2011 - 02:53 AM

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.

#14 RobMaddison   Members   -  Reputation: 769

Like
0Likes
Like

Posted 06 December 2011 - 03:18 AM

Me or OP?

#15 Krohm   Crossbones+   -  Reputation: 3238

Like
0Likes
Like

Posted 06 December 2011 - 03:19 AM

...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.
  • 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.
  • 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.
  • 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.
  • 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.

Edited by Krohm, 06 December 2011 - 03:20 AM.


#16 SimonForsman   Crossbones+   -  Reputation: 6288

Like
0Likes
Like

Posted 06 December 2011 - 03:41 AM

...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.
  • 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.
  • 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.
  • 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.
  • 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.


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.
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!

#17 turbello   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 December 2011 - 04:24 AM

@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:

#18 DarklyDreaming   Members   -  Reputation: 366

Like
0Likes
Like

Posted 06 December 2011 - 04:26 AM

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).


...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.
  • 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.
  • 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.
  • 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.
  • 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.


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.

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! Posted Image
"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."
~ Bregma

"Well, you're not alone.

There's a club for people like that. It's called Everybody and we meet at the bar."

~ Antheus


#19 turbello   Members   -  Reputation: 115

Like
0Likes
Like

Posted 06 December 2011 - 04:44 AM

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

#20 Radikalizm   Crossbones+   -  Reputation: 2973

Like
2Likes
Like

Posted 06 December 2011 - 04:52 AM

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!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS