Hacking C programing

  • Thread starter Thread starter sightlight
  • Start date Start date
  • Views Views 11,060
  • Replies Replies 96
  • Likes Likes 1
If you want to make games with a programming language (not html or this scratch thing), then you should first learn to program. Just the knowledge of programming already gives you the ability of making simple games. I remember my first games being ASCII based games like Tic-Tac-Toe, a puzzle, hangman and a pokémon battle (no pokeballs, items or the ability to run). If you understand well how games works, you could even simulate backgrounds, sprites animation, events handling using only the basic libraries/functions. I gave some though at it but was too lazy to actually try :P

But when you know how to program for real, you can use some kind of tools to aid in making a game, for 2d programming the Allegro library is quite easy to learn and was used in many commercial games from the DOS era. I programmed some games using C + Allegro and made an improved version of Pong (featuring sound effects, the screen changed color depending on the player's scores), a math function plotter and a graphical demo using Ace Attorney's graphics (and since it failed pretty badly, I used the nervous Phoenix animation).

If you want to learn to program games for real*, you could learn to program either using OpenGL/Directx in case of PCs or learn to program for DS/PSP/Wii or any video game that have an unnofficial development kit and that you are able to run homebrew.

*By real, I mean going level hard :P
 
@peps, and a bit offtopic

If you think the python syntax is annoying, try taking a look at PERL


And I agree that JAVA does a bit more handholding than C++ does (as in none)

Don't get me started...

Friend of mine in work is in love with Perl and we sometimes call her the "Regex Queen"... but she struggles with Java...
 
I suggest BAGASMI! While its not exactly complete, or very functional, or easy to read (assembly like syntax), it is a scripted language (written by me!) that runs on the DS. There is a PC interpreter available so you can type up your program on PC and test it there; when finished you can run your program on the NDS. With the current state of the interpreter, the Supercard DS2 version has way more features than the standard nds version, so I'd recommend that one if you were to give this a shot.

As for slightly more serious advice, if you want a visual for your sprite placement, open up paint and create a new canvas the DS screen size and manually place your images where you'd want them. Once you get your coordinates finalized you can place them in the code.
 
Has anyone actually explained what the different kinds of languages are yet? I didn't read the entire thread but I saw mentions of compiled languages vs interpreted languages but no explanation as to what the difference is. I'll try to explain them as it's a very important basic part of programming.

In school I was taught that there are low level languages and high level languages. There is also machine language, the most basic of all the languages. Machine language is the only language that computers can really understand. It is the collection of zeros and ones that actually tell the computer what to do. The machine language for every different machine is different. This is why a NDS game will not run a PSP. The machine language for the DS is different for the PSP because the hardware and the circuits are different.

Because it is very difficult to program in machine language, someone invented low level languages to make it easier. Assembly language is a low level language. It looks a little more readable than just zeros and ones so it is easier to program in. However, the computer cannot understand Assembly language so it must be converted to machine language. This is done with a program called an assembler.

Later, people started to develop high level languages such as C and Java. They are easier to read than assembly language and like assembly language they must be converted to machine language so that the computer can actually understand them. However, instead of an assembler high level languages can use one of two different kinds of programs to convert to machine language. The first kind of program is called a compiler. It is similar to an assembler in that it takes the all of the high level code and converts it all at the same time to machine language BEFORE the program runs. The C language uses a compiler. On the other hand, there are interpreters. Interpreters also convert the high level code to machine language but the difference is that it is done WHILE the program is running. Say for instance you have an if statement like this:

if (someConditionIsTrue) {
//do stuff
}

The block of code within this statement ("//do stuff") will not be converted to machine language until "someConditionIsTrue" is true while the program is running.

So, to answer your question, compiled languages like C and C++ cannot be run in real time while writing the code because the entire script has to be converted to machine language before the program is run. However, it may be possible to run interpreted languages like Java in a real time interpreter because the entire script doesn't have to be converted at the same time.

For now, I would suggest sticking with DSGM until you've got the basic idea of programming down. That's what I did.

I hope this was clear and accurate enough!
 
Oh my gosh, why does everyone keep saying that Java can be interpreted in realtime! It can't!

From all my years in programming, I have never seen anything at all that could be programmed in real-time besides interpreted "languages" like HTML and Scratch, which won't help you get anywhere with game development. Contrary to common believe, Java is in fact compiled, it is not interpreted, and it is not in any way related to JavaScript. Java code is parsed and compiled to Java Bytecode, which is then interpreted by the Java Virtual Machine. This allows it to be cross-platform with ease, because it doesn't use platform-specific coding (most of the time...)

So, to clear things up, Java doesn't have live interpreting, because it must be compiled. If you want to code for the 3DS, tough luck. The only languages that you can actually use, are Assembly, C, and C++. Interpreters could be made, but native code is much, much faster. As for getting started, I'd suggest doing DS Homebrew to begin with, then advance to 3DS homebrew once it is made available in a few months.
 
AHDH version of the text above (no offense), C/C++ turns into an executable that just works on whatever os it was compiled for, JAVA turns into an executable that needs a separate runtime (separate from the OS) to work
 
@Deltaechoe
Sorry, I just had to clear that up. My OCD was killing me. :P

Continuing...

Well, that's debatable. From what I've seen, DSGM seems like it does a lot of internal coding itself, as opposed to without any tools or wrapping. I was talking about actual programming, with no tools besides the IDE and a compiler. If you've ever done Assembly (or ASM for short) or C programming for any sort of homebrew/hacks, you'd understand. I've programmed ASM for the Gameboy (ARM7 processor), and you have to do EVERYTHING. You load graphics into the VRAM, modify VRAM addresses to make it draw differently, get input from the RAM, load pointers, write pointers, and so on. No holding hands with an SDK or library.

Of course, sometimes it's easier with an SDK, but it's also nice to be in control of everything as well.
 
I started with Java, but that really hurt me later on trying to move on to C++. It holds your hands too much. You're better off learning a variant of Lisp called Dr.Racket (http://racket-lang.org/) and the guide at http://www.htdp.org . The easiest one I've dealt with was Visual Basic, but if you're looking to do anything other than native windows applications, you're out of luck.

The program you are describing sounds like making flash games or maybe GameMaker (http://www.yoyogames.com/gamemaker/) which is not going to help you learn anything.
Actually, Game Maker is a great way to start programming. You can start off with Drag & Drop, learning the basics of how the different things function together, and over time you can start to use larger and larger amounts of code in place of D&D until you don't use any Drag & Drop at all. That's how I learned programming :)
It also helps that the syntax is very similar to C/C++.
 
Well go learn C, then C#, get the pointers/loops/adresses stuff right and you're on your way into coding something from your own hands without relying too much on SDKs.

A loop runs code until a certain requirement is set (this is n times). If that certain requirement is 1, then the loop will run forever.

An if statement will only run the code inside it ONCE, only if the requirement is met.

Or else code inside the else branches will be run (if statement --tied to else ) has failed to run.
 
Development within a game studio uses a custom scripting language. This is nothing like working in an actual programming language. You cannot compare them.

A programming language like C/C++ must be compiled in order to convert program code into machine code which the computer can understand. A game studio uses their own scripting engine to parse your scripts and "interpret" or translate them into code they've written. The code they've written was already compiled into machine code. This is why a game studio can offer an IDE with real time updates. They are providing you with a large portion of code to abstract you from complex details.

The closest you're going to get with a programming language is something like Windows development using Visual Studio (hence the "visual" part). Visual Studio provides some built-in interpretation for Microsoft Foundation Classes and Windows Forms. But it only allows you to align non-interactive controls. Events/functionality must still be compiled to be seen.
 
I agree that Game Maker isn't a good intro to game programming. It's a great intro to game design though, and all the higher-level concepts and ideas that people often don't understand take so much work.

Has anyone actually explained what the different kinds of languages are yet? I didn't read the entire thread but I saw mentions of compiled languages vs interpreted languages but no explanation as to what the difference is.
Welllllll to be entirely technical, both are compiled before running. And yes, this does mean that it's possible to take an interpreted language and compile a binary of it (well, taking the interpreted/compiled form, slapping the headers on it, and saving it instead of running and deleting it in RAM) for running on a system that doesn't have the interpreter (PHP, Perl, Python, etc.) but it's rarely done because that's pretty much the only advantage.
 
Welllllll to be entirely technical, both are compiled before running.
It really depends on your definition of "compiled".

Certain interpreted languages can be compiled (like Java). Other languages can be "compiled" as byte code (such as PHP). Byte code is nothing more than a more efficient form to allow the interpreter to translate the code into machine code. Others use JIT compilation (such as Python and Java). JIT is more of a hybrid approach. I believe Perl may be compiled into byte code as well... I'm not sure. I'm not a Perl developer.
 
That's a good thing that Java abstracts that though. Newbies shouldn't have to deal with pointers or memory management when they don't even understand basic control structures. And considering how crucial pointers and references are to even do some basics in C++.
-- stuff
I took a Game Dev C++ in college and not in a single moment were memory management and pointers discussed. Its completely possible for a beginner to jump into the language without wading into the low-level aspects of the language.

That's the beauty and strength of C++, the high/low level versatility of the language and its enormous catalog of mature libraries.
 
  • Like
Reactions: RodrigoDavy
I took a Game Dev C++ in college and not in a single moment were memory management and pointers discussed. Its completely possible for a beginner to jump into the language without wading into the low-level aspects of the language.

That's the beauty and strength of C++, the high/low level versatility of the language and its enormous catalog of mature libraries.

That was a terrible game development course then.

The main reason to go for C++ is because of pointers and memory management. If you don't want to learn anything about them, then there's simply no point going with C++, and you're just going to end up with a very inefficient program where objects are constantly being passed into functions by value, with confusing errors that will take a fair bit of time to figure out. You might as well just use Java for creating games in that case, as odds are it will be far more efficient (and of course you have stuff like PSP emulators and Minecraft both coded with Java as proof that Java is pretty fast).

Again, we don't want to confuse newbies to programming and to scare them off. Let them start simple with Java, and then move onto more complex languages like C++. You're stating they don't need to do anything complex with C++, so why not just make their life easier with Java which will provide them with meaningful errors?

(And just on a side note: NullPointerExceptions are the reason you need to have a basic understanding of pointers in Java)
 
  • Like
Reactions: Wabsta
That was a terrible game development course then.
I have to agree.

Now, everyone has to start somewhere, especially with C++. So, I can understand if there's some courses that don't get into memory management or pointers. However, I would expect more from a course dedicated to developing complex systems like game engines. They should have required these fundamentals to have been covered in a previous course and then build on them. Efficient code is critical for modern games. More importantly, it's far too easy to create memory leaks if you do not understand how to manage it.

Besides Java, I think XNA development using managed C# would also be an option for beginners.
 
Besides Java, I think XNA development using managed C# would also be an option for beginners.

I keep forgetting about XNA, definitely is another option. Java is just for easy programming learning more than anything else.

I agree with @Rydian that GameMaker is a great tool for learning game concepts, which is pretty critical when it comes to game development. Many aspiring game developers always think that doing something like jumping is a simple matter of "myCharacter.jump()", which GameMaker will quickly show you isn't the case at all. It really helps you learn how to do complex things without knowing anything about programming languages. And of course, if you want to do something more complex, GML is there as a coding language. I remember making a online top down space shooter in first year of college using GML.

The game development course I went to in my college (which is mostly a software course with game development added on, which makes a LOT more sense that dedicating the whole course to games), starts off the students with GameMaker in first year, PyGame in second year, Unity3D and Havok in third year, and finally DirectX in fourth year. It builds up the students gradually, first learning about game concepts without having to touch code, then moving onto coding 2d games in Python, then developing 3D games using pre-existing engines, and then learning how to create their own engine using DirectX. Of course, this is only a single module, and you're still learning about Java, C++, Requirements, Networks, Databases, Maths, Software Testing, Law, etc etc in other modules.
 

Site & Scene News

Popular threads in this forum