Sign in to follow this  

c and games

This topic is 3459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quote:
Original post by phil67rpg
what is a good starter game using c


The best starter game using C is the one that doesn't use C, in my opinion. I'm assuming you're new to programming and, if you are, I would avoid C like the plague for a number of boring, technical reasons (as well as my own personal opinion; I hate C with a burning white-hot passion).

However, if you already know C then you could try something very simple and text-based, like "Guess the Number". It involves the computer picking a number and the player has to guess it. You can vary the difficulty by making the range of the randomly selected number bigger (instead of between 1 and 5, try 1 and 10 etc.), and you can give the user a number of guesses or lives (get the number wrong 3 times, game over) or something like that. It's a very simple game, easy to program and just because it's not selling millions of copies and making millions of dollars doesn't mean it's not a game and not worth writing.

I would stick to text-based stuff like that for now. You could maybe, if you're feeling adventurous, try making Hangman but that is much more complicated for a beginner (I've been coding games on and off for about four years and never made Hangman, might try it once my current project is complete).

Good luck! I'm sure other people will post in this thread with different suggestions too.

Share this post


Link to post
Share on other sites
Quote:
Original post by phil67rpg
well I was thinking of making a poker game


Yup, you don't necessarily need graphics to do that. I'd still say avoid C, though. Looking at your previous post history it looks like you've tried a bit of everything [grin] so I'm not too sure what to recommend, what did you like the most out of all you've studied so far?

Share this post


Link to post
Share on other sites
Quote:
Original post by phil67rpg
well I was thinking of making a poker game
Off you go then, that's a perfectly fine idea that isn't overly complex, give it a shot.

Share this post


Link to post
Share on other sites
Quote:
Original post by ukdeveloper
Quote:
Original post by phil67rpg
well I was thinking of making a poker game


Yup, you don't necessarily need graphics to do that.

Unless it's strip poker. [grin]

Poker or any other card game is fairly simple, unless it requires complex AI. It's a good choice I think.

Share this post


Link to post
Share on other sites
Quote:
Original post by WanMaster
Quote:
Original post by ukdeveloper
Yup, you don't necessarily need graphics to do that.

Unless it's strip poker. [grin]

There's always ASCII-Pr0n...

Share this post


Link to post
Share on other sites
I would recommend you stick with C. It is difficult to learn (and use at times) but you get a large amount of control with it, and it's very versatile. Also, if you ever decide you want to do more than just program games, a lot of code in colleges and businesses is still being written in C or is left over from days when C was king.

Share this post


Link to post
Share on other sites
Quote:
Original post by samoz
I would recommend you stick with C. It is difficult to learn (and use at times) but you get a large amount of control with it, and it's very versatile.


I must reluctantly agree with this. I know C is hard to learn as a beginner language because its so powerful and it can blow your leg off if you try to shoot yourself in the foot (Metaphorically speaking). What I like about it is that you not only get your feet we with it, you learn the fundamentals of programming at vigorous pace. If you switch to VB or Java, you will not touch pointers or memory addresses. You won't learn how to manage things yourself, which I believe is absolutely required by programmers.

But before this turns into a rant, I must say that there is a clear line between programmers that believe C should be taught first, versus teaching managed (or 'visual') languages.

If you shy away from all that hard work, try C#, its just like C but with the grunt work handled for you. So if you end up shooting yourself in the foot, it would be with a water gun :).

Share this post


Link to post
Share on other sites
It's worth noting that pointers aren't really fundamental to programming, nor are memory addresses. What is fundamental about pointers is the referential semantics they provide (which are provided in just about any language capable of nontrivial programs). And memory addresses are more fundamental to machine architecture than programming, which in the abstract doesn't really concern itself with those details.

Remember, C operates on an abstract machine like any other language. At one point it may have been a realistic option to believe that C gives you 'control' and is 'close to the metal,' but on modern CPUs this is almost never true.

On the larger issue, it is more important that somebody start writing games than that they start writing games in [The Most Ideal Language For Beginners]. C wouldn't be my recommendation as a first language to anybody, but if the OP is already more than a few weeks worth of education into the language, trying to get him to switch can be more harmful than not.

