• Forum
  • Lounge
  • Thinking about writing a series of artic

 
Thinking about writing a series of articles

So,

Now I have some free time, I have been thinking about writing some well written, structured articles about C++ and programming in general.

My aim is to write good quality, platform independent articles that follow on from each other in a structured manor. When searching the internet, I get millions of pages, most of which are half assed, less than a paragraph answer to an ambiguous question.

Another thing I often witness is that most, if not all examples are generic foo/bar examples, which I find myself truly hating, when coming across these examples I often wonder "Why don't you bother to write good quality content? Something that can be used in a actual project?"


My idea is that these articles are going to be chapters in a book, and when reading and following the articles at the end they will have something real to use. Such as the SFML book, that takes you from nothing to a complete working game (Or so I've heard).

Some of the ideas I have in mind are:

A text based RPG game

The game will be an ASCII based console game. The user can choose a class, level up skills, level up it's character, fight monsters, collect items etc etc. Imagine a text based "Runescape" or "World of Warcraft"

I am also going to try and do this with server/client in the future so multiple people can connect and play at the same time.


Writing a database program.

The database could be anything, but the project is to teach major data handling and object orientated code. I have seen replicated questions about "Reading contents from a file and storing them into an array" etc etc, so this should come in useful for CS students.


Creating a user made library of useful functions.

This unit would be to teach the important of reusable code, code which can be written once and transfered to other projects with ease. It seems people new to programming ignore the fact they write code which can be used over and over again. I want to create a library with both functions, structs and classes which can be included and linked. The idea I'm hoping will also show how the compiling and linking process works and why it is powerful asset to create an object file and link it when needed.


Writing a Server/Client chat and FTP program using the SFML network library.

This is by far the most interesting thing I have written, and felt like my programming actually meant something rather than standard console IO. Again this was written in the console. I'm not sure whether students would like the SFML installation process for the network library over raw socket programming. I haven't done the FTP part yet, but I imagine reading a file into a byte array and sending it over and rebuilding it at the other end over TCP should suffice. I ought to touch up on some encryption routines too ( Which could be put in the library )



I have offloaded all this from my head and any comments, or even an extra pair of hands are welcome. If there is something I have missed please let me know.

I find the articles section of this website to be... unorganised. There are some great articles in there, but they don't seem to bridge the gap from beginner to "how to start using C++" for me. The beginners tutorial on this websites is great at explaining key concepts and how they would be used, but the examples are trivial with no real depth. Although I learned my programming from this website, I fondly recall yelling at my screen why the examples are so small and leave me with hundreds of questions.


I'd really like some advice, comments or even pointers on this, as I'm hoping it to be a worthwhile project, that would both help our community and strengthen my own programming.

Cheers,
closed account (EwCjE3v7)
Well it would be nice if you could setup a github page for each one. So we can help out with it aswell. I believe we already have a cplusplus group.

But again if you want to do it yourself, that's fine aswell
Well it would be nice if you could setup a github page for each one.


As this is supposed to be actual teaching material rather than a scaled project, I'm not fully sure how to incorporate both, I was thinking more of a book rather than numerous source files. I imagine it would be hard documenting code from several people, people who can be tricky to get a hold of for a full explanation of code.
The game will be an ASCII based console game.


*Grinds teeth*

Please do not encourage this.
> The game will be an ASCII a text based console game.

This is an excellent approach; an article on writing a back-end that is instructive, focusses on programming techniques and logic; and eschews unprincipled hacking with poorly designed libraries. Such an article could be really helpful to beginners.

As a follow up, it could be extended with a couple of graphical front-end clients; ideally, at least one of them in a programming language other than C++. That would illustrate a fundamental principle of good architecture: loosely coupled non-monolithic components that cooperate with each other, each one doing one thing and doing that thing well.
Disch wrote:

*Grinds teeth*

Please do not encourage this.


I understand, I forgot people really dislike using the console for games programming. As much as I do not want to encourage "bad practice", I would like to get down various logic and concepts. I have read up on games such as rogue and netHack, I've been trying to use ncurses, and currently trying to develop an object orientated C++ wrapper ( If anyone is interested is helping, please PM me because my curses knowledge is terrible )

I was going to use the same kind of cycle which would be used in other media programming (The Draw-Input-Update loop)


JLBorges wrote:

This is an excellent approach; an article on writing a back-end that is instructive, focusses on programming techniques and logic; and eschews unprincipled hacking with poorly designed libraries. Such an article could be really helpful to beginners.


I don't know whether it's because I have just woke up, but I can't tell if that is sarcasm or not? Purely because of Disch's response.


If the game idea is a bad one, I'll pull it out, but I'm still going to work on mine. :)

