Download presentation
Presentation is loading. Please wait.
Published byBarnard Mathews Modified over 9 years ago
1
SPELLING GAME PROJECT SAMPLE ASSESSMENT MATERIAL GCSE Computing
2
Objectives 1.The program should store the words in the list 2.The user should be able to add a new word, if the word is chosen to be added to the array is already in the array then the program should tell the user that the word is already in the array otherwise it will add the word the to the array 3.The word should not be able to be chosen twice until the game is restarted and the word chosen by the program should be overwritten with a 0 4.The program should pick a word at random and display it for a short period time 5.The user should be invited to make a guess in response to the word generated by the computer 6.If the user enters the same combination of characters to make up a word guess then this should be rejected by the program 7.The chosenword and the users guess should be written to the chosenword and myguess list 8.The chosenword and the users guess lists need to be of equal length. 9.The program should tell the user how many letters guessed match the chosen word and how many letters were guessed correctly and how many are incorrect. 10.If the word entered by the user matches the word chosen by the computer then the program should indicate this is a correct guess 11.If the user guesses incorrectly 3 times he should lose the game
3
Algorithm – Add a word and start the game Sub AddAWord Set counter to one Set flag to false Input the newword Set newword to Answer while counter is less than or equal to the length of the words list or flag = false if newword = item counter of words list set the flag to true else set the flag to false Counter = counter + 1 if flag = true then add this word to the list of words Sub Start Set lives to 3 Reset chosenword and myguess lists = “ ” Set answa “ “ Repeat until answa = “y” or “n” Answer = Input “do you want to rest the list” If answer = yes activate reset Elseif answer = no Activate playme Sub reset Set Counter to 1 Set wordpicked to 1 Reset wordsasked = “” Repeat lengthofwordslist Add item(counter)of words to wordlist Counter = counter + 1 Activate playme This sub starts the game initialising the lives to 3 at the start and offering the user the chance to reset the list. The words are copied into the wordsasked list and picked from these/ This sub checks adds a newword to the list, before that it checks the word added is not in the list already.
4
Algorithm – Play the game Sub Playme Set wordchosen to “” Set gameover to false Set lenwordsasked to lengthofwordsasked Set pickme to 0 If wordspicked is less than the lengthofwords Repeat until length of item pickme of wordsasked is less than 1 Randomize Set pickme to 1 to the length of wordsaskedlist Display itempickme of wordsasked list for 0.5 seconds Set wordchosen = item pickme of wordsasked Set item pickme of wordsasked to 0 Wordspicked = wordspicked + 1 Call makeaguess Else Display all words are used up Sub makeaguess Set tempword to “” Input – what is your guess Set tempword to answer Reset correct letters “” Call checkifusedbefore Sub checkifusedbefore Set flag = false Set counter = 1 Repeat until counter = length of Incorrectwordsguessed + 1 or flag = false If tempword = item(counter) Incorrectwordsguessed then flag = true Else flag = false If flag = true then Display guessed word has been used before Else if flag = false Call make a guess Insert tempword at the last Incorrectwordsguessed Call checkword Sub checkword Set tempword = myguess If myguess = wordchosen Display you have won Call you have won Else Call write2array
5
Sub write2array Reset chosenword,myguess and correctletters lists = “ ” Set Counter to 1 Repeat until counter = length of wordchosen + 1 Add letter counter of wordchosen to chosenword Counter = Counter + 1 Set Counter to 1 Repeat until counter = length of myguess + 1 Add letter counter of myguess to myguess list Counter = Counter + 1 Call checklistsize Else Display all words are used up Sub checklistsize Set lenmyguess to len(myguess) Set lenwordpicked to len(wordschosen) If lenmyguess = lenwordpicked Display list sizes are equal If lenmyguess > lenwordpicked Set counter = lenwordpicked Repeat until conter – lenmyguess Add * to chosenwordlist Counter = counter + 1 Elseif lenmyguess < lenwordpicked Set counter = lenmyguess Repeat until conter = lenwordpicked Add * to chosenwordlist Counter = counter + 1 Call howmanyletters Sub howmanyletters Set lettersright = 0 Set letterswrong = 0 Set counter = 1 Repeat len(chosenword) If item(counter) chosenword = item(counter)myguess Lettersright = Lettersright + 1 Insert item(counter)of myguess(list) at last of correctletters list Else Letterswrong = letterswrong + 1 Insert “ “ at last of correctletters Counter = counter + 1 Sub analyseresult If lettersright < lenwordpicked Lives = lives – 1 If lives = 0 Display “you have lost” Gameover = true Call you have lost If lettersright = len(chosenwordlist) Call youhavewon Algorithm – Check lists and play game
6
Importing the words Set up a list from Import the words into the list from a text file. Do not manually enter them yourself this is a waste of time.
7
Design – variables and list design Tempword – string used to store the value of the users guess whilst the program checks that the combination of characters in the word entered as a guess has not been entered before Answer – set to y or n in response to questions posed by the prog, for example do you want to reset the list Counter – used as a means to increment through a counter for example adding the chosenword into the chosenword list Flag – used as a Boolean value set to true or false if for example the combination of characters entered by a user as a word has been used before Gameover – Boolean value set to true / false used to indicate the end of the game Lenmyguess – variable stored as an integer to indicate the length of the variable my guess Lenwordpicked - variable stored as an integer to indicate the length of the variable wordpicked Lettersright – integer stores the values of no of letters that the user has guessed correctly Letterswrong – integer stores the values of no of letters that the user has guessed incorrect Lives – integer keeps track of the number of lives that the user has this is set a t 3 from the beginining Newword – string value – used to store the value of the new word being entered into the array Pickme – integer set as a random value between 1 and the length of the words list Wordchosen – string – stores the value of the word chosen by the program Wordpicked – stores the value of the number of words that the program has picked Words – stores the value of the words in the list Wordsasked copies the value of the words in the wordsasked Chosenword – individual characters from the wordchosen variable will be stored here Myguess individual characters from the myguess variable will be stored here Incorrectwordsguessed – incorrect word guess combinations will be stored here
8
Design User Interface Input Box Lives Chosenw ordlist. Mygue ss. Words. Wordsasked. Incorrect wordlist In the design of my interface for the game I am going 6 lists. One which will store the words, the words asked, the individual characters of the words chosen by the program and my guess, The incorrect words the user has chosen, and the correctword list will display the characters correctly guessed by the user. Correctw ordlist The variables listed will also be displayed at various points as the program is executed Play MeAdd A Word
9
Testing and Development – User Interface 1.The program should store the words in the list This shows that the words are stored in a list. The words are imported into the list and then copied into the wordasked list. At the start of the game the user is offered the chance to reset the game and copy the words from the words list into the wo
10
Testing and Development 2) The user should be able to add a new word, if the word is chosen to be added to the array is already in the array then the program should tell the user that the word is already in the array otherwise it will add the word the to the array When the add a word sprite is clicked the variables are set at the start with counter at 1, newword as “ “ and flag to false. The user enters a new word in the newword variable and this value is checked against each value in the words list to see if it is in the words list. If it is a message is displayed saying the word is already in the array, if not the word is added at the end. Test – word to be entered Floccinaucinihilipilification (longest word in the English language Word entered Word added Same word entered againAnd blown out Test successful as the same word cannot be entered again
11
Testing and Development 3) The word should not be able to be chosen twice until the game is restarted and the word chosen by the program should be overwritten with a 0 All of the variables are initalised at the start, gameover – false, letterscorrect and letterswrong are 0. If the wordpicked value is less than the lengthofwords then the script will repeat until the length of item pickme of wordsasked is greater than 1. The value will then be displayed and set to wordchosen variable and this space will be overwritten with a 0. The wordspicked variable will be changed by 1. If all the words have been used in the list then the message will be display all words have been used up. Test – word chosen GIF The word GIF is chosen by the program as this is item number 229, this is overwritten with 0 in the wordsasked list.
12
Testing and Development 4) The program should pick a word at random and display it for a short period time The word is selected by the program displayed for approximately 1 second
13
Testing and Development 5) The user should be invited to make a guess in response to the word generated by the computer 6) If the user enters the same combination of characters to make up a word guess then this should be rejected by the program Tempword is initialised at the start of the sub and the user is invited to make a guess in response to the word generated by the program. The users guess is written into this variable. Flag is set to false and counter to 1 and the program checks if the combination of letters / characters entered have been used before. If it has the user is invited to make another guess otherwise this is added to the list wordsguessed list Word selected is ASDL– the user is invited to make a guess. Guessed entered ADSADS is going to be entered again And the entry is rejected
14
Setting up the Data Structure Each of these variables will be used later on in the game, Import the data into the list
15
Testing and Development 7) The chosenword and the users guess should be written to the chosenword and myguess list The variable Myguess – is set to tempword, if these value are the saem then the game terminates and the you have won sub is called. If these 2 variables are not the same then the chosenlist, myguess and correctletters lists are reset. The wordchosen and myguess variables are then written into the chosenlist and myguess lists. The size of the lists are then compared This shows the users guess and the chosenword chosen by the program are written to the lists. The program equalises the lists by adding a *.
16
Testing and Development This sub is run to equalise the length of the lists, will add a * to the chosenword list or the myguess list depending on which one is the smaller. Entered ADSLR Both lists are equalised and the correct letters are included in the correct letters list, expect it leaves a blank at the end. Both the chosenwordlist and myguess list are equal 8) The chosenword and the users guess lists need to be of equal length.
17
Copying Data to another list We are going to copy of the contents of wordslist to wordsasked Create the following script Set counter to 1 Add item counter of wordlist to wordasked the other list we have created. This is going to used throughout this game This shows the words being copied into the wordsasked list
18
Testing and Development 9) The program should tell the user how many letters guessed match the chosen word This set sets initialises the letters right and letters wrong variables. The loop runs thorough the loop and checks if item counter of chosenword is equal to item counter of the myguess, if this lettersright is incremented by and the correct letter is inserted into the correct letters list. If not the letterswrong is incremented by 1 and a space is inserted in the correctletters list. This tells the user what letters are correct and which ones are incorrect. CPU chosen C is entered as a guess, the arrays are initialised and the letters right = 1 and letterswrong = 2
19
Testing and Development 10) If the word entered by the user matches the word chosen by the computer then the program should indicate this is a correct guess This sub analyses the results if the no of lettersright is less than the len(wordpicked) variable then a life is deducted. If lives = 0 then the game will terminate and if the noofletters right = lengthofthechosenword list then the game is won. This shows the game being won after 1 incorrect guess. The correct word was CPU
20
Testing and Development If the user guesses incorrectly 3 times he should lose the game 1) Word picked File System enter guess file 2) Try 2 guess entered past guesses to list and lists equalised 2 nd guess entered and unsuccessful 3 rd attempt entered 3 rd unsuccessful attempt and game ends
21
Pick A word Enter the following script. We are going to create a sub here called start the game Variable – change howmanywordssaked by 1 Use the repeat until function Repeat until the lengthof item rnd(ofwordsasked) > 1 then Set chosenword to = item (rnd) of wordsaksed This sub checks the length of the word chosen and makes sure that word cannot be chosen again.
22
Make A Guess Enter the following script so that the user can make a guess. If the guess is correct the game should terminate Create 2 lists where the user’s guess and the computers chosen word are written.
23
Write to the lists and check length of list These subs will write the user guess and the chosen word to the chosenwordlist and userwordlist. This sub checks the length of each list. If they are not equal it will write an * to the list.
24
Game result The following sub checks the result and records the number of letters correct and the number of letters wrong
25
Extension 1)See if you can set a number of lives 2)Reveal only the correct letters in the places where they appear and * with the incorrect guesses 3)Create a sub which will add a new word and checks to see if it is in the list 4)What can you do to extend this into a hangman game? 5)Can you use the custom blocks in BYOB to improve your programming technique
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.