PowerApps4Kids Session 20 is on 26th January 2022. If you miss the session, you can watch on YouTube PowerApps4Kids Channel after about a week – 2nd February 2022. So who’s presenting?
If you want to learn how to make Connect 4 in Power Apps, then look no further, this is it explained in a post. It was first played in 1974 and has been played for 47 years. Read on to find out more on how to make it.
Rules of Connect 4
The rules for this game are, Connect 4 is a game with 7 columns and 6 rows. This is the game, in a Power App and you will see the game when you press play. On your colour go (it shows which go it is under the label saying ‘current turn’), you need to click one of the buttons that says ‘here’. This will put a circle in that column at the bottom blank circle. the aim is to get 4 in a row. This will make an arrow appear showing which direction four circle are connected. Also, a smile will appear. In addition, a sound will play.
Brackets
In the code for Connect 4, you will find 3 different types of brackets. You will find round brackets, square brackets and curly brackets. Look here to find out what each one does.
() – After the name of a function you put ( and the you have your code, afterwards you put )
[] – List of items, they are also called collections.
Create a name for the app, make sure it is a tablet app and then click on the create button.
This will create a blank screen
Code for the App on start
First, we have to make the grid of different coins in connect 4. This is the board for the game. We create this on the app on start. how you find this is, click on App, go to the dropdown and click OnStart
The code we put in here will create the grid. The code we need to put in here is,
The clearcollect creates a list of items, which is also known as a collection.
colColumns is the name of our collection because without a name there would be no collection.
ColNumber is the column number. We use this to set our grid.
NumberOfPieces is how many pieces are in this column.
Rows contains the coins and their colour.
RowNumber is the location in that column.
The Set function at the end of the above code, is where we are changing a variable, which stores information that you can change.
VarCurrentTurn is our variable that tells the app whose turn it is.
Now, run the app on start by playing the app using the play icon at the top.
Making the connect 4 board visible
We need to create a horizontal gallery on our screen for the columns.
You do this by going to insert like we did earlier and clicking on gallery and selecting horizontal gallery.
Next, make the items property of the gallery to
colColumns
Now, add another gallery inside the first one. It needs to be vertical. This will be the rows. The tree view in the app should now look like this.
In the items property we will make it
ThisItem.Rows
ThisItem.Rows is all of the rows in one column.
Now go to insert at the top of your screen and click on icon and add in a circle and a rectangle. Make the colour using the Fill property blue for the rectangle and for the circle use the following code
ThisItem.Value.Row
The Row contains the colour that we set earlier. The screen should now look like this.
Adding the Buttons and make them work
We are now going to add a button to the first gallery we made. The text property needs to be set to “here”. It should now look like this.
When the button is pressed we want to add the coin to that column. Then we want to change the varCurrentTurn and increase the number of pieces for the selected column
On the OnSelect code for the button we start with if there are no coins in that column. This means
that the number of pieces is set to zero. For this, we need to write the following code.
To disable the button for when the column is full, we need to write the following code to the Display Mode property,
If(ThisItem.NumberOfPieces < 6, Edit,Disabled)
Displaying the current turn
Outside of all of the galleries, we add a circle nd on the fill property we put
varCurrentTurn
New game button
Add a new button make the text “new game” and on the OnSelect code, we copy the App OnStart code.
Arrows to signal that the game is done
We need to add an arrow for every possible place that there could be four in a row. In total there are 69 possibilities. As an example, if the four yellow coins are shown as they are above, then add the following code,
On the first line, in the grid for column 0 and row 5 we are checking that there is a coin and for the rest of the rows, we are checking that they are the same to column 0 and row 5. Repeat the same just change the numbers for all the other options. You might want to make sure that you name the arrows. I named all my arrows column number _ row number then the direction of the arrow so for example 0_5v or 4_6v
Smiley face to check that there is an arrow visible
when any of the arrows are visible, we want a smiley face to appear. We do this by adding a smiley icon and on the visible property we use the following code.
When we first set up PowerApps4Kids we cobbled together a logo, and towards the end of 2020 Microsoft rebranded Power Apps and ours started to look a little out of date.
So here it is – we hope you like it, and we hope you can join us at our next session which will be held on Tuesday 23rd February 6pm GMT
Chess – one of the ultimate board games and one that dates back hundreds of years. We know what it looks like, and I take on the challenge of making it in PowerApps. Practically speaking this is straightforward, but understanding the formulas is pretty complex. Good Luck!
Steps for importing an msapp.
1. Go to https://us.create.powerapps.com/studio/# (see the link below) – you should get redirected to https://eu.create.powerapps.com/studio/# if in Europe
2. Download one of the apps below. The app MUST be of a type *.msapp for this technique to work
3. Go back to the site above
4. Click Open
5. Browse for your file
6. Open it.
7. Nearly there
8. Make sure that you save the app (so that it lives on the web)
This is an example post, originally published as part of Blogging University. Enroll in one of our ten programs, and start your blog right.
You’re going to publish a post today. Don’t worry about how your blog looks. Don’t worry if you haven’t given it a name yet, or you’re feeling overwhelmed. Just click the “New Post” button, and tell us why you’re here.
Why do this?
Because it gives new readers context. What are you about? Why should they read your blog?
Because it will help you focus your own ideas about your blog and what you’d like to do with it.
The post can be short or long, a personal intro to your life or a bloggy mission statement, a manifesto for the future or a simple outline of your the types of things you hope to publish.
To help you get started, here are a few questions:
Why are you blogging publicly, rather than keeping a personal journal?
What topics do you think you’ll write about?
Who would you love to connect with via your blog?
If you blog successfully throughout the next year, what would you hope to have accomplished?
You’re not locked into any of this; one of the wonderful things about blogs is how they constantly evolve as we learn, grow, and interact with one another — but it’s good to know where and why you started, and articulating your goals may just give you a few other post ideas.
Can’t think how to get started? Just write the first thing that pops into your head. Anne Lamott, author of a book on writing we love, says that you need to give yourself permission to write a “crappy first draft”. Anne makes a great point — just start writing, and worry about editing it later.
When you’re ready to publish, give your post three to five tags that describe your blog’s focus — writing, photography, fiction, parenting, food, cars, movies, sports, whatever. These tags will help others who care about your topics find you in the Reader. Make sure one of the tags is “zerotohero,” so other new bloggers can find you, too.
This is an example post, originally published as part of Blogging University. Enroll in one of our ten programs, and start your blog right.
You’re going to publish a post today. Don’t worry about how your blog looks. Don’t worry if you haven’t given it a name yet, or you’re feeling overwhelmed. Just click the “New Post” button, and tell us why you’re here.
Why do this?
Because it gives new readers context. What are you about? Why should they read your blog?
Because it will help you focus your own ideas about your blog and what you’d like to do with it.
The post can be short or long, a personal intro to your life or a bloggy mission statement, a manifesto for the future or a simple outline of your the types of things you hope to publish.
To help you get started, here are a few questions:
Why are you blogging publicly, rather than keeping a personal journal?
What topics do you think you’ll write about?
Who would you love to connect with via your blog?
If you blog successfully throughout the next year, what would you hope to have accomplished?
You’re not locked into any of this; one of the wonderful things about blogs is how they constantly evolve as we learn, grow, and interact with one another — but it’s good to know where and why you started, and articulating your goals may just give you a few other post ideas.
Can’t think how to get started? Just write the first thing that pops into your head. Anne Lamott, author of a book on writing we love, says that you need to give yourself permission to write a “crappy first draft”. Anne makes a great point — just start writing, and worry about editing it later.
When you’re ready to publish, give your post three to five tags that describe your blog’s focus — writing, photography, fiction, parenting, food, cars, movies, sports, whatever. These tags will help others who care about your topics find you in the Reader. Make sure one of the tags is “zerotohero,” so other new bloggers can find you, too.
This is an example post, originally published as part of Blogging University. Enroll in one of our ten programs, and start your blog right.
You’re going to publish a post today. Don’t worry about how your blog looks. Don’t worry if you haven’t given it a name yet, or you’re feeling overwhelmed. Just click the “New Post” button, and tell us why you’re here.
Why do this?
Because it gives new readers context. What are you about? Why should they read your blog?
Because it will help you focus your own ideas about your blog and what you’d like to do with it.
The post can be short or long, a personal intro to your life or a bloggy mission statement, a manifesto for the future or a simple outline of your the types of things you hope to publish.
To help you get started, here are a few questions:
Why are you blogging publicly, rather than keeping a personal journal?
What topics do you think you’ll write about?
Who would you love to connect with via your blog?
If you blog successfully throughout the next year, what would you hope to have accomplished?
You’re not locked into any of this; one of the wonderful things about blogs is how they constantly evolve as we learn, grow, and interact with one another — but it’s good to know where and why you started, and articulating your goals may just give you a few other post ideas.
Can’t think how to get started? Just write the first thing that pops into your head. Anne Lamott, author of a book on writing we love, says that you need to give yourself permission to write a “crappy first draft”. Anne makes a great point — just start writing, and worry about editing it later.
When you’re ready to publish, give your post three to five tags that describe your blog’s focus — writing, photography, fiction, parenting, food, cars, movies, sports, whatever. These tags will help others who care about your topics find you in the Reader. Make sure one of the tags is “zerotohero,” so other new bloggers can find you, too.