So, I have a question.
I need to have a three-layer deep... thing. I'm not sure if I should use a three dimensional array or something else.
What I need:
So, general classes first. A list of things like "heavy weapons", "light weapons", etc.
Then, a list of things that points to each of those. For example, under heavy weapons, "rpg", "chaingun", etc.
Then, a list of things that points to each of THOSE, that have interger values. For example, under RPG: "damage", "rateoffire", "clipsize", etc.
Would I use a three-dimensional array with this? What I would need this for, is like if the user picks up an RPG, see if it's a heavy weapon, and then if it is enable certain perks for the character. Also stuff like if the user picks up an RPG and attacks with it, see what the RPG's damage is and all that, and then check what type of weapon it is to see if those damages should be altered by any of the user's perks.
an example:
(user picks up rpg)
(attacks monster)
check stats to see what the damage and rate of fire is, along with clip size and everything else
check what type of weapon it is
if heavy weapon add ten damage
if not heavy weapon, do nothing
etc etc
Can anyone help? What type of thing should I use to.. I don't know, "declare" this?
Results 1 to 19 of 19
Thread: c++ question
- 29 Nov. 2012 04:51pm #1
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 0.00
c++ question
- 29 Nov. 2012 09:44pm #2
I'm not even going to try to fathom your question.
Just learn to C++ brah.
- 29 Nov. 2012 10:38pm #3
I don't completely understand what you're asking.
But I'm assuming what you're designing is a sort of game framework.
Reminded me of the old text based game game Zork. Someone made a version in C++ a while back.
Studying the source provided here would probably be a real help. I haven't looked through all the code but it seems similar to what you're looking for as a design outline.
If you aren't already familiar with the base concepts of object oriented design you should probably read up on them.
If you're planning to actually make this into a pretty large scale project you're going to need to maintain good modularity, which you'll probably want OOP knowledge to do in C++.
If you run into any problems, I know The Unintelligible is good at OOP concepts.
You can probably post more specific issues you run into here and people will probably attempt to help you debug the code.
Best of luck.
- 29 Nov. 2012 11:15pm #4
Oh psht. You understand the finer points of OOP probably better than I do. After all, you are a Java fag
And my C++ specific OOP knowledge would probably be limited as far as helping him directly with code goes.
He's going to need to revise and rephrase his question if he is in dire need of help though. I read the first few sentences and conceded.
- 30 Nov. 2012 12:24am #5
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 0.00
Well, think of it this way:
You have a general specification, lets say "fruit". Inside that general specification, you might have "apple," "orange," and "pear." Then, pointing to each of those, is an even more specific specification. For apple, you might have "red," "glossy," and "core" while for orange you might have "orange," "rough," and "juicy." Maybe from there you even have a pointer pointing to each thing, like say for apple, a specification of red might be "burgundy."
What would I do to have a list of information such as that one, in a convenient matter where I could, say, go "Is the value apple under the main specification of fruit?" and have it return true or false. And then from there, go "Well, is the apple red? and if so, what shade of red?" and be able to return the value of the shade of red.
Would I have to use something like a multidimensional array for this?
Sorry if my explaining is still unclear, but I don't know of a much better way to explain it.
- 30 Nov. 2012 12:29am #6
- 30 Nov. 2012 12:33am #7
A multi-dimensional array should be able to handle this.
But your general question is still too unclear. I need some context, and I need a more abstract idea or instance of what you're trying to accomplish.
- 30 Nov. 2012 12:35am #8
- 30 Nov. 2012 12:42am #9
- 30 Nov. 2012 12:43am #10
Uhm. I'm not 100% sure what you're trying to do, but I'm going to throw a basic OOP concept at you: inheritance.
A class can inherit/extend a parent class. So for instance, in your example, you might have a class called Fruit which has the general properties/procedures/functions needed by all fruit objects. You might then have an Apple class which extends from Fruit. It would therefore have all of its parent's (Fruits) properties/methods, and also have methods specific to apples. You might then have a RedApple class that extends from Apple. It would have all of Apple's properties/methods (and by extension Fruit's properties/methods) and then methods/properties specific to Red Apples.
- 30 Nov. 2012 12:46am #11
General concepts OP should look in to: OOP in C++, pointers, arrays.
What Artifcial said might be the best answer though. I cannot for the life of me comprehend what you're saying lol.
Edit: 2k posts. Says I'm "elite" now. Don't I feel cool.
- 30 Nov. 2012 12:55am #12
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 0.00
That's actually extremely helpful, thank you.
Also, to the others:
What the big picture is:
I need this for the game/game engine I'm working on.
The class (Game-wise, not programming-wise) has a perk that gives it x2 damage if it's holding a dagger.
I would need to make a statement to check if the x2 damage should be activated or not.
If playerweaponclass = light weapon //if the player has a light weapon
then
if playerweaponspec = dagger //check if that light weapon is a dagger
then
playerattack = playerattack * 2 //if it is, multiply the player's attack by 2
Where playerattack is the weapon's attack, the player's base attack stat, and any other additional attack stats from items all combined into one value (all added up)
I'd be happy to give another example if that STILL isn't clear enough, haha.
- 30 Nov. 2012 01:12am #13
- 30 Nov. 2012 03:37am #14
so now u think u a damn video game designer or something? lel
- 30 Nov. 2012 03:42am #15
- 30 Nov. 2012 03:44am #16
dis guy too much. stick to hackforums
- 30 Nov. 2012 04:28pm #17
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 0.00
Lol, I have, like, project-ADHD. I move from project to project to project. I gave up on the Gaia Java Login because I didn't know how to POST The right login parameters, because besides username and password there's a bunch of other parameters that I don't know how to randomly generate. So, then I moved onto a game that I had been working on a few years ago, and had been putting off. I have about 15% of the game engine done, and I've selected a graphics engine but haven't implemented it yet. I just need to finish up the class selection system and then I can move onto weapon stats, physics engine, and the main storyline and everything.
- 30 Nov. 2012 10:51pm #18
If you stick a project through to the end rather than abandon it when you get stuck, you'll learn a lot more. As for the login, you don't need to generate anything. Gaia Online does all of that. You go to the website, grab the values they've generated, and post them.
- 01 Dec. 2012 01:05am #19
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 0.00
Yeah, I know that, but my problem is that no one wants to help me. All of my projects require other people helping me, as they're things that aren't normally documented in programming guides, and I can never get answers on any other online programming forums. Like the Gaia Login: I asked, but no one seemed to want to help, so I just abandoned it. As for this game engine that I'm working on, I had abandoned it before because I had absolutely no idea how to program a game engine, much less how to program in general.
And one other question, how would I grab the values? Would I somehow have to parse the page for the input fields, or the input field names or something? Or would there be some simpler way to do it? Sorry for all of the questions.Last edited by 323; 01 Dec. 2012 at 01:13am.