Tutorial for making your own 2D Game Engine

Started by
8 comments, last by LuanLebarch 12 years, 4 months ago
I'd like to know where there is a place on the net, or a book I could purchase that would guide you in the steps of setting up your project in Visual C++ or any other IDE that would teach you how to make your own 2d Game engine. I guess sorta seeing how you link library's and API's together you would just create a .dll project and have many classes that are all extern functions, and classes, and I guess abstract as well... see why I need a tutorial? I could build it that's for sure. There's just a couple of vocabulary, rules, and specific steps that I'm missing on building one myself. If you'd like to know what languages, IDE/compilers, API's and libraries I'm using here it is. Language: C++ Library's: SDL + OpenGL Purpose: Ease the creation of creating 2d Arcade games. Game Engine hierarchy -Graphics Core -Sound Core -Scene Management -Object Core -Advance Timer & Multi-thread -Artificial Intelligence -Physics I could go into details of what each component within the library will do, and what I have of them completed as of now, but I believe that is the purpose of the game engine, and the ease of creation of the games I shall finish when the game engine is complete as well. Also, I'd like to create this game engine up to where once I get to a specific point with the engine I could stop working on the engine and make a game to see how fast and easy it is to utilize, and then go back to the engine and back to making games, and back and forth. So basically I need to know how to setup it up, so I can test the hell out of it like crazy whenever I need to without messing up any other completed games, the game engine itself, and what not... Thanks,
Advertisement
Making your own engine can be very time consuming, even a simple 2D one, so unless you have plenty of time I don't recomend that.

There are many engines already out there to be used, check this list: http://wiki.gamedev.net/index.php/Game_Engines
I also recomend you PTK, which is dead simple, it is written in C++ and let you chose OpenGL or D3D7, and works for Mac and Windows.

If you still go for your own engine, then I may ask, what experience you have with C++, OpenGL and SDL ?

Dang! I sound like such a beginner huh?

Well, I have about a year and half of self-taught experience with C++, C#, Java, VB
about a month experience with Python, Ruby.

I'm also proficient in the field of mathematics.

OK, so I have completed a game using each of the following API's or libraries.

DirectX (pong, breakout), OpenGL(breakout), SDL(pong, breakout, tetris, space invaders), Allegro(Tank), (working on a game using SDL.Net just found it today)

I'm writing a huge article on making games using SDL by first building a framework in Part I having easy access to Graphics, Input, Sound, Timer, and in Part II making the games Pong, Breakout, Tetris, Space Invaders (all games I have completed in one of the above languages I posted above).

And knowing that what I'm making isn't a game engine, but more less a framework to make a game I make sure I state that clear in the article; however, as I was writing it I was wondering what it would take to make my own game engine.

I know I'd have to ask what components, game development techniques I would want in the engine how abstract or game type specific I would want to make it, but I figure this being a hobby and having plenty of time why not?

So that is the experience I have. Of course, everything that I do is self-taught, and knowing that I probably use the wrong data types in places, or instances in the wrong place when it should be something else I know I'm still learning and pushed toward the right direction I know that I could make a 2D game engine.
My newfound, and very much preferred method of creating a game engine is to create it along side a game.

Come up with a game idea: a simple platformer, and start creating the game, adding engine features as required. You'll find a whole load of features you didn't think of if you just designed the engine alone.

When you've finished your game, use the engine for something completely different - a 2D isometric shooter? You'll find yet another chunk of features you'll need to add to the engine. Keep making more games: your engine will mature, you'll find important bugs, it's feature list will grow, AND you'll have a nice selection of games to show for your efforts.

I'm currently head first in a 3D engine for my final year team project at University, the game's design document is haven for things I need to add to it. I'll have a reusable engine AND a professional game developed by a team of 8 people at the end of it.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

That's what I wanted to do, but how do you create it separately from that game?

Like say I want to create a project (the game engine) in Visual C++ and I want it to be a library I'm assuming not an exe project

and i want to add this feature, and this feature for a 2d side scroller.

and then I have the 2d game project and i want to add that library to the game project, but I want to be able to edit which ever project I need to completely separate from each other without any interference.

I'm trying to do that; however, like I know how to link a library to a project I've been doing that since I learned how to download allegro and set the the project up, but how do you do it when it's your own creation that you're constantly updating?


Like if I was to create the engine along side of making the platform wouldn't i have to delete the platform stuff when I make that isometric shooter?

I would consider that a framework not a game engine. Like a game engine for adventure games would be completely different from an RTS game, but the framework what I would consider loading sprite sheet, clipping, input, sound, would stay the same.
Ok, if I understand what you want to know, it's how to have a library (the game engine) and the actual game code together in visual studio.

Well, to do this, you just have to make a "solution" which contains multiple projects. Then you just add both of your projects to this solution (one will be the game engine, the other the game). Then you add a dependency for the game that tells visual studio that the game depends on the game engine (right click on the project->Project Dependencies). Lastly, if you want to setup multiple games within the same solution that is also possible. You just have to tell visual studio which project is the default by right clicking on the project and selecting "Set as start-up item."

Let me know if something isn't clear.

-TOmcAT
-Keith
Thank you!

Thank you!


YES YES YES!!!! :)

It's clear!!!!


Quote:Original post by aleisterbukowski
That's what I wanted to do, but how do you create it separately from that game?

***SNIPPETS REMOVED***

Like if I was to create the engine along side of making the platform wouldn't i have to delete the platform stuff when I make that isometric shooter?

I would consider that a framework not a game engine. Like a game engine for adventure games would be completely different from an RTS game, but the framework what I would consider loading sprite sheet, clipping, input, sound, would stay the same.


If you are building a game alongside a game engine, but want to reuse the engine in another game genre, you can select parts of the game code that you feel are generic enough to integrate well into other genres. For example, collision detection functions/physics can be used in a variety of genres, from platformers to RPGs to shootem ups. However you will find that certain features, such as an container to fit all of the player's items will not be used in nearly as many genres, and can then be excluded. Functions specific to sound, networking, entity management, scripting, graphics and input are all generic enough to be used in most genres, whereas you will not likely find a RPG battle system in say, an isometric point-and-click. So the idea about writing a multi-purpose game engine (or framework) is to keep it as open ended as you feel you will need it.

If you need any more clarification, feel free to respond here, or if you are the same CS Finch I had talked with on AIM months ago, you can still IM me. my screen name is 'zerotri3'.

Hope that helps,
-Wynter Woods(aka zerotri)
Hi I got your private message but I can't click 'reply'...? I'll look into it.

To develop the engine along-side the game without making a mess, put your engine code into an 'engine' folder (give your engine a name, mine's Symmetry), then include your engine files with #include "symmetry/engine.h"

As for IDE independent, you only need your source files and media to compile and run. I make use of Visual Studio .NET 2003 on Windows, and KDevelop on Linux, the source is in a shared folder and each IDE throws in its project files, etc, but leaves the source untouched so the other IDE knows none the wiser. Of course, there's better methods, but I'm not the world's best programmer.

Since you're making use of SDL, it's also relatively easy to keep it platform independent too. For example, I create a window and stuff it with OpenGL using pure SDL functions - I never have to touch the Windows API or that God-awful window class creation mess, and it runs on Linux without changing a single line of code.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Hello there
I am new to this forum, and I was wondering if any of you guys could help on a little project that I am doing at University.
basically I am creating a breakout game which I know is not that difficult to make but the catch is I need to use the game engine that they have provided called GFC.
and I cannot seem to make some things work. I cannot use openGL since we haven't learned it yet so it would be cheating in a way.
if anyone could help that would be appreciated. I'll forward the engine so you can have a look at it.
my email is darkness120@hotmail.co.uk
if anyone would like to help me please contact me on the email above.
Thank you.

This topic is closed to new replies.

Advertisement