You are not logged in.
Pages: 1
I have been thinking about checking out graphics/game programming in C. I would like to use something cross platform as well. Anyone still using plain C for game programming?
Offline
I'm developing a video game in strict ANSI C using the Allegro Game Library. It runs on Linux and Windows. Allegro games also run on Mac OS X, but I haven't used it.
There's also a version of Allegro for Haiku. I got my game to compile and "run", but it's pretty flaky.
Offline
That sounds interesting, I will check it out. It seems pretty popular.
Offline
I don't like that the way you ask this question implies that "plain C" is somehow inferior to some other kind of "C" (presumably referring to C++). If you come to this project with the idea "C is not as good as C++", you might as well be using C++ anyway. They're different languages; choose one based on its merits.
And I'm not sure why you posted a question that your namesake could solve so quickly.
Offline
I asked in plain C because it's my main language. I would rather avoid C++ for the time being. I have looked and everywhere I turn it seems C++ and libraries built around it seem to be used. I want to make sure a library is able to be used with plain C.
It's obvious C++ is the standard for game development. Python and Java are also popular and have good libraries, but I want to stick with plain C.
edit:
The only game I have read about wrote entirely in plain C is quake. I wonder how many others there are?
Last edited by Google (2010-11-24 14:49:56)
Offline
If you come to this project with the idea "C is not as good as C++"...
Google loves C. I, too, love C. It's been my favorite programming language for many many years.
(My boring history:) When I first started doing game development as a hobby, I decided I would make a 2D game with C and then a 3D game with C++. Well, it's been over ten years and I'm still writing games in C, none of which are finished. More recently I started using Objective-C, because it is C, but with objects. Even so, the game I'm working on now is strict ANSI C for two reasons: I love C, and I thought it would be a fun challenge to make it strict ANSI.
For the record, the more I study C++ the more I hate it.
And I'm not sure why you posted a question that your namesake could solve so quickly.
I've been doing a lot of internet searching because it interests me too. I found almost nothing on the topic. Are there any websites you recommend on the subject?
The only game I have read about wrote entirely in plain C is quake. I wonder how many others there are?
As for APIs, OpenGL, Allegro, and SDL are all C. Other than that, it seems to be really hard to find information regarding games made in C. I assume that's because most video games aren't open source.
Offline
SDL and Allegro seem pretty nice from what I have been reading. I think SDL looks more appealing from what I have seen so far.
I would love to see tutorials for games wrote in C. C++ tutorials are a dime a dozen. I found a lot of nice tutorials for game development in C++.
I also find the more I learn C++ the more I dislike it. If I was forced to not use C.. I wouldn't use C++, I would probably go for Java instead as it seems to be a lot easier on me. C++ is incredibly complex.
It doesn't matter how many languages are out there, I would love to stick with plain C. I have no doubts that it's possible to code games with it, but it's certainly hard to find tutorials and guides for it. I suppose you could read C++ tutorials and wing it out in plain C. It would be quite the exercise though.
Offline
I used SDL instead of Allegro for one of the games I worked on. I think it was because I wanted it to be more "pure" or something. I found the Allegro and SDL API to be very similar, with the main difference being that SDL is general-purpose, while Allegro is designed specifically for game development.
See http://www.allegro.cc/ for information on Allegro. I don't think you'll have any problem making your first application with Allegro. All you need is the examples that come with the library and the API to look up the meaning of things. The forums are quite nice too.
Offline
I always try to make a game as a hobby, but next year I'll probably go to university so I need to study a programming language.
I've experimented with python and C++ in the past, but I'm going to learn seriously C before the begin of the university, so I enjoyed reading this thread.
http://wiki.allegro.cc/index.php?title=ExampleExHello
I read this example and I have a question, do you learn by heart the parts like this "if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {" or there's a text editor that shows you the function and something like that?
Because I feel like if I'm doing a memory exercise, is this computer programming? Do you have an API reference always with you until you have learned by heart an API?
Sorry for the questions, I've been always fascinated by computers and Linux but I've never learnt a computer language seriously, I always feel like I'm doing a mess when I try to do something.
Offline
I read this example and I have a question, do you learn by heart the parts like this "if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {" or there's a text editor that shows you the function and something like that? Because I feel like if I'm doing a memory exercise, is this computer programming? Do you have an API reference always with you until you have learned by heart an API?
That's a good question.
I don't memorize the Allegro API, but I understand it. I always have the Allegro API open in my web browser when I make a video game. It's easy for me to find and use functions in the API.
Also, you only use the "set_gfx_mode" function in your game once. You don't need to memorize it. Just use it and forget it. It's easy to remember the functions I use often, like "blit". But most of the code in my video game doesn't use Allegro. Most of the code is just math
I think it's very useful to be able to use any library by reading the API. I think it's more useful than learning a new programming language.
If you have any more questions, please ask!
Offline
Thank you very much, I always thought that all programmers learned by heart every API. I'm going to do some experiments in the next days .
Offline
Thank you very much, I always thought that all programmers learned by heart every API. I'm going to do some experiments in the next days .
I have not used the API, but even I can guess:
if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { // If set graphics mode doesn't return 0 (success)
// Do something here if the graphics mode didn't return successful
}
Learning an API is useful, but impossible to memorize everything. The thing is most APIs tend to follow some of the same conventions. For example most functions return 0 on success or >0 on failure or sometimes NULL on failure. A lot of test conditions look for these which is why I assume this statement is testing if the set graphics mode was successful or not.
Once you learn basic programming you will begin to think in this kind of way naturally.
Learning the standard libraries is a little different. I think most programmers memorize most of the standard libraries. For a language like plain C it's not too hard, the standard library is very standard and not too large. Learning additional APIs like SDL, OpenGL or Allegro is another story. They are completely secondary and harder to memorize since it's something you don't use or need everyday.. well depending on if you use it for your job or something.
Start with learning a language like plain C. Learn the standard library routines, programming logic etc. Then build your way up.
Offline
SDL is a very good choice for game developement in C. You can find nice SDL tutorial here: http://www.lazyfoo.net/SDL_tutorials/. Author of this tutorial does not only cover SDL but also introduces some game programming concepts.
Offline
Thank you very much, I always thought that all programmers learned by heart every API. I'm going to do some experiments in the next days .
It's not that we learn every API, it's that when we use API's, our brains (and the brain of every creature functions this way) form links based on context. If I start writing a game using, let's say SDL in C++, then my brain forms a link between graphics and the SDL API. If I start writing a compression utility, then I form a link between compression and zlib. We remember what we want/need to remember when we need to remember it, is what I am trying to say. And when that fails, documentation is just a Google search or man page away. (Insert relevant XKCD comic here, the one with the flowchart for non-tech savvy people explaining how nerds work would work fine.)
Last edited by Orm (2010-11-26 16:08:38)
Clever tagline here.
Offline
I too am writing some games in C, and yes I would say it's a good choice depending on what type of game you are doing. I'm more of a quick and dirty programmer so for me C is pretty optimal, whenever I code in C++ I have a tendency to generalize everything so as to make it as broad a solution as possible, which usurps alot of time whereas in C I pretty much go straight for the simplest fastest solution. Sure the code ends up alot less reuseable, but I find that my projects move along much faster this way. I have been interested in trying out Vala though, anyone who has any experience with it?
Offline
I love C because it has been the only language I was able to learn fast and use with very little documentation to accompany it. I basically browse man pages once in a while to double check function arguments etc. Other than that I feel I can just crack at it and get the job done. I haven't felt that in any other language yet.
I think C is best for small to medium size projects. Once you get to a huge project C is kind of difficult to handle because you need a grasp of the entire code and what has been done etc. If you are just jumping in on a huge project you basically need to re-read the entire code to have a feel of how things work. At least that is how I feel. I wonder how the kernel developers do it? Haha
Vala looks very interesting.
I am checking out SDL and also GTK+ for making some GUIs. These have been my ambitions lately. I am also hoping to start learning html scripting and some CSS stuff. I know it's kind of late in the game to be learning something as basic as html but I never had the ambition to learn it before, but now I want to start my own website.
Offline
I think C is best for small to medium size projects. Once you get to a huge project C is kind of difficult to handle because you need a grasp of the entire code and what has been done etc. If you are just jumping in on a huge project you basically need to re-read the entire code to have a feel of how things work. At least that is how I feel. I wonder how the kernel developers do it? Haha
I'm not a kernel developer but I'm pretty sure that they divide different parts of the kernel into smaller parts tied together by a thin layer of glue (or maybe no glue I don't know). That way one piece of code dosn't have to know anything about other parts of the kernel. I guess it's a bit similair to how a libraries work in that all you need to know is what it does not how it does it. Anyway, you know much more about kernels than I do so maybe I'm wrong..
I am checking out SDL and also GTK+ for making some GUIs. These have been my ambitions lately. I am also hoping to start learning html scripting and some CSS stuff. I know it's kind of late in the game to be learning something as basic as html but I never had the ambition to learn it before, but now I want to start my own website.
It's not called HTML scripting HTML is a markup language not a scripting language. JavaScript is the scripting language used on the web, and its syntacs is btw very similair to C/C++. So it should be a piece of cake to learn for you
Offline
I find SFML to be a lot more sane than SDL when coding up some small games. SFML is C++, but there are C-bindings for it. At the very least it uses OpenGL under the hood (rather than software rendering) and allows you to mix GL routines and SFML routines.
Offline
I find SFML to be a lot more sane than SDL when coding up some small games.
Wow. I took one look at the SFML short example and immediately became jealous of how nice it looks to use.
For reference, it looks like both the packages for SFML and the C bindings ("sfml" and "csfml") are in the Arch Linux repositories.
I've decided studying new libraries is fun.
Offline
I went to university in Albany NY, not too far from you haha.
I think SDL and SFML looks very nice... I really like some game design tutorials I found for SDL. I prefer the look of SFML.
edit:
I am in love with SFML. I have been hacking around with it in C++ and it's really easy to use. I have been building a pretty basic graphics application. I am going to test it on some various systems. I think I will give the C bindings a shot too.
Last edited by Google (2010-12-02 14:20:04)
Offline
You can always do gameboy advance programming. I did it in one of my classes at university. There is a rom online, and many tutorials about how to make it work. Not exactly what you want, but definitely a good example of games that are made with C.
Offline
That sounds fun, I also read into games made for the NES but they weren't done so much in C. I did find that you can program in C and compile for a MIPS machine which enables you to kind of program for Playstation and the N64.. kind of had me thinking....
Offline
Pages: 1