Sign in to follow this  

Creating a 2D engine from scratch...

This topic is 2333 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

I'm currently studying a Game Development course, but I wanna try some stuff on my own....I still haven't got to 3D yet, so I was thinking, why not try making a simple 2D game

Thing is, I know (at least I'd say) enough C++ to get it done, but I don't know where to start....

C++ I know is all the basics (variables, classes, functions, memory management, new, delete, pointers, virtual etc.), but taking what I know and turning that into a game.....s'kinda daunting, I mean, I've programmed a little to practice the stuff, but it hasn't been "complete" things, more, sections of things....as part of the course, I have seen a little of a 2D engine, but I want to make my own (more for the experience than anything)

I know more or less what sort of game I want to make....it'll be single player for now (although I would like to add an online multiplayer component at some point, not MMO, just two/three other players in a game....if it's not super difficult/pointless, maybe a basic lobby with chat).....it'll be kinda like Monster Hunter for those who know it, only much, much simpler (at least to start ^_^) and 2D.....I'd like to make it so adding stuff in is relatively easy (eg, if I want to add a new enemy I don't want to have to remake the game from the ground up)

Mainly, what I'm wondering is....where to start? (any good tutorials are welcome too ^^_)

Share this post


Link to post
Share on other sites
I'm actually doing it right now, I went the whole 2D from scratch. It definitely is way more work and takes way more time than I thought. 2nd go round I really would like to just use an already existing engine.

But I am learning... ALOT.... very time consuming.

Anyways, If you are totally new to this, I would start with http://nehe.gamedev.net if you want to go the opengl route.

Some people might reply his code is old and outdated, but you can still learn from it. Unfortunately, I don't know of any other active sites that has tutorials as in depth as nehe.

[url="http://www.gametutorials.com/"]http://www.gametutorials.com[/url] used to be free, now you have to pay for it.

Share this post


Link to post
Share on other sites
Start with the basics, and build from there:
[list=1][*]Set up a window (and get it running full-screen if you're planning to do that).[list][*]You'll need to choose a windowing API -- depending on your choice it may also provide your rendering functionality and even other things such as input handling. Common choices for people using C++ include [url="http://sfml-dev.org/"]SFML[/url] or [url="http://www.libsdl.org/"]SDL[/url] (you could use [url="http://lazyfoo.net/SDL_tutorials/index.php"]Lazy Foo's Tutorials[/url] for SDL). You could also choose to do the lower-level work yourself using DirectX or OpenGL. Note that whatever choice you make you'll need to learn how to work with libraries, which is an important skill.[/list][*]Display an image in your window.[list][*]For this you would either use the drawing functionality provided by the API you chose above, or if you chose an API that only sets up a Window you would now choose a graphics API as well. SFML and SDL both provide easy-to-use functions for loading and displaying images -- if you're working directly with OpenGL or DirectX you'll have a little more work to do but should still be able to get this working relatively quickly.[/list][*]Figure out how to get your image to move around in response to user input.[list][*]Again, you'll either be using functionality provided by your initial API choice, or you'll need to choose an input library. Start with a single keyboard button or mouse-click as input, and build from there -- you should spend a little time at this point learning how to respond to multiple key-presses, responding to mouse-movement and clicks, etc.[/list][*]Add a second image, and set up some basic collision detection such that your original image can not move through the new one.[*]You should now be at the point where you could assemble the bits and pieces you've built into a basic game such as Pong or BreakOut by adding additional objects and applying some game specific logic (in Pong for example, you would need to implement a bouncing ball). This is the stage where you can start fleshing out the type of game you want to make -- you might want to turn your original image into a character for a side-scroller who jumps and falls back down, or you might want to turn it into an overhead space-ship dodging asteroids.[/list]

Hope that helps! [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]

Share this post


Link to post
Share on other sites
Thanks, that does help ^_^

All of the replies so far help actually! Although the course I'm doing shows me DirectX I'll still check out that Nehe tutorial, and JBAdams, thanks so much for breaking it down like that...it makes a lot more sense to me now ^_^

Share this post


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