5 Replies - 833 Views - Last Post: 04 April 2015 - 11:42 AM Rate Topic: -----

#1 TheStrange_One   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-April 15

How Would You Re-Create A Game?

Posted 04 April 2015 - 01:24 AM

Hey guys, I am just starting to learn C++ (I have a lot of experience making games but never anything insanely complex, and always through premade engines.) I just wanted to ask you guys a question about how you learnt how to make games. I have an idea for a game that I wanted to try and make that uses features from other games and smashes them into one big super game. Mt first instinct is to try and recreate a simple version of a few of these games to understand how the mechanics work alone before combining everything... One problem, how?

The first game I wanted to (for lack of a better word) clone, for personal research would be Shopping Cart Hero. I just have no idea where to start. Does anyone know of any source code from the app that I can read or anything similar to this. Or even just a nudge in the right direction?

Thankyou for your response in advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: How Would You Re-Create A Game?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,621
  • Joined: 12-June 08

Re: How Would You Re-Create A Game?

Posted 04 April 2015 - 07:16 AM

Quote

Mt first instinct is to try and recreate a simple version of a few of these games to understand how the mechanics work alone before combining everything... One problem, how?

How what? You grab a pen and paper and begin to outline the mechanic you want to you make a proof of concept for. What it does, how it operates, what it interacts with, how the user triggers it, etc. Once you have scoped that out you can sit down and recreate the design in code.

Quote

Does anyone know of any source code from the app

Unless the make gave out the code on git hub, or somewhere similar, it is not polite to try and snatch/grab the app's code.

Quote

Or even just a nudge in the right direction?

Again - design, design, DESIGN! *BEFORE* you even hit the keyboard. Write down all the interacting parts, what you see on the screen, actions, interactions, etc.
Was This Post Helpful? 2
  • +
  • -

#3 GetSet   User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 411
  • Joined: 08-February 11

Re: How Would You Re-Create A Game?

Posted 04 April 2015 - 07:23 AM

Design is definitely important for a game because a game is usually a big project, relatively speaking. Of course tic-tac-to is not a big project but generally games are.

Quote

...and always through premade engines...


Premade engines I would say are the way to go unless you want to do a few things for fun. Ideally an engine would have methods for graphics, sound, input. But that could come in many flavors as an api for any language. In terms of game engine, I am curious, what game engine(s) have you developed in so far?
Was This Post Helpful? 0
  • +
  • -

#4 BBeck   User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: How Would You Re-Create A Game?

Posted 04 April 2015 - 07:31 AM

I learned game program by hacking at it for over a decade and making lots of wrong turns and mistakes. I'm still trying to learn it. :-)


XNA in C# was the real breakthrough for me. Of course, a big part of the problem for me was that I never really wanted to do 2D games (I actually did some simple 2D stuff when I was about 12, so after that all I wanted to do was 3D). But the XNA 3.1 books really were what took me to where I wanted to go and got me started with 3D.

You say that you have experience writing games with various engines and that you're doing C++. So, I assume you've made up your mind that you want to use C++ to make games. There are several options for making games in C++, especially in 2D. For example, SDL, OpenGL, and DirectX. So, you have to make up your mind which you want to use.

In Windows, Windows takes control over all the hardware and traditionally going through Windows was so slow that game programmers refused to do it and wrote their games in DOS instead of Windows which was making Microsoft lose all of the game market for PC's.

So, Microsoft invented DirectX to bypass windows and go straight to the graphics card. Things have changed substantially since then but that's still the basic purpose of DirectX. OpenGL does basically the same thing as DirectX. I'm not sure what the situation on UNIX or MacOS is but I assume it's largely the same and uses OpenGL.

I think the vast majority of game frameworks, API's, and Engines are built on top of DX or OpenGL or both (like Unity). Really, I don't know of any other way to get to the graphics card without using either DX or OpenGL. But, DX and OpenGL are almost like writing graphics drivers. They are as difficult as it gets in game programming. Of course, if you are already in the world of C++ and mastering dereferenced pointers and such, it may not be that much worse really. Also, they don't handle a lot of even the most basic things for you like creating a window for your game to run in and a Windows process for your game to run under. You have to do all of that stuff yourself. So, it's very low level. There are some API's and whatnot like the DirectX Tool Kit that can help you with some of that, but I'm of the mind that if you're going to go this low level you might as well go all the way; otherwise, why not just use an engine? So, I've avoided using any sort of API or library with my DirectX projects.

OpenGL is similar but uses it's own APIs and such. OpenGL also does nothing but graphics and so you have to use another API for things like keyboard, game controllers, sound, etc. DX does those thing within DX albeit it can't make up it's mind how it wants to do them from version to version.

I hear you can make 2D games with XAML in Windows 8 these days. That may involve C++ for the underlying code. I'm not sure.

You may want to look at SDL which is built on top of OpenGL. That uses C++ for 2D.

If you're in Windows, I just posted C++ code for projects I'm working on in Visual Studio 2013. I'm getting ready to make some tutorials on them and post them on YouTube. (Really, more of just a discussion of the code and some tutorials on the underlying principles.) Even 2D game programming in DX 11 and OpenGL 4 is done in 3D these days. So, you have to learn at least the basics of 3D in order to do 2D in DX or OpenGL now.

But anyway, that is some C++ for DX11 source code you can look through and see how it works. The first project I posted there is two projects in one solution. The first project is so basic all it does is start up DX and put a Window on the screen without drawing anything. The second project in the same solution file is the same thing with an additional class that allows you to put 3D objects into the scene. This is pretty close to what you would do in 2D for DX11. The stuff after that is specific to 3D in the other projects posted. (The last project has a bug in it so it only runs in 64 bit and not 32 bit. I'm working on fixing that this weekend.) So, if you want to download that first project it would give you some C++ code to look at to see how things are done in DX. Start with the Main.CPP file because that's where the code starts. Then you can pretty much read through it.

It is at least intermediate level C++ when you're doing DX, if not advanced. There are a lot of pointers, which tends to be one of the most difficult things to learn in C++ for a lot of people. But the source code is well commented in that first project. So, you can almost read through it without any knowledge of C++.

Here is a video of the last project posted on my website (the one with the bug in it) if you want to get an idea of what these projects do without actually downloading the projects. That first project download is much more simple but it has the same cube and triangle in it and camera controls. Really 2D work in DX 11 is only slightly more easy than that first example project. Really, the second project on texturing is probably the closest to 2D game programming in DX 11, where I use a grass texture to cover the ground plane.

2D in DX11 is actually done in 3D (which is why these examples are basically the same thing). The primary difference is one line of code which uses an Orthographic Projection Matrix rather than the Perspective Projection Matrix this code uses. Then instead of doing full 3D objects, you make 3D squares and texture those squares. Those are basically sprites. So, if you imagine the camera looking straight down at the floor and the textured squares being flat on the floor with maybe a big square covering the whole screen and smaller squares as tiles on top, that's basically how 2D is done in DX11 which is actually 3D. The camera needs to change a bit, but other than that it's extremely similar to what I did with the ground plane in the texturing example.

This post has been edited by BBeck: 04 April 2015 - 07:47 AM

Was This Post Helpful? 0
  • +
  • -

#5 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1556
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: How Would You Re-Create A Game?

Posted 04 April 2015 - 09:20 AM

Well everyone has made really good replies,

each from different directions mostly I agree with modi's points as they are general and to the specific point.

But you ask how we learned to program games.

Initially from books and magazines recreating simple games then slowly buying more books and building more complicated games.

Also before you program a game you should know the syntax of your chosen language really well.

Once you have the language down it really is just a case of using your imagination and as modi has said design, design, design.

Ultimately any game will test your skill as a programmer and after maybe a lot of hard work improve your skill as a programmer.

The best advice I can give though is not to be scared of it and to just do it.

Regards

Snoopy.
Was This Post Helpful? 1
  • +
  • -

#6 jon.kiparsky   User is online

  • Beginner
  • member icon


Reputation: 11474
  • View blog
  • Posts: 19,537
  • Joined: 19-March 11

Re: How Would You Re-Create A Game?

Posted 04 April 2015 - 11:42 AM

It's always an interesting exercise to try to recreate an existing program. I would not suggest trying to find the source code for the existing program, since that would defeat the purpose of the exercise. Instead, use the original as a sort of "live spec", and derive from that a definition of the behavior you want to implement.
Then:

Quote

Again - design, design, DESIGN! *BEFORE* you even hit the keyboard. Write down all the interacting parts, what you see on the screen, actions, interactions, etc.


Can't repeat this often enough. The biggest source of frustration in beginner projects is taking on something too big for your capacity. The second biggest is writing code before you know what you want to write. You're making the first mistake, which is cool. You'll learn a lot. But don't make the second mistake as well.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1