FedoraForum.org - Fedora Support Forums and Community
Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2006
    Posts
    1,442

    Writing games in C language

    Friends,

    I have taught myself a bit of ANSI C. I would love to write some very basic games that can be played in a terminal only (as far as I know, C does not offer GUI support, please correct me, if I am wrong). Is there any good book on this very subject? I did search Amazon etc, but could not find anything interesting. Thanks.
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

  2. #2
    Join Date
    Jun 2005
    Location
    Montreal, Que, Canada
    Posts
    4,600

    Re: Writing games in C language

    Quote Originally Posted by tech291083
    Friends,

    I have taught myself a bit of ANSI C. I would love to write some very basic games that can be played in a terminal only (as far as I know, C does not offer GUI support, please correct me, if I am wrong). Is there any good book on this very subject? I did search Amazon etc, but could not find anything interesting. Thanks.
    C does offer GUI support. You have to do more to manage your application GUI, thats all.
    Leslie in Montreal

    Interesting web sites list
    http://forums.fedoraforum.org/showth...40#post1697840

  3. #3
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,708

    Re: Writing games in C language

    There are a variety of GUI libraries that you can use from C. GTK is probably the one to use if you want to go that way.
    (GUIs are fundamentally an object based system, so C++ is probably a better choice for GUIs, so I will put that aside for now, and concentrate on command line stuff.)

    I think writing a simple game for the command line would be an excellent way to learn more about programming.

    The simplest command line games would be text adventure games.
    ( http://home.hccnet.nl/r.helderman/ad...tpataic01.html )

    If you want something with a little more animation, without going full GUI, you could use the ncurses library. You could do a simple space invaders using that library.

    For more sophisticated games, the SDL library is quite popular.

  4. #4
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    6,669

    Re: Writing games in C language

    Quote Originally Posted by tech291083
    I have taught myself a bit of ANSI C. I would love to write some very basic games that can be played in a terminal only
    Besides Ncurses, which orcatato mentioned, some other C libraries for terminal applications are Newt and S-Lang, both of which are in the Fedora repos (dnf install newt-devel slang-devel). S-Lang applications have kind of that old DOS/Borland-style look. For example, the JED text editor (dnf install jed) is written in S-Lang, and it looks like this:

    OS: Fedora 27 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 7GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N

  5. #5
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    6,669

    Re: Writing games in C language

    You might also want to look at the source for some of the terminal-based games in the Fedora repos. For example, look at the bsd-games pacakge:
    Code:
    mkdir bsdgames-src
    cd bsdgames-src
    dnf download --source bsd-games
    rpm2cpio bsd-games-2.17-51.fc25.src.rpm | cpio -ivd
    tar xzvf bsd-games-2.17.tar.gz
    cd bsd-games-2.17
    Then look in any of the directories under bsd-games-2.17 for the C source code. I've always found this the best way to learn.
    OS: Fedora 27 x86_64 | Machine: HP Pavilion a6130n | CPU: AMD 64 X2 Dual-Core 5000+ 2.6GHz | RAM: 7GB PC5300 DDR2 | Disk: 400GB SATA | Video: ATI Radeon HD 4350 512MB | Sound: Realtek ALC888S | Ethernet: Realtek RTL8201N

  6. #6
    Join Date
    Sep 2006
    Posts
    1,442

    Re: Writing games in C language

    Sorry for the late reply, but thanks a lot, friends.
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

  7. #7
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,708

    Re: Writing games in C language

    Have you had a chance to write anything interesting ?

  8. #8
    Join Date
    Sep 2006
    Posts
    1,442

    Re: Writing games in C language

    [QUOTE=ocratato;1789310]

    GTK is probably the one to use
    Great.

    I think writing a simple game for the command line would be an excellent way to learn more about programming.
    Yes, this makes sense to me.

    without going full GUI, you could use the ncurses library.
    I will give it a try.

    Many thanks for the help so far.

    ---------- Post added at 10:46 PM ---------- Previous post was at 10:41 PM ----------

    Quote Originally Posted by RupertPupkin
    Then look in any of the directories under bsd-games-2.17 for the C source code. I've always found this the best way to learn.
    This is a great idea. This will give me a start, many thanks.

    ---------- Post added at 10:49 PM ---------- Previous post was at 10:46 PM ----------

    Quote Originally Posted by RupertPupkin
    some other C libraries for terminal applications are Newt and S-Lang
    This also looks promising to me, thanks.
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

  9. #9
    Join Date
    Jun 2005
    Location
    Montreal, Que, Canada
    Posts
    4,600

    Re: Writing games in C language

    Leslie in Montreal

    Interesting web sites list
    http://forums.fedoraforum.org/showth...40#post1697840

  10. #10
    Join Date
    Sep 2006
    Posts
    1,442

    Re: Writing games in C language

    thanks a lot.
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

  11. #11
    Join Date
    Nov 2004
    Location
    MT USA
    Posts
    886

    Re: Writing games in C language

    Mentioned but SDL2 once you progress to graphics...

    http://lazyfoo.net/tutorials/SDL/

  12. #12
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    565

    Re: Writing games in C language

    Quote Originally Posted by rclark
    Mentioned but SDL2 once you progress to graphics...

    http://lazyfoo.net/tutorials/SDL/
    Those tutorials look pretty nice and in depth! It amazes me how some of the libraries out there have absolutely crap documentation.

  13. #13
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    2,708

    Re: Writing games in C language

    Quote Originally Posted by HaydnH
    Those tutorials look pretty nice and in depth! It amazes me how some of the libraries out there have absolutely crap documentation.
    I used to tell my team that if you didn't document how to use your code, you probably wasted your time writing it.

    From what I have seen on the repositories (like SourceForge) is that a lot of the code is just a dump from their development area. It then becomes open source in name only: If there is nothing to say what its for or how to use it, it may as well be an encrypted blob.

    Of course, typically when you look at that code in detail it will often need a fair amount of work to get it into a usable state.

  14. #14
    Join Date
    Sep 2006
    Posts
    1,442

    Re: Writing games in C language

    Quote Originally Posted by rclark
    Mentioned but SDL2 once you progress to graphics...

    http://lazyfoo.net/tutorials/SDL/
    Great, thanks.
    fedoralinuxcommands.blogspot.com


    All the forces in the world are not so powerful as an idea whose time has come - Victor Hugo

Similar Threads

  1. Writing programs in Objective C language
    By tech291083 in forum Programming & Packaging
    Replies: 5
    Last Post: 8th August 2012, 12:09 PM
  2. How switch language text in Fedora Games Spin
    By xhell in forum Fedora Spins & Remixes
    Replies: 0
    Last Post: 10th June 2011, 05:23 PM
  3. Language problem (Writing in Greek)
    By dexter8 in forum Using Fedora
    Replies: 5
    Last Post: 18th October 2009, 09:32 PM
  4. Writing in another language Part 2 (different)
    By Epistax in forum Using Fedora
    Replies: 0
    Last Post: 12th December 2004, 10:27 PM
  5. Writing in another language
    By Epistax in forum Using Fedora
    Replies: 0
    Last Post: 12th December 2004, 04:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •