News:

11 March 2016 - Forum Rules

Main Menu

Trouble with card game I'm making..

Started by InfamousKnight, February 26, 2013, 10:42:15 PM

Previous topic - Next topic

InfamousKnight

So I'm making a triple triad clone from ff8. But it appears its telling me that I never declared the variables I returned..

here's the code:
http://pastebin.com/tt5WiGDa

Doesn't do a whole lot so far. Just assigns values. And one more thing, is there an easier way of doing this? I'm still learning and I'm sure everyone else is too.

Klarth

#1
Short version: You forgot a semicolon after declaring cards edeck[6].
Long version: There's a lot that needs to be cleaned up. I'll try to work on a version that drastically improves the readability if I have time to complete it.

http://pastebin.com/VUYkUCFR is a reworked version. I may be willing to do a more complete rework once the game is in a playable state and some complexity is added.

LostTemplar

@Klarth's (clearly a thousand times more readable) rewrite: Just nit-picking here, but I think it would be better to use the initializer list and write


card(string cardName, int top, int left, int right, int bottom, bool side)
  : CardName(cardName), Top(top), Left(left), Right(right), Bottom(bottom), Side(side) {}


instead of manually assigning the values within the constructor. This might not make a big difference here, but it's best to adopt good practices early on.

@IK: Also, if the complexity further grows, I'd divide main() into smaller functions that are reuseable and can be maintained better, for example "clearing the board", "initialize players' cards" and "game loop".

FAST6191

I will spare you my lousy C++ skills but I do wish to point out there is a nice clone game for the DS with source you might like to have a look at
http://gamebrew.org/wiki/Triple_Triad_DS

InfamousKnight

What's up with this line:

cin >> input;
PlayerDeck[i] = PlayerCards[input];


Does that like inherit everything from one struct to the other? I didn't put that in there.

LostTemplar

It calls the assignment operator method that's defined for that struct/class. The default implementation provided by the compiler just copies all data from one instance to the other.

InfamousKnight

#6
That is so cool! I didn't know about that.. I'm thinking about using that in my battlesystem! But I want to finish this card game first.

Thanks for shortening my code!

February 27, 2013, 04:53:45 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

One more thing, why isn't my map appearing?
http://pastebin.com/iecLWM2x

It all starts on line 106. It doesn't output anything.

Klarth

Quote from: LostTemplar on February 27, 2013, 05:45:34 AMJust nit-picking here, but I think it would be better to use the initializer list
Fair enough, good suggestion!  Also, I didn't break it up into functions because I didn't know exactly where he was going with the code yet.  It can still be substantially cleaner.

Quote from: InfamousKnight on February 27, 2013, 12:59:50 PM
One more thing, why isn't my map appearing?
for(int x = 3; x < 3; x++)

Take a bit to think about that!  Same deal with the inner y loop.  Hint: The loop is never executed.

InfamousKnight

I can't believe I didn't notice that.. Thanks!

syntax error

in FF8 PC the cards are in the executable.