help with SuperSmashBro's like game

Started by
8 comments, last by Dragonsoulj 12 years, 7 months ago
I dont have any problems with the code yet, but i was wondering how i would send information from the character selection page to the actual game stage.

Like, there are 4 tokens, and you can drag each to one of 6 characters. I need the game stage to know which characters were chosen.

Im not really looking for code, but more of just a push in the right direction
Advertisement
What language/tools are you using?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

Im using c++ with sdl.
I started brainstorming and came up with this:


character selection state
Get the coordinates where p1 dropped his token
match the coordinates with the character
store the character's number in an array

( do the same with all four players )

then somehow pass the array to Game() as a parameter. This would be hard to do ( unless characterSelection() can return an array? ) because Game() is called from main in my state machine.
You can't really return an array, but you can return a pointer which points to its first element. Or you could return a std::vector, although I'd recommend passing the vector by reference to SelectCharacters() instead. Or store character selection in your Player class.
Okay so i could pass an empty vector by reference to SelectCharacters() from the state machine, fill it up, then since it was a reference it will be changed in the state machine so i could send the same vector to Game()? Would that work and be the easiest of your choices?
Yes, it will work. Whether it's your easiest option Can't be determined without knowing a lot more about your game's design. If you can't foresee any problems with it then use it. It's probably not an ideal technique, but it's unlikely your game is ideally structured ;) Which is okay, so long as it works.
I have a problem.

I need to modify the vector in SelectCharacters::Logic(). How can i take the vector that is passed to SelectCharacters::SelectCharacters() and move it to its Logic function?
[font=verdana, arial, helvetica, sans-serif]Let me give you an example of what i want to happen.

In SuperSmashBrothersBrawl there is a screen where you can pick to play multiplayer. Lets say that is STATE_MENU. You click to play and a screen comes up where you can choose your characters, or STATE_CHARSELECT. Then another screen comes to choose the stage you would like to play on, or STATE_MAPSELECT. After all that, you can they play the game with the selected characters on the selected map.


My problem is that the way my state machine is set up, i cant figure out a way to do that^^. So im asking you to help me fix me state machine so that it would be possible to do the above.[/font]
Perhaps rework it some? I think I found one of your stack based state machine posts so I think I understand what you are doing.

Push Game onto the stack.
Create a blank game, without the characters or map selected.
Push Map Select onto the stack.
Push Character Select onto the stack
Select Characters and store choice into game created. Pop Character Select.
Select Map and store choice into game created. Pop Map Select.
Load game options (Set everything needed)
Run game. When finished, Pop Game.


EDIT: Perhaps reversing where the Select and Pops occur, ie Pop Character Select and then Select Characters and store choice into game created. Depending on where you execute things. (Not sure if when you pop a state off you execute the state popped - the reason for the edit - or if you work on the top of the stack and then remove it - the original part of my post.)

This topic is closed to new replies.

Advertisement