Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
547 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Software ==> | Power Apps (13 exercises) |
Topic ==> | Formulae (2 exercises) |
Level ==> | Average difficulty |
Subject ==> | Power BI training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
The aim of this exercise is to create a two-horse race! Starty by creating a new canvas tablet app, and save it as Racecourse.
Add two images based on the files in the above folder:
Insert each image ... | ... then assign it to a file. |
You should now have two horses!
Who is your money on? Give each image a sensible name, so you can refer to it easily.
Add a button to put the horses under starter's orders:
Clicking on the button should position the horses 50 pixels beneath the button, ready to start racing. Do this by setting the values of variables, then assigning the Y properties of each image to these variable values.
Be very careful from this point onwards not to drag your horses around the screen - doing so will override the Y property you've set with a constant number. This is Power Apps' most irritating feature!
Add a Race button which randomly advances one horse or another with equal probability:
Test the value of Rand(), a function which returns a random number between 0 and 1. If this is less than 0.5, set Anastasia's variable to be itself plus 50; otherwise, do the same for Archibalda's variable.
Things are going well, but the horses disappear off the bottom of the screen. Set a winning label for each horse to become visible when the horse gets within a given number of pixels of the bottom of the screen (you'll need to use Parent.Height for each label to get the height of the screen it belongs to in order to help determine when this becomes true).
A victory for Archibalda! As a bonus, you could disable the Race button as soon as either horse wins (that is, set its DisplayMode to Disabled when the Visible property of either winning label is true).
If you still have time and energy, you could automate the race by adding a timer:
When everything is working, you can hide the timer - the user doesn't need to see it.
Set the following properties for the timer:
Property | Value |
---|---|
Duration | 1000 (ie 1 second; when everything is working you can reduce this to 100 to speed up your race!). |
OnTimerStart | The same action as you assigned to the Race button previously, to advance one horse or the other randomly. |
Repeat | true (every second you want the timer to restart, to advance a horse another square). |
Start | IfStart (a variable which should be set to false when you put the horse's under starter's orders, and true when you start the race). |
Reset | IfReset (a variable which should be set to true as soon as either winning message label becomes visible). |
You should now be ready to run simulations of your race, and start taking bets!
You can find other training resources for the subject of this exercise here:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.