### Making a Board Game on Stencyl

#### magicpegasus

• Posts: 101
Hello,
I'm ready to dive into my 2nd Stencyl game...title TBA soon, but first I need help from you wonderful people of the Stencyl community.

Any ideas on how to begin making a board game on Stencyl? I want to start simple, like Monopoly but with less spaces. My game will be kind of like Mario Party, in that I want the player to "roll" the dice and move the determined number of spaces.

I can't wrap my head around the logic it would take to do this kind of linear movement. I have the board set up with 16 spaces, and I want to use one dice, so the player could move 1-6 spaces each roll.

Any help/advice is greatly appreciated! If there is a kit available, I couldn't find it. Perhaps my game will be converted into the first kit

Thanks a lot!
Magicpegasus

#### Hectate

• Posts: 4645
Assuming that the board is entirely linear (even if it loops around) you could use a list to keep track of the "spaces" that the player icons can occupy. In the list, each item would be pixel coordinates using comma delimited values for each of the spaces. Then, use a number attribute for your icon actors to determine which space they're on. When the player rolls the dice, increment the number as needed.

Example:

Your list of spaces looks like this...
Item 0 : 100,150
Item 1 : 200,250
Item 2 : 300,350
Item 3 : 400,450

Then the icon actor's "Space" attribute (a number) is set for 0, 1, 2, or 3. A behavior checks that value, and pulls the appropriate matching item from the space list to set the X,Y values of the icon. For example, if Space == 1, set X of self to (first half of item 1) 200 and set Y of self to (second half) to 250.

Rolling dice to move is as simple as running a random number field and adding to the icon's Space number. Obviously, it's more complicated for something where you want more visual interest, but that would get you started.
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### magicpegasus

• Posts: 101
Thank you for replying! I understand what you mean, I think. The list would hold coordinates for each space the player icon could move to. The player icon would have an attribute called "space" that would pull coordinates from my list to place itself on the game board.

What I don't understand is how to make a list in Stencylworks. I've stumbled on examples of other people's lists in the forums, but have not found a tutorial for making a list. Would you please explain or show me what blocks to use?

Thank you!

#### Hectate

• Posts: 4645
Lists themselves are attributes, so you have to create one to use it. Once you create it, you can add the items to the list as needed. The following link shows all the different blocks that are used to alter lists.

http://static.stencyl.com/swHelp/en/html/main/blocks/attributes/Lists/Lists.html

You could use the blocks to add your values to the list in the When Created section of the behavior, but adding the items (which would be the coordinates) sequentially. Remember that lists start at item 0, so you'd do well to keep your first space as number 0 as well.

Edit: for some reason, the split string block isn't showing in the online help documents, but I did locate an older thread that has information on it. You'll need it to split the values into two numbers using the comma as a delimiter.

http://community.stencyl.com/index.php/topic,1193.0.html

« Last Edit: November 04, 2011, 12:27:03 pm by Hectate »
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### magicpegasus

• Posts: 101
Do I create my list as an attribute to the scene behavior? I'm finding this splitting business a little confusing, but I'm sure it is worth learning, because it looks like I will be using lists a lot for this game.
Thanks!

#### magicpegasus

• Posts: 101
Ok, now I'm not sure why I'm using a list at all. My actor behavior doesn't seem to be referencing the list. I have a "Space" attribute on my actor/icon, and "if" blocks that set the coordinates of my icon depending on what the coordinates are. Right now, I don't understand why I'm using the list and split blocks. Couldn't I just put the x and y coordinates of each space in this code? Attached is a picture of what I've been trying.

#### Hectate

• Posts: 4645
If you don't mind hard-coding a long chain of IF statements with the coordinates in it, that's perfectly fine. The goal, however, was to show you an easier way.

The part you missed was why we are using the "Space" attribute as a number. That number corresponds to an item's index (an index is the number that represents where in the list's order the item falls sequentially from first to last). Thus, we can use the current value of "Space" to find the coordinates that match that space, all without needing an IF statement at all.

Here's is what your block is going to look similar to...

I did split up the "Set Y..." set of blocks so you could see exactly how they were asssembled.

So this way, the "Space Number" determines what item in the list is looked up. In your case, you were examining the number and just setting values directly. Lots of extra effort

Notice that I did put in a "0" and a "1" into the first "Get item from list" block. The reason for this is that the "split text" block is treated as a temporary list, so the first half (before the comma, our X value) is item 0 and the second half (after the comma, our Y value) is item at index 1. The OTHER "get item from list" block is using the Space Number to determine which set of values to get though. That's the important part.
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### magicpegasus

• Posts: 101
Thanks for spelling this out for me! I'm not sure if I completely understand what you did, but I now have the coordinates list and blocks functioning and attached to my temporary icon actor. It works the same as my long chain of if statements, and I'll easily be able to change the list to allow for differently shaped game boards.

Now I'm trying to move the actor by creating a behavior that will change Space Number when I press [Enter]. Seems simple enough, but again I'm running into problems.

