You are so much less likely to run into an issue.Īs someone who has been coding for many years, I find that building things with small iterations is best. In the case of Games I like to build from the main game mechanic outward. It’s the most important part of the game, making it secondary might mean it is not well polished. We are going to build a memory card flipping game using Stencyl 3.0 so lets get the pseudo-code out of the way first, or at least a part of it. else if there is another card flipped over and the two cards do not have the same value, it's not a match, flip both cards back over Remove both cards, add a point to the score if there is another card flipped over that has the same value, it's a match. else if there are no other cards flipped over, record the type of card flipped so the comparison can be made in the above logicįrom the above pseudo-code we know we are going to have to keep track of the cards that are flipped. Stencyl uses game attributes as global variables, or values that are available to all the actors in the game. So we will make a list of the cards that have been flipped.įor the purpose of this tutorial, I found some open source playing card images and converted them to jpegs. In Stencyl I create a new game called “Card Flip Tutorial”Īnd then create a new actor called “Ace of Spades” You will need a front and back of a playing card to start, and later, more fronts of the cards. I then add the images of the front and back of the Ace of Spades as animations. I name them, front and back, and make sure they don’t loop. Back should be the first animation (the one with the star), as it will be the one shown when we start. We need a scene for this all to take place. Then I brought 2 Ace of Spades actors out onto the stage.Īt it’s most simplest, we need to flip a card when the player clicks on it. When the card is pressed we switch to the front animation So we will add the following actions to the events tab of the Ace of Spades actor. Test your game! When you click a card, does it show the face of the card? If not, go back and make that happen before moving on. We know we are going to be applying this behavior to a card later, so while building the card behavior we need to keep that in mind and use the available attributes to keep any actions as generic as possible. We also need some feedback because reading the log viewer in flash isn’t really ideal. I have covered creating a super easy HUD in another post. TLDR: Send user feedback to a text variable, draw the text variable in an actor. I need to make some game attributes to control the game flow. Sets Matched - Number - to display the score in the HUD Sets Remaining - Number - to keep track of the remaining sets Cards Flipped - List - to keep track of which cards are flipped over We also need to create a group for our cards. Now, following the pseudo-code from the beginning of this tutorial we create an event behavior in the Ace of Spades When two cards that are not the same are flipped, all of the cards need to flip back, so we use groups to tell the program that. This is a good place to stop and test to see if you’ve messed anything up. Did everything come together as planned? Building onto what we haveĪs I said before, we don’t need to create a masterpiece from the start. It could be said that all programing is best done iteratively like this. Next we are going to apply the code to another card and see if it works. To do that, we are going to create a custom actor behavior. I am going to copy the code from the Ace of Spades actor and paste it into this behavior so we can use that code over and over on all the cards Back on the dashboard I create a new actor behavior using the Design Mode and Actor Behavior radios.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |