This document provides instructions for creating a hidden object game using Scratch. It describes how to:
1) Resize the gameplay area, add a countdown timer that subtracts each second, and use global variables to save the time between levels.
2) Randomly select which hidden objects are visible at the start using repeat loops and conditionals to check positions.
3) Have the player click hidden objects to remove them, increase their score, and win when reaching a set score. Penalize wrong clicks by subtracting time.
4) Add title/end frames to display instructions, scores, and completion times pulled from global variables.
This document provides instructions for creating a hidden object game using Scratch. It describes how to:
1) Resize the gameplay area, add a countdown timer that subtracts each second, and use global variables to save the time between levels.
2) Randomly select which hidden objects are visible at the start using repeat loops and conditionals to check positions.
3) Have the player click hidden objects to remove them, increase their score, and win when reaching a set score. Penalize wrong clicks by subtracting time.
4) Add title/end frames to display instructions, scores, and completion times pulled from global variables.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7
Lesson 6: Hidden Object -style Game
What Youll Learn
Resizing the gameplay area Visibility Strings Countdown timer Image-maps for buttons Ill no longer be providing asset lists or pseudocode--try to wor these out on your own and chec the !"# files for assets$ Title and End Frames !ae two end frames% one for win and one for lose$ &he lose frame will display the high scores$ &he win frame will display the time in which the player finished the game$ !ae a title page with instructions$ 'eve inserted buttons and used eys to clic to start a game( but what if we want to have a special menu system( or round buttons) 'e can import a graphic as an active ob*ect--import menu$gif for this e+ample$ ,yes( I now mine is a very ugly menu-. 'e want to mae an image-map using / and 0 coordinates so the user can clic on an area of the frame$ 1nder events( set a condition for the mouse2 1ser Clics 'ithin a 3one$ &his will bring up a zone-bo+ that we can drag over our word 4start5$ 6o the same for the 4high scores5 part of the menu$ #nd select 4ne+t frame5 as the action for start( and 4*ump to 75 for the high scores- Gameplay Frame 8ets first change the size of our game$ 1nder our 'orspace &oolbar( clic on the frame for our gameplay and the properties will display: we can ad*ust size here$ 8ets change to 9::+;::$ Change the size of the whole game( as well as the frame ,depending on which word youve cliced on above--our game title( 4<idden5( or our level( 4gameplay5$ =>::? @aren Collins www$gamessound$com A Choose a photo for the bacground by inserting an ob*ect2 bacground 2 active Picture$ Ive grabbed one off bigfoto$com$ 'e can ad*ust the size *ust lie we did with the frame size$ 8oc it in place and name it bacground$ 6rop a Buicbacdrop and drag it across the bottom of the screen for our list of ob*ects ,mine is the large grey space below the photo.$ Insert a score counter$ 'rite beside it with a formatted te+t ob*ect that says 4Score5 Cow import the ten images as active ob*ects that will be 4hidden5 in our game$ Dive them all appropriate names and then hide them in the screen image$ I havent hidden them yet in the image below: =>::? @aren Collins www$gamessound$com > # string is a series of characters that could represent numbers( words( and so on$ 'ell insert A: string ob*ects in our space along the bottom$ 1nder their properties enter a name for each$ Ive used 4t+tname5 as my string ob*ect names$ "or each one( deselect the 4display as bacground5 bo+$ &his is to combat a 4bug5 in the program whereby te+t ob*ects go funny if they are displayed as bacground- Cow we want to be able to say( 4when the user clics on an ob*ect( if the te+t for that ob*ect e+ists ,is visible. in the game( and the user clics that ob*ect( mae the te+t invisible( delete the ob*ect( and add A: to the score$ Condition: 1ser clics on an ob*ect with the left button of the mouse$ #nd the te+t for that ob*ect is visible$ =>::? @aren Collins www$gamessound$com 7 #ction: destroy the ob*ect( mae the string invisible( add A: to score$ 6o this for every ob*ect$ Cow we want an action for what happens if a user clics an ob*ect and that ob*ect is not visible( or if they randomly clic the bacground( what will happen$ 'e will penalize their timer$ "irst( however( we need to mae a timer$ &here is no cloc countdown ob*ect for us to display but we can mae one Buite easily: !ae a counter ob*ect$ In the event editor( when the frame loads( set the counter to ;:$ 'rite ne+t to it 4time5 so the player nows what it is- Cow use the condition of the timer: every A second( subtract one from the counter$ Cow( when the counter reaches :( go to the game over frame( but because we may be subtracting five from our counter ,see below.( we need to have this condition read ,eBual or lower than :.$
Eay( now for when the player maes wrong clics: if the player clics the bacground ,active ob*ect.( then A should be subtracted from the counter$ If the player clics an ob*ect and the te+t for that ob*ect is ICVISIF8G( then A should be subtracted from the counter$ Hust lie the conditions for the visible te+t( set a condition for each ob*ect where if the ob*ect is left-clic and the te+t for the ob*ect is not visible( thenI subtract A from timer counter =>::? @aren Collins www$gamessound$com J &est that out and youll see it wors fine$ &he trouble is( however( that all the te+t is always visible ,unless weve already destroyed the ob*ect.I so we need to randomly choose five string ob*ects to mae visible( and five to mae invisible at the load of the frame$ "irst( align the string ob*ects to the top in two rows$ !y top row of five strings all have a 0 co-ordinate of K:L$ !y bottom row aligns at KJ?$ Cow were going to set the strings to randomly display in the top or bottom row$ So( *ust lie with our Arkanoid brics( select the event editors special icon( and choose repeat K times$ Swap the ob*ects with each other ,under the string ob*ect( position2 swap.$ Cow all we need to do is test to see if the ob*ects 0 co-ordinate is K:L( and if it is not( mae it invisible$ Ive made this into a separate event group *ust for claritys sae$ Condition: string ob*ect: Compare 0 position : if 0 position is greater than or eBual to KJK ,*ust to give us a little grace if weve missed an e+act placement.( then mae it invisible$ If 0 position is less than or eBual to KJJ( mae the ob*ect reappear$ =>::? @aren Collins www$gamessound$com K
If we have gained a score of K: ,A: + K ob*ects.( then we should 4win5 and be taen to win screen$ ,condition is Mlayer Enes score is eBual to value of K:. action is *ump to frame J ,win.$ 'e could easily alter this game so that another level is played after player reaches K:$ 8ets do one final thing: store the value of the counter at the end of the game if they win( and load it in the final win frame$ In order to store a value across frames( we need to use a D8EF#8 value$ 1nder our properties for our counter( chec the Dlobal value bo+ in the Runtime Eptions$ In the event editor( set the condition for the Gnd of "rameI so when the game is over( we want to set the global value # to the value of the counter$ 1nder the special icon( we want to set global value # to ,retrieve current value from counter.$ Cow weve stored our value$ =>::? @aren Collins www$gamessound$com ; In the final frame( drop in a counter and write some te+t that says 4Congratulations( you finished in5 and then insert the counter( then another te+t that says 4seconds5( so it should read( 4Congratulations( you finished in NcounterO seconds5$ Cow we need to retrieve the value for the counter$ #t the Start of "rame( counter set2 global value2 retrieve global value #$
Additional Eercises A$ #dd sounds for interesting events$ >$ Mlay a brief 4bling5 animation when the player clics on the right ob*ect$ 7$ See if you can discover other ways to program the random aspect( instead of the way Ive set it up here$ J$ !ae some more levels$ =>::? @aren Collins www$gamessound$com ?
AI-powered Excel Ludo: Complete Code and Easy Instructions to Create a Fully Functional, Advanced and AI-powered Ludo Game in Microsoft Excel using VBA