Tag Info

Hot answers tagged

49

I have worked extensively with a pure-C game engine that has shipped several products, so it is absolutely possible. Here's my personal experience with working in both C vs C++ engines: Using pure-C structures allows you to take advantage of knowledge about the alignment of structures, and you can then use this information to build your object persistence ...


43

Hide anything platform-specific behind abstraction layers This means stuff like rendering, audio, user input, and file IO. One common trick to abstracting that without inducing a run-time performance penalty is platform-agnostic headers with platform-specific implementation files: // FileSystem.h class FileSystem { public: FileHandle OpenFile(const ...


36

However, would writing an entire game engine in C be unreasonable today? It's reasonable, but the question is what does it buy you? You likely don't need the extreme portability C offers, and it's a shame to give up all of the features C++ offers unless you're really philosophically set against it. What are, if any, some advantages that C has over ...


25

The answer depends a bit on what you mean by "game", and on "used". I'll assume "used" means "written during the course of the specific game project". In my experience and anecdotal data from people I've talked to: in browser based games? None. in typical PC games? None. (But you might see some in low level libraries.) in iOS and Android games? None. ...


21

The bulk of high performance code in modern console games is written using a sort of middle ground between assembly and C++: compiler intrinsics. These constructs look and parse like C++ functions, but are actually translated into single machine instructions. So, for example, my "clamp each value of vector V to be >= a and <= b" function looks like // ...


21

C++ does everything C does. You can trivially mix C and C++ in cases where the advantages of C outweigh those of C++. This is a very intentional design decision of C++. C++ does things that C does not. This includes easy polymorphism, but also easy compile time code generation via templates. This is really handy for things like containers, which are ...


18

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++.


18

The simple answer is no, you do not want to use the glutIdleFunc callback in a game that has some sort of simulation. The reason for this is that this function divorces animation and draw code from window event handling but not asynchronously. In other words, receiving and handing window events stalls draw code (or whatever you put in this callback), this is ...


14

Doom, Quake, pretty much all id games up until id Tech 4.


14

How I'd probably do it so I could maintain some art control and not potentially spend a long time trying to tweak a procedural method to get it just right... First, manually create a number of sprites of tea leaf clumps as your art "pool" - not each as an entire cup's worth of tea leaves, but more like a smaller grouping. Say, 20 of them or so? Then place ...


13

You can find the video memory of an Nvidia card using the NVX_gpu_memory_info extension, or an ATI card using ATI_meminfo. Here is a snippet of code I found which might get you started. However, Paul Nettle at flipcode wonders why one would want to find the available video memory, saying: The reason it's difficult (and sometimes impossible) to ...


12

I am rewriting a 2D game engine written in C++ and Lua into C and Lua. So far the experience have been quite good. Obviously doing vector and matrix operations don't end up as nice looking in C. But apart from that I have found the experience quite refreshing after spending 10+ years as a C++ developer. C has a number of advantages over C++: The compiler ...


12

Yes and no. Officially, the only thing you can use on the 360 with XNA is C#. You can't ship any unmanaged DLLs with an app on xbox live, and if you want to write your game in C, you need a dev kit and an impossible-to-get contract with Redmond. That said, anything you can compile into CIL that will run on the compact framework will be okay. If you can ...


11

Assuming... you are talking about converting to a buffer of bytes You are using UDP and performance is a concern Try to avoid wasting space in your packet for defining structure. I.E. send, at minimum, a byte to denote the type of packet, then just assume each packet received follows the predefined structure for that type of packet Should I just read ...


10

Yes, in fact OpenGL is a C library. You can perfectly use it with C.


9

Use an api like opengl/sdl which will give you minimum hassle when going from platform to platform. Make sure you know what platforms you want to support. Don't use opengl just because you think you might want to support multi platform in the future. Start as you mean to go on. Know what hardware limitations are on each of the platforms you want to support. ...


9

Yes, it's possible. No its not a dumb idea. In fact many of the older racing games did something similar. Super Mario Kart is one example. The rendering uses 2d sprites in 3d space instead of polygons, but the physics engine is all 2d.


8

Google's Protocol Buffers is a project designed to help with this kind of thing. Makes it somewhat easy to move structs around between memory, network, disk, et al.


8

Some color data will be lost or changed regardless of your texture format. However, a bigger problem will be gamma correction. Gamma correction can be a tricky subject since your game will not appear visually the same across all display technologies and finding a single solution is not going to be easy. These might help you out: ...


8

I will try to answer this as best as I can, but there are certain "best practices" which I am unsure on, but I'll try to break it down as cleanly as possible. FSMs Firstly, the Miner tutorial is from Programming Game AI by Example by Mat Buckland (which I do recommend you get as an introduction to AI). He uses an enum for each state, NOT a struct. With the ...


8

You can write a game engine in practically any language using practically any methods of rendering. You could write a game engine in bash using console output for example. So, I think it would be best to define what exactly you want to learn in writing your own engine. There are a lot of "fields" in game development. Core Game Engine Rendering / ...


8

Why at a certain point in time the industry switched massively to C++ ? What are the reasons for the choice that ID made ? Id Software is not "the industry". They are one company. While they may be influential, they aren't everyone. I've worked on a couple of game engines that date back to 1999, and they used C++. The principle reasons for the ...


8

Your problem is the order in which you specify your vertices and texture coordinates: glVertex3f(0, 0, 0); glTexCoord2f(0.0, 0.0); should be: glTexCoord2f(0.0, 0.0); glVertex3f(0, 0, 0); OpenGL is a state machine, and in immediate mode, whenever you call glVertex3f the vertex will take on the different attributes (color, texture coordinates, etc.) ...


8

You are looking for a scripting language that can be embedded into your application. That is, a language which is designed to be interpreted at runtime (in many cases quite efficiently) and can be used to allow user extension of your native code written in C/C++/ObjC. There are many to choose from. Lua and Python are two quite popular ones, particularly ...


8

Sure you can, it's just not trivial to get it sounding "nice". I don't know how to do it in Linux, but if you can play a PCM buffer, all you have to do is fill it with whatever you want. So supposing your buffer is set to play in monaural, signed 16-bit samples, at 44100 samples per second, creating a pure (sinusoidal) A4 sound (440 Hz) is as simple as ...


8

You could think of individual places as "rooms" with "doors" connecting them: To implement this, you could create a struct Room to hold a room, with fields for a set of items currently in it and what directions its exits lie in. Then simply keep an array of all rooms and have a pointer to the one the player is currently in. There are ways of getting ...


8

Intel's compiler is just a different compiler. GCC++ and VC++ produce production quality code, just as well as Intel's ICC does. The main difference lies in 4 key areas: a) Features supported (mostly differing on C++11 features) b) Executable size c) Runtime d) Compile time When you're trying to squeeze every last bit of performance out of (mostly) ...


8

Many non-PC platforms, including some consoles and handhelds, use a modified GCC as their primary/only compiler. On the PC, most game dev houses just use Visual Studio's compiler. The choice of compiler typically has little impact on runtime speed compared to engine design and graphics, they all paid for Visual Studio anyway due to its feature set as an ...



Only top voted, non community-wiki answers of a minimum length are eligible