Skip to content

An Android application that puts a creative twist on the game of Hangman by offering 10+ levels of increasing difficulty along with freeplay options

Notifications You must be signed in to change notification settings

justinshapiro/thegallows

Repository files navigation

Commit History

Notes for each commit
04/10/2016 - Justin:
WordBank class completed. See JAVADOC comments for details of each the class, main method, helper methods and constructor. The only method of WordBank that should be referenced is getGameWord(), which is the main method, as all of the other ones are helper methods. However, I make each method public so if we need to use one of the helper methods later down the road we can.
I also created a "test_files" folder under java/csci3320/thegallows and within it included TestWordBank. This was the class that I used to test the WordBank class to verify that getGameWord() was returning the correct results. Each helper method was also tested in TestWordBank. Nothing needs to be done with this class, but I included it in case we need to perform additional testing on the functionality of WordBank in the future.
I created a folder under main called "assets" which contains four .txt files: "easy.txt", "medium.txt", "hard.txt" and "freeplay.txt". Each file has been populated with some words, however whether the words are valid for their associated difficulty level or not is not certain, so once we get the program working we'll have to review these libraries. "freeplay.txt" is simply a copy of the words in each file. I may modify the code of getGameWord() at a later point in time to select randomly from any other three other files to eliminate the redundancy of an aggregate file.
With the completion of WordBank and the population of the .txt difficulty libraries, the word generation feature of the Gameplay class can now be implemented. In Gameplay, to retrieve a word for a game, a new WordBank object must be created: WordBank newWordBank = new WordBank(difficulty), where difficulty is an object of type String that can contain only the following Strings: "EASY", "MEDIUM", "HARD" or "FREEPLAY". I have not implemented error handling in WordBank, so we need to be sure we code the app to pass the correct constructor arguments to WordBank.
I also tried to create a layout for the Gameplay activity (see activity_gameplay.xml). I've created the keyboard and plan on implementing the section of the screen where the words and the blanks display. That is, there is a GridLayout where half is dedicated to the "word area" and the other half dedicated to the timer, keyboard, and hangman animation. This "word area" will contain an interface that uses WordBank. I am going to try to get the word to appear in the Gameplay activity by before class on Tuesday.
04/13/2016 - Alex:
StartScreen and Endgame classes were implemented. On StartScreen, there are now four buttons, four the three difficulty levels and Freeplay. In StartScreen the difficulty level is passed to the Gameplay class via an Intent. When the user presses a button on StartScreen, this Intent starts the Gameplay activity. The Gameplay activity then accesses the difficulty passed via getIntent().getStringExtra("Difficulty").
Similarly, the Endgame class has been implemented with two buttons: "Play Again" and "Change Difficulty". If the "Play Again" button is pressed, the previous difficulty is passed back into the Gameplay activity and that activity is reinstantiated. If the "Change Difficulty" button is pressed, the user is taken back to the StartScreen activity where they can reselect the difficulty mode.
04/13/2016 - Justin:
Significant changes were made since my last commit. First off, the layout of the Gameplay activity in activity_gameplay.xml was redone completely. The layout is actually now more simple: the keyboard is in the QWERTY form and on the bottom of the screen, with the Word Area directly above it. On top of the Word Area will be the hangman picture/animation. I put an ImageView widget in the ScrollView container above the Word Area container, anticipating an image to be placed there.
The Gameplay class was implemented in Java. All items from activity_gameplay.xml are now instantiated in the Gameplay class. A dynamically generated TableLayout was implemented inside the Word Area container in order to display the letters of the WORD with a bar underneath. Each word and associated underline is in a single cell of the table. In the code, it is defined for the first row to be dedicated to the various letters of the WORD, and the second row simply contains two _ characters. The characters in each cell are made possible by a TextView. The letter characters are initially made the same color as the background to appear invisible to the user. Once the user starts selecting buttons, the buttons will become invisible and if the correct button is selected the procedure updateAllOccurrences() goes through an array of TextView objects and determines if the letter associated with the pressed button is in one of those TextView objects. The updateAllOccurrences() exists simply to make sure multiple occurrences of letters are made visible to the user instead of just one. Lastly, a GameOver method was called if the number of attempts (6) were exceeded indicating a lost game, or if the the number of attempts was 6 or less and the number of succeeded tries is equal to the number of characters in the WORD, indicating a win. The Gameplay activity is ended with initiating an Intent that passes the win/loss status, WORD, and current difficulty to the Endgame activity.
The WordBank class was also modified due to some interesting discoveries. Since WordBank is a class not extending Activity, the application Context must be a parameter in its constructor. The reason for needing the application Context is due to the fact that files in the assets folder of the project cannot directly be accessed by file path. The method getAssets() must be used to reference the file. Therefore, slight changes to the methods were made. Particularly, the getFileLength() method was simplified a significant amount by simply iterating the readLine() member method until null.
04/21/2016 - Justin:
I redesigned the way that the game is going to be played. It gets quite boring after a while to just keep selecting "Easy", "Medium", and "Hard" due to the one-dimensional aspect of it. Therefore, the game will now have a purpose: the purpose of the game is to complete a quest whereby you must complete 30 levels in order to win (currently there are only 6 levels implemented but the functionality of this concept works). During this quest, you will have 3 lives and three hints. A hint is simply a definition of the word you are trying to solve.
To implement this overhaul of the type of game we are playing, the following changes were made: (1) StartScreen now has two buttons only: "REGULAR PLAY" and "FREEPLAY". Regardless of user selection, the StartScreen class will create an Intent for the Gameplay class that passes "GameType", "LEVEL", "LIFE", and "HINTS". If the user selects "REGULAR PLAY", "GameType" is "REGULAR", "LEVEL" is 1, and "LIFE" and "HINTS" are both 3. If the user selects "FREEPLAY", "LEVEL" and "LIFE" are 0 and "HINTS" is 1. In the final version of the game, the values of the Intent passed to Gameplay when choosing "FREEPLAY" should be customized in preferences. (2) In the Gameplay activity, initGameStatusArea() was added to fill the top of the screen with all information related to this new kind of game type (the level you are on, topic of level, lifes left and hints left).initKeyboard() was modified to initialize the "hintKey" that, when pressed, displays the hint in a Toast. The play() method was modified slightly to deal with hints, but remained unchanged after that. The gameOver() method was modified the most out of all the methods. It uses nested if-statements in order to determine how to route the user according to the "GameType" passed from StartScreen and number of lives and levels the user has left. (3) The Endgame activity was changed very slightly. The button that originally said "Change Difficulty" now says "Main Menu".
Unreleated to the overhaul of the game play, the Gameplay activity was modified to deal with phrases along with words. That is, spaces and dashes can now be a part of the word you are trying to solve, but the actual letters are the only factor that the user is concerned about. Also, when the user is finished solving a word, the word will either highlight red or green depending if the user one or lost. There is a slight pause that was implemented with a Handler before the user is routed to the next stage of the game.
04/22/2016 - Justin:
Bug fixed in FREEPLAY mode that caused the same two library files to be picked for the word each time. This was due to an error with the random number generator in the getFile() method in the WordBank class. The while loop was eliminated and replaced with random.nextInt(LEVEL_MAX) + 1;. Also modified the Endgame class to pass the appropriate level, hints and life value in the Intent to the next Gameplay if the user selected "Play Again".

About

An Android application that puts a creative twist on the game of Hangman by offering 10+ levels of increasing difficulty along with freeplay options

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages