By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,916 Members | 1,317 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,916 IT Pros & Developers. It's quick & easy.

Using C for game development

P: n/a
I want to begin by making simple 2D games for Dos. What particular
features of C should I look to strengthen ? I am not asking about the
graphics bit but in general.
Jun 27 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
pereges said:
I want to begin by making simple 2D games for Dos. What particular
features of C should I look to strengthen ? I am not asking about the
graphics bit but in general.
Structure, modularity, and cleanliness. Games can rapidly become a mess of
hard-to-maintain code if you're not very, very strict with yourself. Avoid
goto like the plague. (I mean, I do that anyway, but I'm not being
generally-dogmatic here, merely games-programming-dogmatic.) Avoid file
scope wherever practical, even if it means longer parameter lists. Keep
your loops sweet. And try to keep your hardware interface code as isolated
as possible from your game logic and configuration code.

In short, take all the good advice about program organisation that people
regularly post to this group, and get religious about it. Otherwise, when
you "only" want to make a simple modification to the game six months from
now, you'll find it much more difficult than it needs to be.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #2

P: n/a
I don't disagree with Richard's advise.

But it came as a surprise just because I was recently told by a UK
game developer that unless you are developing an engine you want to
sell to third parties (which most game developers don't do) then most
of the code is write once and forget. And that seems to work well for
game developers since they usually do not do much maintenance, and
they live on the bleeding edge of platform specific development.

So I wonder whether different software houses have different
approaches to game development.
Jun 27 '08 #3

P: n/a
fnegroni said:
I don't disagree with Richard's advise.

But it came as a surprise just because I was recently told by a UK
game developer that unless you are developing an engine you want to
sell to third parties (which most game developers don't do) then most
of the code is write once and forget.
....and it shows.

Nevertheless, remember that commercial games developers rarely work in
isolation - rather, they work in teams. And so, albeit for different
reasons, much the same advice applies to them, i.e. loose coupling,
modularity, well-defined interfaces and so on.
And that seems to work well for
game developers since they usually do not do much maintenance,
Certainly not as much as they should.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #4

P: n/a

"fnegroni" <f.*********@googlemail.comwrote in message
news:91**********************************@y38g2000 hsy.googlegroups.com...
>I don't disagree with Richard's advise.

But it came as a surprise just because I was recently told by a UK
game developer that unless you are developing an engine you want to
sell to third parties (which most game developers don't do) then most
of the code is write once and forget. And that seems to work well for
game developers since they usually do not do much maintenance, and
they live on the bleeding edge of platform specific development.
yes, however this depends a lot on the scale and complexity of the game.

for some simplistic engines, say those with maybe only 40 or 50 thousand
lines of code, and doing 2D or limited-functionality 3D gameplay, this is
probably a workable practice.

for much of anything much beyond this, it is very likely that the developers
will have good reason to reuse the code, or for worthwhile games, to make
sequels, so it also makes sense to try to keep it clean.
at least IME, 3D and OS-specific stuff is a small portion of the total
project anyways, most of the rest going into far more mundane tasks
(physics, VM, scene graph, AI and scripts, ...).
even then, most of the 3D code is pretty damn generic, and if well written,
reusable.
after all, shaders are not rocket science...
same old 3D modeling and rendering code, just throwing a shader on it, and,
POOF, the damn thing is shiny polished gold... a little more coding, and,
POOF, the damn thing casts a real-time shadow.

ok, ok, me typically doing 'mundane' shadow technology as well, aka,
projection-shadows for small things, and ray-tracing+vertex-lighting for
large things, along with good old lightmaps as well...

IME, if done well real-time ray-casting comes out scaling better than shadow
volumes, and does not incure the performance hit of using stenciling, or at
least on the cards I have often ended up using...

also possible would be to experiment with the HW-shadow support that comes
with newer GL versions, which may also be sensible.
teh pretties have not been a very high concern though (I am one of those
people, apparently afflicted with the lack of an aesthetic sense, ie, I
don't really care as much personally if stuff looks like crap...).
of course, I am a hobbyist, so I haven't really made any "real" games (with
a story and missions and all that), but, my lack of "creative motivation"
does not necessarily mean I am not unfammiliar with engines (I wrote one, as
did I write 3D modeling tools, ... so I have some idea...).

of course, it may well be, if I am ever to make a job out of this, may well
have to go the last few steps, and "be creative", AKA: art, modeling, maps,
storyline, ... all things I would much rather offload to "someone else" (I
like techie stuff, but creative pursuits are not as much my strong point),
but alas, I am the only one here...

I can't recruit anyone, sadly, because there is no one to recruit, and even
if requested to do something, people don't do it, it is lame...

not going to win the world just with technology it seems (esp all my crufty
hobbyist crap), one needs something more directly marketable...
So I wonder whether different software houses have different
approaches to game development.
I would presume so...
some people write and maintain commercial engines.
other people liscense their engines from others.

some people cruft together their own engine fresh for each game.
others keep reusing and tweaking the same old engine indefinitely.

it all depends really...
<psychotic_rambling>

people can do whatever they want really, but in industry, it is all about
the market, and getting a product to this market (all so we can get money,
so we can make more products, ...).

now, in my case, I like code and techy things, the market being both a goal
and a tool.
money for things and things for money, all so that one can hopefully
increase both, in this world bent on holding us back and forcing us into
this menial existence...

(everyone with hopes and dreams, all dreams crushed as a prerequisite of
joining the "real world", as we all become dull and lazy with no real hope
of achieving anything much beyond leisure and various "pleasures"...).

and, for a while, one ends up buying into all this, only later to discover
that they have at least some personal freedom, which has all been squandered
as so many lost years of braindead conformance...

(after all, it is not conformance making this world move along, that
industry is driven by all our peaceful dilligence and concerns for
"self-image", striving to "get to the top" in some elaborate popularity
contest masquerading as a meaningful and useful existence...).
and the end product:
the world is a better place, since in the end all this crap ends up in the
hands of individuals and hobbyists anyways, more power to the people as a
whole... ever increasing the power of industry to make more products, ...
of course, then there is this big letdown, "who am I"?... just another
pointless hobbyist it seems, irrelevant to the larger scheme of things...

things would be a lot easier though if I had money and people around who
knew how to do anything useful...

("build it and they will come" it seems, one has to bootstrap the process
somehow I guess...).

oh well...
</psychotic_rambling>

Jun 27 '08 #5

P: n/a

"pereges" <Br*****@gmail.comwrote in message
>I want to begin by making simple 2D games for Dos. What particular
features of C should I look to strengthen ? I am not asking about the
graphics bit but in general.
For a simple 2D game there is quite a bit of routine code to manage the
screen, collect input from the user, and keep score, lives, and other game
states.

The hard part is giving the baddies intelligence. Normally you can solve
this by giving the baddies something that looks very clever but isn't
really. For instance space invaders can dive using one of a variety of
pre-generated swoop paths, maybe with a "loop radius" parameter in there to
make it look like you've got far more paths than you really have.

The other hard part, for an action game, is calibrating gameplay.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jun 27 '08 #6

P: n/a
"Malcolm McLean" <re*******@btinternet.comwrote in message
news:oO******************************@bt.com...
>
"pereges" <Br*****@gmail.comwrote in message
>>I want to begin by making simple 2D games for Dos. What particular
features of C should I look to strengthen ? I am not asking about the
graphics bit but in general.
For a simple 2D game there is quite a bit of routine code to manage the
screen, collect input from the user, and keep score, lives, and other game
states.

The hard part is giving the baddies intelligence. Normally you can solve
this by giving the baddies something that looks very clever but isn't
really. For instance space invaders can dive using one of a variety of
pre-generated swoop paths, maybe with a "loop radius" parameter in there
to make it look like you've got far more paths than you really have.

The other hard part, for an action game, is calibrating gameplay.
Suggestion to people who want to write games:

Go here:
http://sourceforge.net/search/index.php

And put this in the search box:
-has_file:(0) AND trove:(80 287 597 633 82 86 268 81 84 288 85 83)

I got 7869 results
** Posted from http://www.teranews.com **
Jun 27 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.