Share this post


Link to post
Share on other sites
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.

Share this post


Link to post
Share on other sites
Quote:
Original post by thre3dee
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.


I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it, and also it's only in the beginning of every scope - so you can declare variables in the middle of a function if you introduce a new scope with {}.

Just typedef a forward declaration and it wont get messy with recursive structures (I assume that's what you meant?).

Templates I agree with though, really nice thing, but tbh, as a hobby programmer you rarely need that generic programming anyway, if you're coding solo and just starting out you don't exactly care about reusable code and maintainability since you're not gonna be writing apps with 100K+ lines of code.

I actually started out with C++ but have gone over to C because I found the OOP and advanced features of C++ overly complex and confusing, C is much easier to learn and start out with imo.

Share this post


Link to post
Share on other sites
Quote:
Original post by marsong
Quote:
Original post by thre3dee
If you want to go down the C lane, then I'd recommend simply going straight to C++. C has a lot of pitfals that C++ has amended. C++ isn't without its own problems but they are often brought out by the more advanced topics.

Some of my gripes with C coming from C++ is:
  • All variables must be declared before any statements (this is a pain in the arse - seriously)
  • You must either typedef a structure (messy) or have 'struct' in front of every use of the structure type (code bloat)
  • No templates bring pointer hacks to the masses

C really is an old language. C++ is almost 30 years old, but its still light years ahead of C.


I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it, and also it's only in the beginning of every scope - so you can declare variables in the middle of a function if you introduce a new scope with {}.

Just typedef a forward declaration and it wont get messy with recursive structures (I assume that's what you meant?).

Templates I agree with though, really nice thing, but tbh, as a hobby programmer you rarely need that generic programming anyway, if you're coding solo and just starting out you don't exactly care about reusable code and maintainability since you're not gonna be writing apps with 100K+ lines of code.

I actually started out with C++ but have gone over to C because I found the OOP and advanced features of C++ overly complex and confusing, C is much easier to learn and start out with imo.


Well, C++ is just C with OO. A few differences is syntax here and there but there isn't much of a reason to go to C becaause OO is difficult in C++. Just don't use OO in C++ and you're almost writing C. Its just that, in order to get anywhere in the games industry you'll probablty have to learn OO inevitably whether its in C++ or not.

OO is a blessing not a curse (I hope).

Share this post


Link to post
Share on other sites
Quote:
Marsong:
I think it's a good thing that you need to declare all variables before any statements, especially as a beginner because it forces you to really think your code through before you write it,
It’s actually a bad thing to have to create your variables right up front.

Quote:
but tbh, as a hobby programmer you rarely need that generic programming anyway...if you're coding solo and just starting out you don't exactly care about reusable code and maintainability
You sure you want to be saying this?

Quote:
C is much easier to learn and start out with imo
No it isn’t. You have little abstraction, and some really awkward design choices for beginners. The lack of a first class string type is very problematic for beginners in C. You can’t learn C string manipulation partially.

Quote:
thre3dee:
Well, C++ is just C with OO....Just don't use OO in C++ and you're almost writing C.
Wrong. C++ has a common C subset, but it is not C with some OO tacked on. C++ code and C code are written differently.

Share this post


Link to post
Share on other sites
Quote:
Original post by thre3dee
Well, C++ is just C with OO.


There is a lot to comment on, but I'll just tackle this one point:

C++ is not an object oriented langauge. C++ is distinctly a multi-paradigm langauge, one of those paradigms being object oriented.

C++ supports imperative, generic, object-oriented and functional programming.

If you're strictly using its object oriented facilities, you're using about 25% of C++'s functionality.

C, OTOH, is strictly a single paradigm langauge (imperative).

Share this post


Link to post
Share on other sites
Quote:
Original post by fpsgamer
Quote:
Original post by thre3dee
Well, C++ is just C with OO.


There is a lot to comment on, but I'll just tackle this one point:

C++ is not an object oriented langauge. C++ is distinctly a multi-paradigm langauge, one of those paradigms being object oriented.

C++ supports imperative, generic, object-oriented and functional programming.

If you're strictly using its object oriented facilities, you're using about 25% of C++'s functionality.

C, OTOH, is strictly a single paradigm langauge (imperative).


Yeah that quote wasn't put well, but essentially, why explicitly use C when C++ is fundamentally easier to use than C when it comes to the same principles.

What I'm trying to say is that learning imperative (C-like) code in C++ is possible however without the pitfalls of C (such as forward declaration of function variables and the like).

You're better off learning C++ from the beginning instead of C then C++ as it a lot more common in the games development industry.

Share this post


Link to post
Share on other sites
[quote]Original post by oler1s
Quote:
Marsong:
It’s actually a bad thing to have to create your variables right up front.



I guess that depends on whether you want to learn good habits that will help other developers if you move to other languages with respect to readability. Sure it's nice to type for (int nCount = 0; ...) but really, what so bad about having to put an int nCount; at the start of a code block? And if you don't have that habit, and then switch to a language that allows "on the fly" variable declaration (Like good ol' VB) then you can create a world of pain for yourself and anyone else that works on your lazy code.

Variable declarations - up front and easy to see are good.

Share this post


Link to post
Share on other sites
Quote:
Original post by oler1s
Quote:
C is much easier to learn and start out with imo
No it isn’t. You have little abstraction, and some really awkward design choices for beginners. The lack of a first class string type is very problematic for beginners in C. You can’t learn C string manipulation partially.


Hmmm, yes. Learning the guts of how strings are handled is of no value what-so-ever. Much better to learn to rely on someone elses code at all costs because heaven forbid that any of these "next generation" developers should learn to do anything for themselves. Learning memory / string management isn't all bad you know.

Share this post


Link to post
Share on other sites
Quote:
Original post by fpsgamer
C++ supports imperative, generic, object-oriented and functional programming.

I'll grant you imperative, object-oriented through classes and generic through templates, but how does C++ support functional programming in a manner than C does not? (I'm just curious on this one as I'm more of a C++ dabbler than a fully qualified C++ wizard).

You can still do generic, object-oriented and functional programming in C, although it's significantly more awkward than in languages that have been specifically designed to make those styles easier.

I have to admit that I'm still quite fond of C. It's the main language I used as an undergraduate, so I was trained in learning algorithms through it's style. Once you've used it for a bit you get used to making those pointers dance [smile]. But I agree that it's not a very beginner friendly language, and it can get mighty ugly if you don't structure your code well (same with any language, but after marking first year projects you come to appreciate languages that enforce good styles). These days I'd recommend something much more high level for the majority of your programming, with C as a good choice when you want to work low level without going to the architecture dependant craziness of assembly.

Share this post


Link to post
Share on other sites
Quote:
Variable declarations - up front and easy to see are good.
Unfortunately I don't have time to elaborate much at the moment, but I think you're a bit off base here (although you're certainly entitled to your opinion).

Declaring variables near first use is idiomatic in C++ (and other similar languages), and offers both practical and conceptual advantages. At the moment I can't think of what advantage (conceptual or practical) declaring a loop iterator (or any other variable) used halfway into a function at the top of the function body might offer, but YMMV.

Got to go at the moment, but perhaps others will comment further on this issue...

Share this post


Link to post
Share on other sites
Quote:
Original post by jyk
Declaring variables near first use is idiomatic in C++ (and other similar languages), and offers both practical and conceptual advantages. At the moment I can't think of what advantage (conceptual or practical) declaring a loop iterator (or any other variable) used halfway into a function at the top of the function body might offer, but YMMV.

I usually define all my non-loop variables at the start of a code block in languages other than C, so I don't particularly mind this restriction. It doesn't seem to matter that much having a "int i, j, k" line at the start of a function rather than defining them within the code. Most of my functions aren't long enough where it would be a problem, and since you can stick defintions at the start of any curly brace block if you really need to define a new variable inside a monster nest of while loops, you can.

Share this post


Link to post
Share on other sites

This topic is 3459 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this