I understand the language... I just have trouble implementing it into a game...

Started by
7 comments, last by Anthony(y) 9 years, 4 months ago

Hello. This is my first post on Gamedev, I'm been looking around the site for a while but I never started my own topic so I hope I can get some help smile.png

So, over the past three months or so, I've been experimenting with a few different languages:

  • Python (my first language, I'm quite comfortable using it for basic programs, etc. but I wanted something more for making games)
  • Java (my second language, I had looked at it before when I was trying to make Minecraft mods a few years ago but I'd since forgotten about it really. I understand the language and syntax but I can't really make anything from it.)
  • C++ (again, I know the language and syntax of it (knowing some Java really helped me here) but I can't really sit down and put anything together)

I was just wondering if anyone else has/if having the same sort of problem and how they plan/did get over it?

Thanks smile.png

Advertisement

You get over it by trying to build something, failing to do so, asking questions about your failures, learning from them and revisiting the problem.

It concerns me that you're dabbing in three different languages. All three of those are perfectly suitable for making games. If your goal is to make games, then you should start making them using whichever of those three languages you are most comfortable with. This sounds like Python, so what makes you want "something more" than Python? What is it you feel you are missing?

I would argue strongly that if you can't "make anything" in a language you don't really know the language or the syntax. You've perhaps just memorized some words, but don't have the critical reasoning about the way those words relate to actually form them into a useful program, and thus effectively don't know the language.

Regardless, pick one of those languages. Ideally (again) the one you think you know best. Start with a simple game, and try to make it. The simplest possible game you can make is a text-based guess-the-number game. Can you do that? If so, can you build a text-based hangman game? Settle on a simple project that seems within your skill level and try to make it.

Post questions when you run into them.

I think it's essential that you find open source game projects for you to study.
They might not even illustrate the best coding practices, but they will show you a way.

Try to play the game before reading the source at all.

I think it's essential that you find open source game projects for you to study.

They might not even illustrate the best coding practices, but they will show you a way.

I don't think this is good advice at all.

Reading and comprehending source code is a skill on it's own, and requires a reasonable understanding of the structure of a program and conventions of the language. In this case the OP is unable to grasp enough of that structure or those conventions to articulate his own ideas in a tangible form via a programming language; looking at what others have done (without context for why) is not going to make that any easier.

Plus, since the context for decisions is not provided with most source code, it's very easy to pick up extremely bad habits this way.

Not to mention that any of the 'open source game projects' the OP is likely to find via his or her local search engine of choice are almost certainly going to be well beyond the threshold of complexity he or she should be staying in.

It's not supposed to be the entire focus of his study, it is a complement.

When I was learning how to structure programs I made sure to have the source code of a few games and playable \ interactive "demos" around to look at and admire, obtained from the programming community related to the language that I was using.
I learned a lot from observing the blocks of code, recognizing the patterns formed by those blocks and understanding how those patterns influenced the behaviour of the game.
I also learned by modifying the game code and seeing how those changes affected the behaviour of the game; even if a modification was small, seeing the result would motivate me to pursue further study on programming and this justifies this recommendation.

It seems that there are more ideas here:
http://www.gamedev.net/topic/637176-open-source-projects/

There is no reason you couldn't use Python to make games.

The problem you're facing is that learning to program is a lot more than just learning syntax. You have to learn how to use the libraries of your environment, you have to learn how to use the building and packaging and editing tools available to you, and you have to learn how to solve problems. All at the same time.

When I start learning a new programming language (about a quarterly occurrence for me, these days), I start by figuring out how to:

  1. Open a GUI window, bonus points for it being a native window for the operating system I'm on
  2. Put buttons in the window, and how to place them. The GUI button is the minimum of interaction that a GUI system can provide. If I can get a button working, I'm well on my way to figuring out how the event model works. It will also serve me when developing the program further, to have an easy way to plop controls on the screen to change things.
  3. Register mouse and keyboard events. Ideally, I want to be able to poll the keyboard and mouse, but that is often not the case, so usually I have to setup an event handler of some kind and keep track of the state.
  4. Perform an animation loop, the "infinite while loop" that also doesn't make the system unresponsive. In the old days with Win32, that meant an infinite loop which gave back time to the OS to execute. In Java, that meant a Timer object that had a Tick event handler. In JavaScript, you request a new frame of animation from the browser when you first start or after you receive an animation frame from the browser. So how a particular system does animation can be quite varied.
  5. Load files from disk. I'm going to want to store my images in files, foremost, and eventually my level layouts.
  6. Draw images to the screen. With the basic 2D graphics libraries that are available in most GUI subsystems, this is not too difficult. In all of the 3D APIs, there is a lot of setup code to get something like this to work. I usually focus on the 2D graphics from the GUI subsystem first, because usually that's all I need to start.
  7. Play sounds asynchronously. Audio has a huge impact on the enjoyability of a game. A really crappy looking game can be greatly improved by just some simple sounds, but even a great looking game is nearly ruined by having no audio. Depending on the system, making it so you can play multiple sounds at the same time, on top of each other, can be difficult. But once I've got it, it's usually easy to copy it around to all of my projects.

Once I have these tasks figured out, the rest of the job is mostly just figuring out how to put together the game. For a "first" project in a new language, I usually do Tetris for this reason, because I've done it so many times I don't have to think too hard about what needs to be done to make the game work.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]


The problem you're facing is that learning to program is a lot more than just learning syntax. You have to learn how to use the libraries of your environment, you have to learn how to use the building and packaging and editing tools available to you, and you have to learn how to solve problems. All at the same time.

Thanks for all of your responses by the way, after I saw that first one I just thought I was being a nuisance. I hope not :)

I've always been very good at problem solving, even if it sometimes takes me a while to look at what I have and realise what's gone wrong.

The problem I have is making the jump from games that run in the CMD to fully graphical games. It's just the way my brain works I guess. I've already made several text based adventure games / interactive fiction games with Python and I've done a bit with C++. It's just that, in my mind, if a program is written... it shows text, likewise, if a program is made in a graphical environment such as Unity, it will be displayed graphically on the screen. I really need to get this out of my head.

I really need to learn how to write stuff in OpenGL, SDL, SFML, etc.

I apologize if I've lost anyone there... I've always been pretty terrible with words... and programming :P

I think you would benefit from going through the SFML tutorials. I imagine you'll have a fairly good idea of how you can write a game in C++ after that.

I think you would benefit from going through the SFML tutorials. I imagine you'll have a fairly good idea of how you can write a game in C++ after that.

Having a look through now, I don't know why I didn't think of that before. Thanks :)

This topic is closed to new replies.

Advertisement