• Advertisement
Sign in to follow this  

To Start Anew?

This topic is 2265 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

Hello everyone,

New to the forums here. I've been self-teaching myself C++ for a little over a year now (off and on, unfortunately), and I thought it would be best to get involved in a community of some sort, mainly because I don't know anyone who actually programs. I'm mainly posting because I've run into a predicament that I thought some more experienced programmers could help with.

As I said, I'm self-taught to this point. I've been using Teach Yourself C++ in 21 days and C++ Without Fear, and I've covered variables, loops, some arrays and pointers, references, classes, and a little inheritance. I then programmed a text based game based on those old graphing calculator drug-running games from high school. The game was heavy on loops and arrays, and it actually worked for what I had programmed. However, I essentially stopped the project because I felt like I had learned what I wanted to learn.

Having no project in mind, I took a hiatus for a month or so. Lately I've been trying to get allegro or SFML to work in code:blocks, and I've had some horrible defeats recently. I'm finding that I have little to no knowledge of how directories work. I keep running into outdated tutorials, nondescript tutorials, or terminology I'm simply not familiar with. Directories, linkers, environment variables, libraries, so on and so forth. I'm not sure if this is a direct result of how I've approached programming, or it's simply unfamiliarity with Windows 7, or something totally different.

I have no grand intentions to program the next minecraft or angry birds. I actually really like the idea of starting a roguelike. I have also been kicking around a mix of Call of Duty Zombies, Dwarf Fortress, and Tower Defense. I don't even mind if the game is actually represented by graphics or ASCII characters. However, this block with Allegro and SFML has really stumped me even though it seems like it should be incredibly easy (seriously, I just want a window to open, that's it). So, I've been researching and putting in the sweat, and now I'm questioning whether I should switch languages to Python or C#. Any suggestions the community could offer with setting up a graphics library, how to approach the task of learning to program, whether switching to a new language is a good idea, tutorials on including libraries, etc would be greatly appreciated.

Best wishes,
W.

Share this post


Link to post
Share on other sites
Advertisement
I'd look into C# or python. You've learned enough programming that the jump won't be too much of a step backwards and you'll quickly appreciate how much pain C++ has put you through.

Share this post


Link to post
Share on other sites

I'd look into C# or python. You've learned enough programming that the jump won't be too much of a step backwards and you'll quickly appreciate how much pain C++ has put you through.


I've been wondering about this. I actually don't think of C++ being hard, but I'm starting to think it's because I don't have anything to compare it to. Just as you said, I might make a switch and then realize how rough C++ can be. It seems like Python is really popular, but would C# be an easier conversion considering my C++ experience? On a side note, major noob question, is C# pronounced "C number"?

I was reading about Roguelikes, and I did see quite a few of them are written in Python. I think I'm really leaning towards a switch here. It's not like I couldn't switch back to C++ in the future. In fact, my understanding is that Dwarf Fortress was written in C# and converted to C++.

Does anyone have suggestions for learning programming? I really learned a lot from writing my text based game. Did anyone try using a specific program idea to help learn the skill?

Share this post


Link to post
Share on other sites
The problems you are having aren't related to language, but of setting up a project. You want to get SFML working in a code::blocks project, which isn't too difficult IF you know what you are supposed to be doing.

Let me point you to a project I made using SFML in my blog:
http://2dgamemaking.blogspot.com/2011/10/smashpc-is-started.html

You'll see some snapshots of where I setup the compiler settings and the linker settings for SFML (and other libraries). I use SFML, but I would suggest you stick to SFML 1.6 since it's fully stable.

The main points from the link above is making sure, after setting up a simple console application, in the Project->Build Options window:

In the linker setting, you want to make sure you include, in other linker options the -lsfml options I listed.
What this means is, your project will be using the SFML libraries when it links. Compiling is the act of taking a single source file, and compiling it into machine code, but linking is the act of taking all the compilers output (including libraries, which is a combination of many compiled files) and tying it all together into a single binary executable.

In the Search Directories, under the Compiler tab, you want to make sure you include the folders that hold the include folders for SFML. This is so the compiler knows where to look for the files you #include
Also in Search Directories, under the Linker tab, you want to point to the directory where the SFML libraries are located. Typically it's in the bin/lib folder, and the libraries end in .a or .dll (occasionally you'll see .lib extensions).

Once you do that, continue in that post, and there's some example code of setting up a simple SFML window.

Good Luck.

Share this post


Link to post
Share on other sites

The problems you are having aren't related to language, but of setting up a project. You want to get SFML working in a code::blocks project, which isn't too difficult IF you know what you are supposed to be doing.

Let me point you to a project I made using SFML in my blog:
http://2dgamemaking....is-started.html

You'll see some snapshots of where I setup the compiler settings and the linker settings for SFML (and other libraries). I use SFML, but I would suggest you stick to SFML 1.6 since it's fully stable.

The main points from the link above is making sure, after setting up a simple console application, in the Project->Build Options window:

In the linker setting, you want to make sure you include, in other linker options the -lsfml options I listed.
What this means is, your project will be using the SFML libraries when it links. Compiling is the act of taking a single source file, and compiling it into machine code, but linking is the act of taking all the compilers output (including libraries, which is a combination of many compiled files) and tying it all together into a single binary executable.

In the Search Directories, under the Compiler tab, you want to make sure you include the folders that hold the include folders for SFML. This is so the compiler knows where to look for the files you #include
Also in Search Directories, under the Linker tab, you want to point to the directory where the SFML libraries are located. Typically it's in the bin/lib folder, and the libraries end in .a or .dll (occasionally you'll see .lib extensions).

Once you do that, continue in that post, and there's some example code of setting up a simple SFML window.

Good Luck.


OMG! I remember playing SmashTV! I used to play the 1-player/2 controller setting on Nintendo. Good stuff. I'm going to take a look at your link and give it a shot. Though it might be a couple days, I'll post back with results. Thanks for the link!

I do need to learn how to set up projects. I imagine that will be an issue regardless of what language I use. The text game I wrote was all in one .cpp file, which might suggest how limited my knowledge is when setting up a program. I started to re-write it using .h files for my classes, but honestly didn't have the motivation to re-write the whole thing. Maybe something worth re-visiting?


Share this post


Link to post
Share on other sites

The problems you are having aren't related to language, but of setting up a project.

*snip 5 paragraphs of instructions*


Or, in C#: right click on your project references, pick/navigate to the library dll you're using.

Sorry, C++'s retarded compilation model makes these things way more difficult than they should be.

Share this post


Link to post
Share on other sites
We are in very similar situations. I have been teaching myself C++, and using the SFML libraries.
I am about halfway through developing my first game and it has been a lot of fun. (and lots of work).
C++ is a great language to learn. But you won't really be able to use and understand SFML or any
other library for that matter until you have completed all of the basics.

That includes:
Classes, Polymorphism, STL, Templates, Methods, Virtual Functions, everything.
(most libraries will use it all.)

Also it wouldn't hurt to read a book about the IDE you chose.

It sounds like you have some grasp of C++ but from your post it sounds like a half knowledge of the language.
Having a half knowledge of the language and then trying to use 3rd party libraries is similar to
learning enough chinese to order coffee in the morning and ask for directions, and then trying
to sit through an advanced college course in particle physics entirely in the chinese language.
You really need the fundamentals of the language first, before you can do something useful with it.

"Teach Yourself C++ in 21 days" is a somewhat deceptive title. It sells the book but leaves you with
the impression that you can learn the language in just 3 weeks. It may take a few months to get
comfortable and it will take a minimum of one year every day to get good.

Take it slow...

Find a book you like, go through the whole thing, make sure you pass all of the tests at the end of
the chapters, and then you are ready to start using third party libraries. I really liked Ivo Horton's
Beginning Visual C++ 2010, but I am sure there are plenty of other's to chose from.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That being said. If you chose to abandon C++ altogether. Everyone here seems to think that
C# or Python is the way to go. I totally disagree. For making games yes they are great but
If I had to start again, I would go Flash or HTML5. In terms of game quality, they are not as
strong but....

Both of those languages have 2 huge advantages. No installation. You can write a game,
stick it on the web, and people can play it immediately. Many people don't like to download and
install things. They are afraid of viruses, a lot of older users don't even know how to install
a program, seriously. A download is a barrier.

If you do Flash or HTML5 those issues are gone. You can put it on Facebook. If the game is good lots of people will
come. You can have an arcade site sponsor the game, and even get a little bit of cash out of it
from a site like flashgamelicensing.com. Or you can make your own arcade site and if your games
are good enough you will get enough traffic to start making a little bit of cash selling ad space.
Enough to quit your day job, probably not. But it is conceivable to make up to a few thousand USD per
month from a successful arcade site. Big sites like FreeOnlineGames.com, miniclip, y8games
are making several hundred thousand per month selling ads on silly little flash games.

