Monday, July 12, 2010

Mars invaders...

Hi there, how are you, here you have a version of the mitic Mars invaders. Obviously, the intention of this game is purely didactic and its unique goal is you learn what you might get with the beautiful art of c programming. As you have seen, in this version only the "little faces" can shoot. I propose, as a challenge, to try the enemies ("little faces") can shoot too (tip: you have to use threads). Any way, I will try to publish that improvement in this blog later, of course, after you have tried it. By the way, game controls are: j (left), k (shoot) y l (right).

You may want to see, if you haven't done it yet, the video where you can see in more detail what I just said: Demonstration video.

Here you have the executable file (zip compressed):

Invaders


And here you have the game's code:

Code


For those who have sufficient experience in c programming, if haven't done it yet, should consider learning programming high-level languages, such as C++ or Java language. C++ is a continuation of c language, but with a perspective of object-oriented programming (OOP). What??? Yes, as well as hear it, this new idea is based in methods and attributes. For example, let's consider the object "dog" (yes, the dog animal), its methods would be ;among others, "bark", "eat", "sleep", that in programming language would be translated as functions: bark(), eat(), sleep(), respectively. Its attributes could be "color", "race", "weight", etc, that in programming language would be translated as variables. Therefore, an object is determined by its methods (functions) and attributes (variables).


For its part, Java is language, like C++, object oriented (OO) and based in c; but this is much more flexible; we can do many things which, in most cases, we do not know what is happening behind, in some way "we don't have total control of what we are doing". That does not mean Java is less important, in fact, it's becoming one of the most widespread and used progrmming languages, by one of its most important peculiarities: Create cross-platform programs, that is, for example, programs that can run on multiple operating systems (such as Windows or Linux). well I'm not going to dwell more, my intentions were only to give you a slight idea of what object oriented languages are; in any case, there is plenty of information online about it.


Finally, tell you that these high-level languages are good and all, but remember c language is a powerful tool and dangerous in some cases, you can have absolute control of the computer. Combining it with the Windows API you can create, for example, computer applications as interesting as I have in this other blog: http://prank-programs.blogspot.com/. Good luck and bye.

No comments:

Post a Comment