What is a C++ equivalent to JavaFx and AnimationTimer class? - c++

I have a tetris game programmed in JavaFX. I want to translate it into C++ to learn C++. What can I use in C++ to display the graphics and time the game loop, the way I did with JavaFX and the AnimationTimer class?

C++ really doesn't have any in-built compatibility for graphics. You need to learn an API.
Looking at JavaFX it seems to be a 3D rendering library. So this really is determined by how deep you want to go.
If you want to learn the baseline, engine design, etc. you could learn OpenGL directly which would teach you the nitty gritty of how all 3D graphics work and SDL2 http://wiki.libsdl.org/FrontPage for the OS interop. Timing the game loop can be done easily with the std::chrono classes.
If you want something slightly higher level where things like lights and such are already built for you I'd consider working with an existing framework that will give you practical experience towards game development. Most of these use scripting languages like C#, Lua, etc. Unity C# is great for something like this. Unreal Engine 4 has C++ bindings if C++ is the main consideration, but it is a bit heavy for such a small game but most game engines only use C++ for their optimized low level frameworks with scripting engines hooked on to them for ease of development while maintaining near optimal performance.
Ogre is another option for C++ open source engine that has a lot of documentation. http://www.ogre3d.org/ Which could be a happy medium between the 2.
If you don't care about 3D graphics and just want rectangles / images in your game something like QT could work well also, but that is a GUI framework more than it is a game engine which if all you are wanting is something like Tetris is fine.

Related

What limitations will I run into making a game with Allegro / SDL vs. OpenGL / DirectX?

So I have a bunch of experience with C++ and Win32 programming and I am looking to create a 2D game with a couple of friends of mine. I have also dipped my toe into DirectX and OpenGL, but would prefer to use as simple of a library / API as possible when developing this game both for reducing the learning curve and making the development process easier / faster. However, I don't want to limit myself to much with regards to what I can and can't do in my game based on my choice here. What functionality / features would I lose out on by going with something like Allegro or SDL vs jumping straight into OpenGL lets say. I realize you can do other things aside from just graphics with Allegro, etc., but will I be able to build a fully featured game with something like Allegro?
Yes, it is possible to create a good game with libraries like Allegro. There is a few nice games in their depot to prove that. And I remember a few shareware games created using Allegro. It all depends on what kind of game you want to create.
But AFAIK Allegro and SDL are C libraries and if you are familiar with C++, you may try SFML or Cinder which could further simplify the process.
If you are only into creating a game comfortably and don't care about the technology used maybe using a complete engine like Unity3D or Unreal engine, which are free until you make a considerable profit out of the game.
You will miss out the lighting part you generally do in a fragment shader. Other than that, using a pure 2D api can significantly reduce your amount of code, because you do not need to write your own shaders, nor the interface between shader and c++ code which is often even more work and maintenance than the shader itself. Since shader code is mandatory in modern OpenGl my recommendation is SDL2.

Game map for DirectX

I am making a game in DirectX 9/C++. I do not have a lot of knowledge about directX. I want to make a map for my game similar to GTA 1. I want to know is there a way to make whole map in some other software and then import and render that map in my directX application.
If, not what are alternatives?
DirectX is not a game engine. DirectX is a programming API. Things like maps, game logic, and so on are completely beyond what DirectX does. It's your burden, as a programmer to implement these things.
Honestly, if you have to ask this question, you should not use DirectX directly, if you want results fast. Instead use an existing, available game engine and implement your game using that. In the past years a number of high quality engines have become available for little money or even free. To name a few:
Unity
Unreal Engine or SDK
CryEngine
Source SDK
There are also a few open source worth looking at:
IrrLicht
Ogre
CrystalSpace
You may also want to look at open source games, which engine you can repurpose. Specifically I'm thinking about Cube2 / Sauerbraten and it's successor Tesseract here.
I would really recommend to use an Engine like Unreal Engine 4. You can get it for little money and it does a lot for you. You can spend a lot of time in designing your game, so you dont need to spend that much time which directx and stuff.

C++ using animations from Flash or similar

I want to program a game, and I want to do it in C++, because everyone seems to agree this is the best way to program a game. What I really want, though, is the ability to animate something, swap images around during runtime, and retain the animation. Also, the ability to pin graphics to certain parts of other graphics, or group graphics together. I know for sure Actionscript and Flash can do both of these. It's especially easy in Flash because I can visually see the animation and swap symbols via Actionscript to change it to what I want at whichever frame I want. Now, I know that it's fairly simple to swap images during runtime in C++ as well, but in C++, (from my understanding) I would have to animate via code and I would have to manually move each graphic separately for the graphics to stay together. Is there's a way where I can animate in Flash, then use those animations and swap images in C++? Or, if there's some other way to accomplish the same thing, without using Flash? (don't mind using bitmaps)
I think maybe you should just program your game in Flash and ActionScript, if you're already experienced with those tools and your game can fit in them. Programming a game in C++ is a difficult and complex task, necessary for difficult and complex games but often overkill for simple and fun design. If you just want to design games, go with the simplest tool that lets you make your prototype!
If your game is too big to implement in Flash, consider using XNA, or a prebuilt game engine such as Ogre or Unity. XNA is in C♯ but even that is good enough for any game that a one-man team could build.
Scaleform lets you embed Flash in a C++/DirectX game, but as you can see it is rather complicated to employ. We have one engineer and three artists dedicated full-time to Scaleform UI on our project, to give a sense of how much work it is.

C++ Game Programming Resources

Where can i get some advanced game programming resources for c++?
At http://gamedev.stackexchange.com ?
More specifically, this question and lots of others tagged with c++
Start with writing some simple 2D games, e.g. Snake, TicTacToe, etc. Write these using any GUI builder you're already familiar with.
Then try to rewrite these games using a serious graphic engine, e.g. SDL, OpenGL, or DirectX.
Then try to write a more complex 2D games, e.g. side-scroller. Write these games with the graphic engine of your choice.
Then add some simple 3D effect to your 2D game, e.g. parallax scrolling.
Then rewrite this effect with true 3D, use 3D models/sprites, 3D environment, etc, while maintaining a 2D look and feel.
Then add some simple 3D look and feel, e.g. allowing characters to move in the Z-direction (to/from the camera), doing camera rotation, etc.
If you just got out of the command prompt and simple GUI, you'll probably want to start simple.
I'd very much recommend OpenGL as your API of choice. Since you've done some simple GUI programming, you'd know what an API is.
OpenGL has the following advantages (compared to SDL and DirectX previously mentioned):
-Its hardware accelerated (SDL is not as far as I know)
-Its 3D (SDL is 2D)
-Its cross-platform (DirectX is Windows only)
By far the best place to start with OpenGL is the Nehe tutorials.
http://nehe.gamedev.net/
Game programming becomes evident once you become a bit more familiar with the API.
Also, I'd heartily recommend GLUT (OpenGL Utilities Toolkit). It simplifies window creation and user input handling, among other things. Its great for learning OpenGL. It also happens to be cross platform.
Here's freeglut, a free GLUT implementation:
http://freeglut.sourceforge.net/
OpenGL is also a relatively simple and easy API to learn. You'll be going into 3D in no time.
What libraries are you using? You can try GP wiki. It can be a bit hit and miss depending on what you want to use.
By "resources," do you mean tools? Libraries? Tutorials? I have a bunch of useful game developer links in the sidebar of my own site. I also think "Mathematics for Game Developers" was very helpful. It has a second edition as well.

What environment should I use for 3d programming on Linux?

One thing I always shy away from is 3d graphics programming, so I've decided to take on a project working with 3d graphics for a learning experience. I would like to do this project in Linux.
I want to write a simple 3d CAD type program. Something that will allow the user to manipulate objects in 3d space. What is the best environment for doing this type of development? I'm assuming C++ is the way to go, but what tools? Will I want to use Eclipse? What tools will I want?
OpenGL/SDL, and the IDE is kind-of irrelevant.
My personal IDE preference is gedit/VIM + Command windows. There are tons of IDE's, all of which will allow you to program with OpenGL/SDL and other utility libraries.
I am presuming you are programming in C, but the bindings exist for Python, Perl, PHP or whatever else, so no worries there.
Have a look online for open-source CAD packages, they may offer inspiration!
Another approach might be a C#/Mono implementations ... these apps are gaining ground ... and you might be able to make it a bit portable.
It depends on what exactly you want to learn.
At the heart of the 3d stuff is openGL, there is really no competitor for 3d apps, especially on non-windows platforms.
On top of this you might want a scenegraph (osg, openscengraph, coin) - this handles the list of objects you want to draw, their relationship to each other in space the ability to move one relative to the others, selecting objects etc. It calls opengGL to do the actual rendering.
Then on top of this you need a gui library. Qt, Fltk, wxWigets or one built into the scene library or written directly in openGL. This handles the menus, dialogs frames etc of your app. It provides an openGL canvas to draw into.
Personal choices are openscenegraph and Qt
For the 3D part, I strongly recommend the SDL Library with the OpenGL library
You can get some tutorials here
Qt has a pretty decent OpenGL-based graphics module.
Maybe you should consider using a graphics rendering engine such as OGRE. Coding a CAD program from scratch using OpenGL will take lots of time.
On Linux you have no competition to OpenGL.
It's one of the big players in the 3D field, so it's definitely worth learning.
This site has some excellent guides and code examples (on various languages).
You can use OpenGL with many languages, naturally on C and C++ but also for example with JAVA using LWJGL or other API's.
If you want to program at "a higher level" than opengl, use vtk. It is quite easy to get started and has bindings to many languages.
See www.vtk.org
you may use OpenSceneGraph for rendering.. it is an OpenGL based library..
and you may use OpenCascade.. it is good for 3D modelling...
we are implementing such an IDE at work and we use these things.. using pure OpenGL may be hard for you... anyway you may try...
for interface it is good to use Qt..
and i suggest you to use Eclipse if it is Linux..
(if it was Windows, suggestion would be Visual Studio)
For a C/C++ IDE, you have the following options:
KDevelop - KDE-based
Anjuta - GTK-based
Netbeans
Eclipse
Of course, you could also use a language like C# or Java:
Best OpenGL Wrappers for Mono and .Net
JOGL
There's really no reason why a simple CAD application would have to be written in C++.