![]() |
C++ Knowledge
Afternoon FF, I just wanted to make a little callout to see if anyone on here had knowledge of the programming language C++. Long story short I'm about to start a project using this language and knowing that I could contact a member of the forums if I got particularly stumped would help.
So... Anyone know it ? |
I'm trying to learn C++ right now too. I've written a few C console programs years ago, and been doing lots of PHP lately. C++ seems... hard.
Are you doing something with a windows GUI or just a console application? |
Aw, I learned a bit of C, not C++ D:
|
Quote:
|
You can count on me. :) Except with graphics stuff.
|
Good to hear Vasu :D As I said there's no graphics involved, I just need someone I can ask questions if I get stuck with a bit of code.
|
Oh, you could've mentioned zork was an interactive fiction. Yeah sure, I can help. C++ is not too much harder than C. If you grasp the basic differences between the languages, then they might as well be the same, however crazy that may sound. :D
|
Good luck, everyone. 8)
|
Bleh, my original plan was to have locations linked to a series of X, Y and Z co-ordinates and then through commands issued by the user the player could move through a grid format with if clauses. However this means there are no boundaries, so I've had to scrap it all and now I'm researching into Arrays and sub strings to get it to work.
|
Since we're not going to be displaying any grids anyway, you can use simple location IDs. I DL'ed and played a bit of Zork, and there is not much scope for movement within a location, so we can have it similar to that. You can have various states based on the location ID. Each location can be the object of a class, with the following properties:
Basically the most important thing to do in OOP is to draw out a list of the various types of objects that you may use within the game such as "Location", "Item", "NPC". Then when it comes to taking the input, you'll need to really be able to work with strings and separate them out and stuff. C and C++ are really 2 of the worst languages for handling strings, so you'll definitely have your work cut out for you. Basically you'll need to form an exhaustive list of verbs, nouns and conjunctions if you're using those which will be checked against each time they type something in. Form a structure for the input. In Zork it seems to be <verb> <noun> or <verb> <conjunction> <noun>. I realise you may already have a lot of this planned out, I'm just trying to show how I would approach the problem. |
Quote:
Inside each section of the array will be a string of 4 letters (eg, "FTTF") which the code will use to determine where it is allowed to move, if the first letter is our ability to go North and it equals F then we cant go north from that area, etc. We can use sub strings to enforce this. Thats my current general plan anyway, this project definitely seems a lot more complex than when I had first envisioned it :P |
Actually, you can just add a single dimensional array as a property within the "location" class which holds 10 integers, each one corresponding to a particular direction. For example, the array could be:
{N,E,W,S,NE,NW,SE,SW,Up,Down} For a particular room, the array might read: {1,0,0,1,0,0,0,0,1,0} which means that he can move north, south and up, but not anywhere else. |
Quote:
And without a multidimensional array wouldnt all the 'areas' lie across the X axis ? meaning that North/South wouldnt take you anywhere. EDIT: Since instead of having to initiate all the variables like this: bool directionUp = true; bool directionDown = true; bool directionEast = true; bool directionNorth = true; etc... I could just put string directionset = "TTTFFT..etc" |
Yeah, I suppose characters do occupy less space than integers, so you can go with the string.
Also I didn't understand what you were saying about the multi-dimensional arrays earlier, but yeah, I guess you'll need a 3D array of pointers which point to particular location objects on the "map". EDIT: Actually, I think using a grid map is a little elaborate. You could just alter the permission string you're using from something like "TFFTFFFT" into {"Meadow","F","F","Living Room","F","F","F","Riverside"}, so that you automatically have the list of accessible locations and their direction. Or if you're using location IDs which I suggest, you can just do {23,0,0,18,0,0,0,7} or something like that. |
All times are GMT. The time now is 09:25 AM. |
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.