简体   繁体   中英

2D Game Programming for Linux, OSX, and Windows - C++/Python/OpenGL?

A friend of mine is making the jump from graphic designer to game developer, and I have decided to work with him in my free time. Neither of us have much development experience, but I am very interested in learning Python, and my friend wants to learn C++.

I have read that C++ is the common denominator in game programming, but related questions here on SO recommend that new users avoid more difficult languages like C++. My #1 concern is creating games that are portable between operating systems. I will be using Linux to develop and play-test the game, but we would like it to run on OSX and Windows as well. We have no interest in 3D game development since we don't have any experience with 3D graphics. I would be perfectly happy with graphics equivalent to a game like VVVVVV - very simple 2D with minimal (or zero) texturing.

Also, is it necessary to use OpenGL for 2D graphics, or do C++/Python have some graphics libraries capable of producing game-worthy graphics? Remember, by game-worthy I mean simple, pixelated graphics like Minecraft or VVVVVV.

We have some books on Python, C++, and OpenGL, and can dive into those if that's the right way to get started. What does everyone recommend?

There's actually a handy set of libraries and modules for Python, pygame , that is extremely useful, well documented and has a ton of community support and a lot of fun games have been built with it. And the best part, to answer part of your question, is that OpenGL is not required.

And, because it's based on Python, it's highly portable. Of course there are lots of challenges that come with that sort of project, but be patient and stick with it and you can learn a lot and have a lot of fun too.

C++ is a really powerful language and there are lots of things you can do with it, and people who are experienced with C++ will say that you should learn it, and they are right because it's not going away any time soon, but you're correct in holding off a little. If you end up really enjoying developing with Python then there's nothing stopping you from picking up C++ later on and enjoying them together.

Above all read, practice and enjoy what you do.

I have written several small propgrams and games with C++ and Python, and for starters I can recommend using Python until you have learned how a game is built.

Of course, I don't know what type of games you want to create, but fory many small 2D games the efficiency of Python is enough, so you don't have to deal with the complexity of C++.

The libraries I can recomend for Python are either Pygame (as we have already heard) and (even better, in my opinion) pyglet , which is a more sophisticated tool for 2D graphics (it uses OpenGL in the background).

For 2D games written in C++, I can highly recommend ClanLib , an Open Source game engine with a large and active community, giant codebase and many examples. I supports both Software and OpenGL rendering, and is compilable for Windows/Linux/MacOSX. You should definitely give it a try!

Good luck :)

I agree with newlymintedcocoaguy something such as Pygame is the way to go in your situation. But to awnser your second question, you can make 2D games in C++ without the use of OpenGL/DirectX. I have done this in the past using the Windows libraries for bitmaps, RECTS etc. I assume Linux will have similiar functionality. Though if you want your game to be cross platform then OpenGL is probably the way to go.

i will recommend c++. Many people say that its difficult, true to some extent, but you can make a good 2d game in c++, without getting into the 'difficult' part. And for this you will need a library like SDL , SFML etc. Its worth your time, if you learn C++, at least you will never run in performance problem.

As someone whose familiar with the "I'm new, I want to do X, what should I learn?" thing, having done it quite recently, I'd say stick with Python for now. As others have mentioned, there are some decent libraries like PyGame out there, and C++ is well, a little complex.

If you're learning both how to put the parts together to make a game and tangling with the language, it starts getting difficult to untangle which one is actually causing your particular problem. And its always possible, once you have a good feel for what you are doing to learn a new way to do it by picking up C++.

For portable C++ games for beginners, I'd go with the SDL . It gives access to OpenGL, check the tutorials ! You may probably even use it from python with the aforementioned Python-to-C binding libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM