I am a first year college student in India and want to make a small game as a this semester project.

I am quite good at C and am learning it rapidly but I wanted to ask if developing a game entirely in C (no C++ or C#) I'd love to use these but for college projects, we have strict requirements of using only C.

What I am looking for is a simple top view driving game. It won't have anything fancy and even the visual things will be powered by simple characters. For example, user controlled car can be represented by ▓ and edges of road by series of |'s. What do you think?

closed as not constructive by Nicol Bolas, Tetrad Jan 13 '13 at 7:36

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

10 Answers 10

up vote 22 down vote accepted

Writing games in C is possible. For example, Quake II is written purely in C, so writing other games in C should be no problem at all. It may be the better choice if you're more proficient and comfortable in C than in C++.

  • 2
    @Ishan Sharma: Actually, a lot of game (engine) development is still don in C, or at least very C:ish C++. Nothing says that your C++ game will be better (or even better written) just because it's C++. – void Feb 15 '11 at 9:41
  • 5
    @void: That's only true if the programmer in question has no idea about how to use C++ effectively. C++ programs written where the writer has a basic grasp of object orientation are far more secure and reliable than equivalent C programs. – DeadMG Feb 15 '11 at 17:58
  • 7
    @DeadMG [citation needed] – Bob Somers Feb 16 '11 at 7:36
  • 6
    @Bob Somers: Easy. Compare std::string to char*. std::string always cleans up it's own memory in any situation, allocates the right amount every time. char*, you might forget to free, or double free, or not allocate enough memory. Whoops. Basic logic says that C++ programs are better and more secure than C programs. – DeadMG Feb 16 '11 at 12:17
  • 10
    @DeadMG A good programmer can write good, secure code in any language. Conversely, a bad programmer can write awful, insecure code in any language. A poor carpenter blames his tools. – Bob Somers Feb 20 '11 at 3:57

I work on a AAA MMORPG codebase that is pure C, so yes.

  • 5
    I guess that puts you at Cryptic. Do you use a scripting language of any sort? – Dan Olson Feb 15 '11 at 20:18
  • 3
    We have an internal expression language that used by designers for basically everything, and we use a mix of Python and Lua for some stuff (offline processing, map-reduce on game DBS for stats), but no Real Scripting Language in the game itself. – coderanger Feb 15 '11 at 21:49

Yes, it's perfectly possible. Many OS-level APIs like POSIX and Windows, DirectX and OpenGL all have C-compatible interfaces.

Fabien Sanglard has written an article about his 3d engine in C. On reddit, this article has created an interesting debate.

Languages are only tools... So use them wisely. To create a good game, it can be easier to use XNA or Unity3D. Mastering C is a good first step, but you must learn C++, D, python, lua ... C++ is a very difficult langage. So use it carefully.

C is great for game development.

I'm working on a 3D platformer, and I've never had any problems with the language. The only problems are collision detection and shading, I just know nothing about them, they would still occur in any other language.

In fact, I find it much easier than languages like C# and Java. I always iterate on entities using pointers (an example from my code), and fread saved a lot of time making the map loader.

If you want object orientation and modularity, you can make structures of function pointers.

Without a doubt. A lot of libraries useful in game development (such as SDL, PhysFS, etc...) have C APIs, which helps a lot.

You may wish to look into embedding a scripting language such as lua if you wish to do any extensible, high-level programming. Many people are beginning to see the appeal in programming a C framework that uses lua for things such as AI, events, etc...

Good luck.

Simple answer for this question is: You can do simple text based game like this in every programing language. Even pascal, basic or x86 assembler :]

(and do not need anything else)

Yes it is possible, but it may not be the most desirable course of action. A number of people recognize these days that C and C++ both aren't ideal for a number of tasks, and high level game logic often falls into that category.

If you insist on C instead of C++ (which makes no sense to me, but to each their own), you may be best off using Lua in conjunction with C.

For your college projects that require C this won't be an option, but for spare time projects it would be a good way to learn.

  • Lua is good at development time, but before the release everything should be ported to a native language for higher performance. – Triang3l Sep 10 '12 at 11:00

Of course you can. Many games have been programmed in C (DOOM comes to mind). SDL is a game programming library written in C.

Of course, it may be a little more difficult than using C++ for a big project, but it's possible.

I think it is possible to make a complete c games. I have made a game ( which is similar to 'space impact' of nokia 1110 mobile ) in my 2nd semester project using turbo c compiler. I think you can try this way ( as a first year college student ) without knowing any others.

Not the answer you're looking for? Browse other questions tagged or ask your own question.