When I hit [Enter] nothing happens. I added a "print space number" block and watched the console, and found that the space number was not changing from zero.

What am I doing wrong here? I've attached a picture of my behavior blocks and a swf of the WIP.

#### Hectate

• Posts: 4645
Actor values are not the same thing as attributes. Currently, you're setting a new actor value to "Space Number + 1" but not actually changing the value of the "Space Number" attribute at any point.

I think it's actually been combined with the "decrement" block but the idea is the same. Either way, look in the "Numbers and Text > Math" section.
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### magicpegasus

• Posts: 101
Great! I have a behavior that moves my actor around the board. The rest of the game is supposed to be like a text based adventure. I have learned how to draw text, but I don't know how to make it flow to display it in sequence to play the game.

The first message should be something like: The player has appeared at space 01.

Then The player gets to choose if they want to move or wait

If move, we "roll" for a random number between 1-6,

The player encounters something on the new space: either a monster, or treasure, or "free parking".

The player fights the monster, opens, the treasure chest, or waits. Then the turn is over.

Any sugguestions on how to manage the text in this game? I tried making a list attribute with different messages on separate lines in the list but it didn't display anything.

I've attached a picture of the behavior. Any ideas? I'm stuck with this game until I can figure out the text aspects.

Thank you,
Magicpegasus

#### Hectate

• Posts: 4645
For the text, your best bet will be to put the game into different "states" and then display text appropriate to the state. The list is an acceptable solution to storing all the text, but that doesn't do you any good for displaying it when needed. Just like with the previous use of lists, you can use something like a "State Number" to determine which text to get. Be sure to use the "get item from list as text" block just to make it easier on you.

That doesn't mean though that you MUST use a list in this case. Unlike before, where hardcoding it would be repetitive, in this case the state change will result in wildly varying output (instead of a standardized list of coordinates).

What you need to do first though is completely plan out every line of text that this behavior will display and how to use them efficiently. From what I see you've got a few different states that the text could be in...

Blank
"Player has rolled a #" or "Player moves # spaces ahead/behind"
"player moves to space #" or "Player is now on space #"
"Player has encountered a monster/treasure/other special"

...but there could be many more - all depending on your design - so it's best to know in advance what you have to be ready for.

Remember, you can use the "text + text" block to combine two things, such as the number of the current space or the die roll and a standard message like "The Player is now on space" (and then have the number afterward). You'll need to use conditionals to check the current state and determine if it should be added in depending on what text you're going to show. After all, you don't want the player to be on space 5, opening a treasure chest, and display "The Player has opened a treasure chest 5".
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### coleislazy

• Posts: 2607
Do you intend to have a single line of text on the screen at any time, or do you want a "log" of text somewhere so you can see what happened on previous turns or earlier in this turn?

If you simply want a line of text at once, you would have a behavior which draws text from a text attribute. Then you would change the value of this attribute whenever you wanted to display a different message.

If you wanted a log, you would need to store the text in an array and loop through it, drawing the value of the items in the list on different lines.

If you lay out what plan you have, it will be easier for us to help you figure this out!

#### magicpegasus

• Posts: 101
I want to start by showing one message at a time. The first message would be:

"An Alien has appeared over Bermuda!"

then the player would hit a key to "roll". The next message would be:

"The Alien has moved (#) spaces and is now hovering over (new space)."

--------------------------------------------------------

If I could get this far, it would be a good start. For the end product, I would want a log. The basic idea for this game is to play a turn, and send your move to a friend, like the game "Words with Friends". You and your friend would complete a game over the course of the day, or maybe the week, depending on how things play out and how often you correspond.

I realize this is kind of a lofty project for a beginner, so I'm trying to start simple, with local two player play. Or even one player with some cpu "monsters" on the board.

I will try the text attribute suggestion and see how far I can get today....Thanks guys.
-MP

#### magicpegasus

• Posts: 101
I just can't seem to understand how to do this. All I got done after hours of trial and error was changing the text from one message to another. I have no idea how to put the pieces together and make what I thought was a simple concept work. I used to make text based adventures on basic when I was a kid, and I really didn't see how this project was that different.

I don't know if my "draw text" behavior should be attached to the scene or to a hidden actor. If it is attached to the actor, I don't know how to make it "tell" another actor to do anything. It feels like I've only scratched the surface of what I wanted to complete this game.

I'm disappointed with how little I've been able to accomplish with this project. I think I'll have to put it on hold until a board game kit or text based adventure kit is developed for Stencyl. It's beyond my grasp to build it from scratch. Next, I'll try something more arcade-style, like my first game, which was extremely easy to develop in Stencyl. Thanks to those who replied and helped me with this!

#### Hectate

• Posts: 4645
You're welcome! And yes, it was a bit ambitions. However! You learned a great deal - even if you didn't complete your design you know much more than when you started, and you can always come back to this when you feel more confident.

I've found that some of the things I figured out in my early projects are invaluable and I frequently go back to them and just steal the ideas and behaviors for use in new projects. Learn and recycle, that's the way it works!
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.