However I would like to replace it with something else if it is considered bad programming material.
Last edited on
> I can't tell if that is sarcasm or not?

It was not sarcasm. There is quite a bit to learnt from designing a text based protocol to communicate between the back-end (core game logic) and the front-end (presentation/user input).

Consider the possibilities: text (console) based single client linked into the same executable, more than one such client (say, Python clients) distributed over a network; different GUI clients on different platforms; the back-end on a web server with browser clients (say, javascript) ...

So, now you have two completely contrary views on this; think about it and make your own decision. Above all, think about it.
So, now you have two completely contrary views on this; think about it and make your own decision.


This is where I usually say "But I always look to those who came before me to determine what route I take" but now, I don't know what to do about it.

I know that I have learned a lot (And keep learning to do so) from writing a text based RPG, I have read that "The console isn't designed for games" etc etc, but I don't understand why, just because something isn't meant for a game, doesn't mean it can't be turned into one. Like in the old days, kids using a stick to whip a bike tyre down the road was considered fun and they made a game out of it. I pretty much use the same logic. I understand a stick and a rusty bike tyre might not be the greatest tools to make a game from, but many of us are happy to make do.

For instance my nephew loves to watch me develop my ASCII game, getting my '@' sign moving about the screen, he liked watching that much he turned his xbox off. If I can invoke this creativity and wonder in other people no matter young or old, I'd die a happy man.


Consider the possibilities: text (console) based single client linked into the same executable, more than one such client (say, Python clients) distributed over a network; different GUI clients on different platforms; the back-end on a web server with browser clients (say, javascript) ...


Now you are starting to loose me before I have begun, hah. You do like making me think JLB.

So I should write a single back-end in C++ and write several client programs in different languages? I only know C++ to this level, unfortunately.
> So I should write a single back-end in C++ and write several client programs in different languages?
> I only know C++ to this level, unfortunately.

Why not start with a single C++ program which contains both the parts: the back-end and a text based front-end?

Perhaps, in such a way that you do not paint yourself into a corner; in such a way that the other possibilities continue to remain genuine possibilities; in such a way that if either you or someone else becomes interested, it could be extended without breaking the core game logic.
I try to encapsulate all my code, especially core logic from the interface. I can do them both in the same program easily enough; but how would I say, be able to use a separate language for a part of a program. How could I get a Python program to interact with my C++ program?

EDIT: Or should I say, link python code to C++ code.
Last edited on
Console is fine if you either
— write a game which works fine with stream ideology: does not mess with system console handling, does not need advanced controls (screen clearing, disabling scrolling etc.). Something like text adventure would be fine.
— Do not use standard C/C++ stream facilities. You will need to recreate ncurses create your own library which would handle things like creation of different "windows" you can easily control, wrapping platform-dependend stuff like screen and cursor manipuilation, maybe limited mouse support. Something that looks like early Borland products will be extremely awesome. If it would be written according to C++ ideology (unlike ncurses, which is C library) it would be doubly so.
In addition it will give you a chance to show how portable libraries are created.
> How could I get a Python program to interact with my C++ program?

The most flexible would be separate processes communicating through some form of IPC; say, through BSD Sockets (which is supported everywhere). Using the aforementioned 'text based protocol to communicate between the back-end and the front-end'.

By the way, I'm not suggesting that you do not use a library: use curses, SDL, tkinter, Pygame, whatever makes the task easier for you. I'm merely suggesting that the presentation logic should not be tightly coupled with he game logic. That it should be easy to add, say, a Java front-end without breaking the core game logic.
@MiiNiPaa