Even if making money is not the goal, there is a huge advantage in having a game that someone
can just land on a URL and play.

Just my thoughts

Share this post


Link to post
Share on other sites
bu ba bugga hu ma bu wait... you're issue has nothing do do with programming language... ok 99% of it doesn't. What you're having problems with is finding stuff in your ide. Now take a deep breathe and don't give up. If you've been learning C++, despite it's difficulties Id stick with it. The jump to other languages won't be that hard later on, but a jump this early maybe be discouraging making oyu more likely to give up. Comming from QBasic + ASM in Dos, it took me a good part of 2 years before I was comfortable enough with C++ to not have this 900page purple reference book around at all times.

if codeblocks is giving you a hard time, hell even if it ain't. If you're on a windows machine, I'd highly suggest getting visual studio (the express versions are completely free, and the features that aren't present you'll probably never need as a hobby/indie dev). Plus the vast majority of tut's use visualstudio, and are up to date.

P.S. what projects (no matter how small) or apps have you completed. Have you done and completed any of the tasks in the books you're learning from. I ask just to get a better understanding of your abilities.

Here's a great program you can write to help better understand the language, and it can all be done in the console so need for third party graphics api's.

You know those choose your own path, story books. The ones were at the end of each page you have to make a descision on how the story goes and then go to that page, to continue the story. Try making a simple app that tells the player a little bit of a story, then gives them choice, that determines how the story will play out.

ie

"Sally is walking her dog down the sidewalk, when she sees a nother dog ahead."

Choose, does she stay on this side of the road, or cross to the other side to avoid the dog.

Depending on the answer you would output the next part of the story, and so. If you need more help don't be afraid to post more or message me here. I'm always willing to lend a helping hand when it's within my abilities.

Share this post


Link to post
Share on other sites
Some questions about how far I've gone with C++, so I thought I'd include a description of the text game I had worked on for a little over a month I'd say. The game is called Gangland, I imagine most people are familiar with games where you buy a drug from one dealer and try to sell it at a profit somewhere else (I'm still not crazy about centering the game on drugs, and I actually considered converting it to a space smuggler setting or something like that. Anyway, it was just to challenge myself and I never intended it to be public or anything so I kept the drug theme haha). At this point, it has a class "Dealer" which includes the dealer's name, city, and several arrays that include his chances to have a certain drug on any given day, base price, a random price adjustment, quantity of each drug. Essentially, each dealer has a base percent chance of having a drug in stock, and a base quantity. The game cycles through the entire array using a for loop, determines with a random number whether the dealer has the product, and, if so, rolls again to add base quantity with the random quantity.

The game has menus that include: Travel (to a city), Visit (one of four dealers within a city), Gas (visit the gas station), Check Supplies (menu of items, money, total car mileage, gas tank, etc), Quit. I figured time by having every action take x number of minutes and breaking minutes into hours -> days -> months -> years. Each dealer has his own trigger for getting a new line of products. The first guy refreshes his stock every day, but others may only refresh every week or so. I also have booleans to prevent the player from traveling to all the cities or all the dealers. Essentially, my plan was for the player to develop relationships with the dealers who would then introduce them to new dealers. Travel between cities takes its toll on your money, the condition of your car, etc. I also wanted to implement law, and I was in the process of adding a city class which would track the local economy and police presence, among other things. All the menus and game options have been checked for errors; i.e. you can't fill your gas tank past full and you can't have less than 0 gallons, you can't buy anything unless you have sufficient money, and you can't buy anything unless the dealer has it in stock.

All this is included in 1060 lines of a single .cpp file. When I started the "beta" project, I wanted to have files included in main. However, I'm not sure I really have any idea what should be in my main .cpp and what should be included from another file. I also wanted to implement some inheritance to dealers, perhaps having sub-classes like "Small Time Dealer" and "Cartel Member" and so on. Hopefully this gives a little idea of what I've done with C++ so far. Thanks for all your posts so far. I'm beginning to feel motivated to start learning again.

Share this post


Link to post
Share on other sites
... I know I'm off-topic, but I congratulate you on keeping 1060 lines of code in a single cpp file XD That must've been one heck of a complicated game. When I was writing a 2D sidescroller, the game was only about 4000 lines, but at the same time, I was using Java, so that's a little different from C++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement