• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
turquoiseptato

I want to make a 2D game engine! Where do I start?

16 posts in this topic

Guys I feel ready to make a 2D game engine, I have the knowledge of many language and library and whatever. But let's say I know nothing! What would you recommend me to learn to make a 2D game engine? What programming language? what library? which programming technique or algorithme should I learn?

1

Share this post


Link to post
Share on other sites


Guys I feel ready to make a 2D game engine, I have the knowledge of many language and library and whatever. But let's say I know nothing! What would you recommend me to learn to make a 2D game engine? What programming language? what library? which programming technique or algorithme should I learn?

If you want a starting point for C++11 work, you could take a look at the repository I'm setting up for my next set of articles.  Tutorial  The directory "WithSupportLibs" sets up a C++11 cross platform environment which supports SFML and Horde3D (you don't have to use the 3D portion, I just put it in as an option as it is small and works well enough even though dev work seems to have stalled on Horde3D).  I'm sure there are other starting points but figured what the hell, this may be interesting to you since the build environment has been well documented through the series of articles I wrote. :)

0

Share this post


Link to post
Share on other sites

If your goal is making a 2D game engine, but no game, then cool. But if your goal is making a 2D game, then make the game, not an engine. Engines aren't really used for 2D games much, and focusing on the engine and over-engineering it leaves you without a finished playable project at the end.

 

Regardless, it doesn't matter what language you use, or what libraries. Use the language you already know best, and the libraries you are already familiar with, and work with those. Unless your goal is learning a new language or a new library, and not completing a game. wink.png

 

Is your goal: (pick one)

A) Making a game

B) Making a game engine without a game

C) Learning a new programming language

D) None of the above

 

If A, let us know what language you already are most familiar with, and someone can recommend a good 2D graphics library for that language.

If B, let us know what language you already are most familiar with, and someone can recommend a good 2D graphics library for that language and some architectural articles or books.

If C, learn Pythonsmile.png

If D, could you elaborate on your actual 1 (one) primary goal for this project?

 

Note: There's nothing wrong with wanting to make a game engine as a goal - it's really fun to do - just realize it comes at the expense of actually making a game.

Many beginners think they need an engine to make a game, but that's not true, and they end up tripping over their 'engine' and failing to produce a game. This is the only point I'm trying to get across. The idea of an engine is appealing, but misleading, to game developers.

 

Engines come out of games before games come out of engines. Engines are the reusable components of pre-existing games wrapped up in a consistent and easier to use interface for future games - but focusing on the engine without a solid game in mind leads to an engine that isn't usable for any real game with heavy alterations - unless a developer has already made a half-dozen real games, in which case the real-world requirements of engines are already in his mind.

Making an engine instead of a game is putting the cart before the horse - from finished games come the knowledge and re-usable pieces to make engines.

Okay I'll tell you what I know. So I know: javascript, C++, python, C and ruby. And I'm more familiar with javascript, C++ and python. My main goal is to make a game engine, which is b. cause I mainly wanna learn how a program can make another program especially how a game engine can make a game. I only know 2 library pygame and SFML for c++.

Edited by turquoiseptato
0

Share this post


Link to post
Share on other sites

A game engine doesn't exactly 'make' a game, a game is built ontop of an engine (if it already exists) or a game is built directly, and the engine is refined from the generic and re-usable pieces of the game.

 

By 'game engine' do you mean something like Game Maker (which is a game engine and a game editor)? Or are you really just interested in the software part of the engine?

 

The term 'game engine' isn't super well defined. Some people mean one thing, others mean a similar but different thing. At what point a game engine ceases to become a library (or collection of libraries) and starts becoming an 'engine' is unclear. I like to think of it as the point where the libraries start to include higher level logic. ([1] [2] <- more of my thoughts on the topic)

 

I would suggest sticking with C++ and SFML, or else Python and PyGame, since either of those combinations are ones you know.

 

Then, to make your engine, I would have some clear genre in mind (to make it loads easier on yourself), and work towards making a engine for that specific genre (say, a tile-based RPG or a turn-based strategy). I would create tools (a map editor, mainly) for working with that genre, and write the code to support logic suited for that type of game.

 

Because different game genres require different logic, if you make your engine's logic too general to fit every genre, you might accidentally end up with a library or framework instead of an engine. Or, you could figure out some way of making the logic of the engine re-arrangeable to suit different genres - but even then I'd suggest having at least one clear-cut genre to work towards at first before creating a pluggable logic system to expand to other genres.