If you mean like : http://img1.wikia.nocookie.net/__cb20071210155316/borlandpascal/images/5/54/Hello_world.png

This is what I'd love to go for, I'm trying to make a C++ wrapper for ncurses, but my knowledge of ncurses is slow, if you would like to give me a hand, I'd much appreciate it.

I'm not sure how to "create my own library to handle windows" and such. I'll try and jot down some ideas and see where I get.


@JLB

Hmm right, I do have SFML installed, though I haven't used it for graphics yet. My curses is.. crap I won't lie, but I have made 2 test objects, a menu and a textbox, I would like to make an input box next, then I could use just those 3 to write a game with.

However something I should note - I would prefer not use anything but the standard, if this article is meant for beginners, on their first lesson they shouldn't have to download and install a library, and it's something I don't have much knowledge on myself.
However something I should note - I would prefer not use anything but the standard, if this article is meant for beginners, on their first lesson they shouldn't have to download and install a library, and it's something I don't have much knowledge on myself.

IMO you should reevaluate your stance on that. Downloading and using a library is A.) 100% necessary and practical knowledge and B.) Not at all difficult, especially if it has a nice set of pre-compiled options like SFML does.

I'm just curious but; why wouldn't the database be the first project? Wouldn't this be necessary in a game like the one you are describing anyway? Please don't tell us that you were planning on hard coding things like interactive items and\or NPCs.
I'm not sure how to "create my own library to handle windows" and such.
If you are not sure how to do that. leave it for now. To teach something you do not know wery well is not a good idea. Use some ready library, just be ready to explain why you are doing it this way and not other.

> I would prefer not use anything but the standard, if this article is meant for beginners,
> on their first lesson they shouldn't have to download and install a library,

Yes, agree with that.

With poorly designed libraries like SFML, there is also the risk of permanent harm to beginners.
http://www.cplusplus.com/forum/lounge/147934/#msg776287
@Computergeek01

Hey, thank you for joining this thread.

IMO you should reevaluate your stance on that. Downloading and using a library is A.) 100% necessary and practical knowledge and B.) Not at all difficult, especially if it has a nice set of pre-compiled options like SFML does.


I do completely agree with you and I understand I may not have been clear.

I will incorporate downloading and installing libraries, but not around the start. Although it may not be complicated it, may look complicated to new readers. I know I have done this with templates; because it looked complicated to me, I never approached it.

I'm just curious but; why wouldn't the database be the first project? Wouldn't this be necessary in a game like the one you are describing anyway? Please don't tell us that you were planning on hard coding things like interactive items and\or NPCs.


Quite the opposite, I listed them in no particular order. I was just thinking of things and writing them down sorry about that. I was thinking about building them up gradually as the game progresses. The items would be in files, and the items themselves derived from a base class, and the inventory being a vector of pointers to base classes. Something along those longs I haven't thought too far ahead, I want to make sure I plan this right.


@MiiNiPaa

Yeah I agree, I don't want to go too far out of my knowledge, not knowing things would be great because it would get me to learn it, but, I don't think the world is ready for me to teach complex template meta-programing ;)

@JLB

Hm I never noticed that, I really will consider how my classes and functions are written, probably going through a lot of test phases before I add it to the master.



As I mentioned before, I cannot do this alone. I will need the experience of all of you guys to get this draft finished. I see how people complain at professors for not teaching things correctly, perhaps it's time to raise the bar, and create a well written journal, like the big book of medical stuff, but for programming. A tome of knowledge passed through the ages. I'd really like to see in my lifetime good free resources for people to use and change and alter with new experiences. A complete goto for C++ and programming techniques.


EDIT:

I would really like someone to make a great guide on makefiles for me to use, full credits will be given of course but I don't know anything about copyright and licensing.

EDIT2: Duoas? - http://www.cplusplus.com/forum/unices/12499/ - That last comment is exactly the kind of thing I am trying to accomplish.
Last edited on
Topic archived. No new replies allowed.