Edited by Servant of the Lord
2

Share this post


Link to post
Share on other sites

Servants post very cleary states the opinion of most people here: make a game not an engine.

Although I agree with most of its points, I personally think it is a good idea to start with the engine.

 

The question to ask yourself is; what is an engine?

I like Servants definition; reusable components fromt the game.

Although everyone has its own programming style, I personally don't think you should start with the game logic of the game without getting any visual output.

I like to start setting up the core components in order to draw a screen, implement all input/visual/audio APIs in an easy to use manner, setting up a basic gamestate system, entity manager incl. messaging etc. etc. I think this is actually a good programming behaviour, start by making a planning and design of what you actually need for your game. For instance in the first game you make you could decide to leave out the audio and you could just use if-statements for handling the gamestates.

 

Later one when you make another game, you can then re-use these core components of your game for the next game, while slowly introducing something new (if you feel that you actually need it or makes development easier), such as a scripting language. If you implemented something in the engine and you don't need it for the next game, you can just leave out these code files.

 

I got the same advice when I started: make a game not an engine. But after finishing a couple of games I felt like I realy couldn't re-use much of my code.

Mostly because I thought things weren't done efficiently or weren't easy to use. At that point I started doing things the way I described above, using carefull design and starting from the ground up and now I can just use this framework I made and start coding the game almost right away.

 

So to summarize my advice: spend some time making a good design, if you write a very good reusable piece of code it'll safe time in the end by avoiding having to recode everything again. But don't try to implement all kinds of features you're not going to use in the current game, you can easily implement those features as soon as you write the game you'll need it in.

1

Share this post


Link to post
Share on other sites

yeah someone says game engine a lot of times their talking about all the programming responsible for interacting with the low level graphics api (like opengl, directx) or sound library (directsound, sdl) - and things like collision detection and physics - and plenty more stuff - but the point is...

 

you make a 2d game you have to - to a certain level - incorporate all that stuff in to the game. There are certain ways to structure this stuff to make it so you can make multiple games using the same code (all the graphics, physics, collision, sound stuff) but until you have made at least one game how in the world can you know how to structure it?

 

I mean make an engine if you want.. its just chances are you will want to rewrite most of the engine when you go to make a game that uses it

1

Share this post


Link to post
Share on other sites

I don't think a beginner is really considering all kinds of low-level stuff when he talks about a game engine. And telling him to just code the game without thinking of the engine, might let them think they should rush into programming the game logic and skipping a good game design. But I tend to agree to most points of the last posts here and in the end it might actually be a good thing if you let the beginning programmers find out their code is not re-usable, so they can learn from their mistakes :)

1

Share this post


Link to post
Share on other sites

As someone that has coded a framework 3 times now  (I wouldn't call it an Engine, but more of "reusable classes" for my games), I would advise making SMALL games and then designing an engine/Framework around that. 

 

After my 4th or 5th game, I scraped my design, and I'm currently reworking my framework to be more "engine" like, and I'm actually happier this way.  But I would have no idea what to look for if i just started by attempting to build an engine.  I'm not sure how much of this is related to a 2D engine since the concepts are easier, but there is still resource management and data structures.  Start small. But always think about "How could I reuse this if I wanted to make another game".

1

Share this post


Link to post
Share on other sites

Hi,

 

Making a 2D game engine should only be considered a novelty hobby or learning project.  To make a professional quality 2D game engine, you really are only reinventing the wheel and spend a good 5 to 10 years doing it when you could be making marketable games and making money most of that time!

1

Share this post


Link to post
Share on other sites

If you know nothing, then you need to start from somewhere and build off from there. It is the only way to learn and gain an understanding of a particular subject.

 

If you do not know anything, then you should not even begin building an engine. It is a good challenge if you know enough.

 

Learning the basics is like riding a bike with training wheels. Learning GUI and graphics is like riding a bike with the training wheels off.

Edited by warnexus
1

Share this post


Link to post
Share on other sites

I've recently started a game project, myself being the only developer and working in collaboration with 3 artists. I settled on the Unity Engine for my 2D game because of how much is already done for you as a game programmer can focus on gameplay and not the boring stuff like creating collision libraries and object factories and object managers.. etc the list can go on forever. Also, the asset pipeline in Unity is extremely robust and can pretty much take anything you throw at it as far as 2D/3D assets. Give it a try if you have the time - well worth it.

0

Share this post


Link to post
Share on other sites

Your engine is only good for what you test it for.

 

The big part of writing a reusable and good code is being able to test it in a real-world scenario. In case of a game engine, I would discuss that it is near impossible to write a good game engine without writing a game. Even then, this makes this engine only tested for this specific type of game [1].

 

Why it is so? Because a use-case is the main factor that drives any software. A good game code works for game-related use case, and not for an idea of a game-engine. If we test your engine by executing some demo of 3D terrain and a skybox, then our engine is good for making a demo for 3D terrain and a skybox. If we try to build a game on top of that, we will most likely find that our engine needs to change. Because our use-case have changed.

 

Do we really need an "engine"?

 

Why do we even want to write game engines?

 

I think we do not like the idea of our code being used for one game only. Why rewrite, when we can reuse the same thing again and again? Let's separate our engine-specific and game-specific code and make engine reusable this way.

 

Well, the problem is that games are quite different. And we like different games. Even in 2D side scrollers, we want to make new wildly insane mechanics different for every game and maybe even the level. The bad things start happening when the game-specific stuff starts to creep into our engine. Now, instead of being optimized for a single game, our engine needs to be optimized for both use cases. And sometimes it is not feasible, and we may end up using separate engine versions for separate games. We should have just made different games without wasting time for one engine.

 

The "good" code.

 

Let's just accept the real world, and embrace it. In the real world, no one ever creates perfect code (except me, but that is a joke [2]). Things break in the real world. Sometimes we need to rewrite big portions of the code. And we learn, often the hard way, that writing a good code requires a knowledge of what a bad code is/was. 

 

And sometimes a good enough code for one game may be a bad code for another. And vice-versa.

 

It depends on what it is used for.

 

Group code by the Use Case.

 

The big thing driving a good software design nowadays is called decoupling and separation of concerns [3].

The Big Idea is to create the tools, not frameworks or engines. A tool is self-sufficient. It should not know about anything else but itself, and require the minimum of third-party components.

 

Inject a bit of pragmatism here. It is OK to copy-paste a helper function from our "engine" into the tool to make it more self-sufficient. Even better, optimize this helper function to work better for our tool. Our tool can have its own "vector" type, or use plain arrays best suited for its job, instead of using engine's "vector" type. It may not be DRY [4], but it might be OK.

 

A game is a test for the tools, as well as the reason the tools exist. It should remain that way.

The question of deciding what "tools" to write should be dictated by the requirements of the game, not a vague idea of what possible games there might be.

 

How to write a tool?

 

Let's write a game, and let the tools be the solutions to the problems we encounter while writing a game.

 

For example, write an input handling the way it is best suited for our game, and make it more and more tool-like and decoupled as we complete it. This way we can keep an eye on suitability for the game and the performance of our tool.

In the end we can move this "tool" into a separate library. We may use a software like CMake [5] to avoid thinking too much about compilation and linking. We may even write a small demo application that uses nothing but this tool

 

We can write a small demo applications to demonstrate that our solutions work properly without the dependencies of the full game. 

This is good for several reasons:

  • If we ever want to evaluate our tool/solution for inclusion into another game, it is easy to see if they are suitable, because a use case is clearly demonstrated in a small amount of code that is required for a demo.
  • This motivates to avoid adding dependencies to our libraries, because we will need to add dependencies to our demo applications.
  • We see more immediate results while developing a game, because we have the working demo applications sooner than the finished game.
  • In case something breaks or needs improving, we can use the demo as testing grounds instead of launching now-big game with all the other clutter.

And even if we do not succeed to completely move our tool into a separate library, our code is still better and more decoupled, because it is more "tool-like".

 

[1] Write Games, Not Engines, scientificninja's blog.

[2] “Nobody actually creates perfect code the first time around, except me. But there's only one of me.” [Tech Talk: Linus Torvalds on git, Google, 15 August 2007].

[3] Managing DecouplingBy Niklas Frykholm, GameDev

[4] DRY - Don't Repeat Yourself

[5] Cross Platform Test Driven Development Environment Using CMakeBy AllEightUp, GameDev

 

(should I expand this into a full article? there is much more to say on this subject)

Edited by Nercury
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0