UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas...

19
UNIT 8 – MOBILE DEVELOPMENT Task 3 – Nicholas Robinson (1598235125)

Transcript of UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas...

Page 1: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

UNit 8 – mobile development

Task 3 – Nicholas Robinson (1598235125)

Page 2: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Unit 8 – Task 3:

Predefined Code

Uri uri1; //variable for first image

Uri uri2; //variable for second image

Uri uri3; //variable for third image

Uri uri4; //variable for fourth image

string soundFile = "";

Random randomIndex = new Random();

int number;

int score; //keep a count of the score

int check;

InitializeComponent();

//call method to load images and sounds

loadImagesSounds();

public void loadImagesSounds()

{

listColoursL1.Add("orange");

listColoursL1.Add("blue");

listColoursL1.Add("red");

listColoursL1.Add("yellow");

}

public void checkCount()

{

Page 3: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

if (check > 4)

{

txtCheckCount.Text = "Game Over";

btnPlay.IsEnabled = false;

check = 0;

}

else

{

txtCheckCount.Text = check.ToString() + " attempts taken" + " Score: " +score.ToString();

}

}

public void loadImages()

{

//set the variable with the first image

uri1 = new Uri("/Assets/" + listColoursL1[0] + ".png", UriKind.Relative);

img1.Source = new System.Windows.Media.Imaging.BitmapImage(uri1);

uri2 = new Uri("/Assets/" + listColoursL1[1] + ".png", UriKind.Relative);

img2.Source = new System.Windows.Media.Imaging.BitmapImage(uri2);

uri3 = new Uri("/Assets/" + listColoursL1[2] + ".png", UriKind.Relative);

img3.Source = new System.Windows.Media.Imaging.BitmapImage(uri3);

uri4 = new Uri("/Assets/" + listColoursL1[3] + ".png", UriKind.Relative);

img4.Source = new System.Windows.Media.Imaging.BitmapImage(uri4);

}

private void Play_Click(object sender, RoutedEventArgs e)

Page 4: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

{

//call the method to load the colours when the play button is pressed

loadImages();

//select a random number between 0 and 4

number = randomIndex.Next(0, 4);

//select a random number between 0 and 4

soundFile = listColoursL1[number];

//set the source code for the sound

SoundClip.Source = new Uri("/Assets/" + soundFile + ".mp3", UriKind.Relative);

//set to play

SoundClip.AutoPlay = true;

SoundClip.Play();

}

Page 5: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Asset Table:

File name Description Source

btnStart Start the game. Visual Studio.

btnSound Play the previously played sound.

Visual Studio.

btnHelp Display the help page. Visual Studio.

Apple.png Apple image. http://adventuretime.wikia.com/wiki/File:Apple.png

Banana.png Banana image. https://www.iconspng.com/image/99874/banana

Cat.png Cat image. http://www.pngmart.com/image/tag/cat

Dog.png Dog image. https://pngtree.com/free-animals-png/dog

Elephant.png Elephant image. http://pngimg.com/imgs/animals/elephants/

Fork.png Fork image. http://www.pngmart.com/image/tag/fork

Apple.m4a A is for apple sound. Audacity.

Banana.m4a B is for banana sound. Audacity.

Cat.m4a C is for cat sound. Audacity.

Dog.m4a D is for dog sound. Audacity.

Elephant.m4a E is for elephant sound. Audacity.

Fork.m4a F is for fork sound. Audacity.

Page 6: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Screens:

Main Page:

Help Page:

Page 7: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Code by Me:

private void btnSound_Click(object sender, RoutedEventArgs e)

{

// Grab the sound file last played

soundFile = listAlphabetL1[number];

// Set the source code for the sound

SoundClip.Source = new Uri("/Assets/Sounds/" + soundFile + ".m4a", UriKind.Relative);

// Set to play

SoundClip.AutoPlay = true;

SoundClip.Play();

}

Repairs or changes:

Last 3 images being the Dog image, I had not changed the image location so it was displaying the 4 th image.

Apple and Dog not being clickable or usable. Adding a sound button to play the previously played sound.

Page 8: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Optimisation:

The application is written in visual studio, using the Windows Phone SDK, the main application code is in XAML, the code behind the different buttons, functions and build for the application is written in C’#.

The application uses 7 words, assigned to the corresponding letter, which matches the sound file to the image.

The images themselves were compressed into png file, creating less file size, the wav audio sound files, were originally very big in size, so I converted them into m4a, compressed them and inserted them into the mobile application.

The game starts off with 3 buttons. Start, help and sound. To begin the game click the start button, the game will preview a sound, if you can assign the images to that sound/letter you earn a point, if not you don’t gain anything. You have 4 lives before the game restarts your points. If you did not hear the sound, you can simply press the sound button and it will replay the previously played sound. If you are struggling simply press the help button and it will tell you how to play the game and what is the purpose.

Page 9: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

User Review:

Enoch Jongwe:

Page 10: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

Test Plan:Test No.

Description Action Expected Result

Actual Result

Changes

1. Start button which will start the alphabet game.

Clicking the start button.

The alphabet game will start.

The game starts. N/A

2. Sound button which will play the previously played sound.

Clicking the sound button.

To play the previous played sound.

The game plays the previous played sound.

N/A

3. Help button which will display the help page on how to play the game.

Clicking the help button.

To display the help page, to assist you on how to play the game.

The help page is displayed when the help button is clicked.

N/A

4. Pressing the apple image when playing the game to earn or lose you a point.

Clicking the apple image so you either earn or lose a point in the alphabet game.

When you click the apple image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

N/A

5. Pressing the banana image when playing the game to earn or lose you a point.

Clicking the banana image so you either earn or lose a point in the alphabet game.

When you click the banana image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

Improved the banana image, so it is easier to see on the game.

6. Pressing the cat image when playing the game to earn or lose you a point.

Clicking the cat image so you either earn or lose a point in the alphabet game.

When you click the cat image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

Improved the cat image, so it is easier to see on the game.

7. Pressing the dog image when playing the game to earn or lose you a point.

Clicking the dog image so you either earn or lose a point in the alphabet game.

When you click the dog image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

Improved the dog image, so it is easier to see on the game.

8. Pressing the elephant image when playing the game to earn or lose you a point.

Clicking the elephant image so you either earn or lose a point in the alphabet game.

When you click the elephant image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

Improved the elephant image, so it is easier to see on the game.

9. Pressing the fork image when playing the game to earn or lose you a point.

Clicking the fork image so you either earn or lose a point in the alphabet game.

When you click the fork image, once the game has started you either earn or lose a point.

The image works as expected when it is clicked.

N/A

10. The “txtMessage” will display whether you have scored a point on an image or you pressed the

Clicking an image which will let you know whether you picked the right

To display whether you scored or lost a point.

The image displays whether you earn or don’t earn a point.

N/A

Page 11: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

wrong image. or wrong image.11. Sound button on

the help page, which will tell the young players how to start the game.

Clicking the sound button on the help page to play the help sound file.

Play the sound file, when the button is clicked.

The sound file is played when the sound button is clicked.

Added it into the game.

Changes:

Before The changes:

No audio on the help page. Elephant, Banana, Dog and Cat images difficult to see.

After The Changes:

Added audio, so the help page has writing for adults and a help button for young children. Fixed the background problem for the Banana, Cat, Dog and Elephant.

Constructs:

Code Dump:

public partial class MainPage : PhoneApplicationPage {

// Declare a list to hold letters List<string> listAlphabetL1 = new List<string>();

// Create variables for the 6 images.

Uri uri1; // The variable for the first alphabet image. Uri uri2; // The variable for the sceond alphabet image. Uri uri3; // The variable for the third alphabet image. Uri uri4; // The variable for the fourth alphabet image. Uri uri5; // The variable for the fifth alphabet image. Uri uri6; // The variable for the sixth alphabet image.

string soundFile = ""; Random randomIndex = new Random(); int number; int score; // Keep a count on the players score. int check; // Keep a count of the players amount of attemps.

public MainPage() {

Page 12: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

InitializeComponent(); // Load the images and sounds for the application. loadImagesSounds(); }

// Loads a list of the images and sound files with the below names.

public void loadImagesSounds() {

listAlphabetL1.Add("Apple"); listAlphabetL1.Add("Banana"); listAlphabetL1.Add("Cat"); listAlphabetL1.Add("Dog"); listAlphabetL1.Add("Elephant"); listAlphabetL1.Add("Fork"); }

// Set the amount of failed attempts to 4 before resetting the game.

public void checkCount() { if (check > 4) { txtCheckCount.Text = "Game Over"; btnStart.IsEnabled = true; check = 0;

} else { txtCheckCount.Text = check.ToString() + " attempts taken" + " Score: " + score.ToString();

} }

// Load images when the start button is pressed. public void loadImages() { // Set the variable with the first image uri1 = new Uri("/Assets/Images/" + listAlphabetL1[0] + ".png", UriKind.Relative); img1.Source = new System.Windows.Media.Imaging.BitmapImage(uri1);

uri2 = new Uri("/Assets/Images/" + listAlphabetL1[1] + ".png", UriKind.Relative); img2.Source = new System.Windows.Media.Imaging.BitmapImage(uri2);

uri3 = new Uri("/Assets/Images/" + listAlphabetL1[2] + ".png", UriKind.Relative); img3.Source = new System.Windows.Media.Imaging.BitmapImage(uri3);

uri4 = new Uri("/Assets/Images/" + listAlphabetL1[3] + ".png", UriKind.Relative); img4.Source = new System.Windows.Media.Imaging.BitmapImage(uri4);

uri5 = new Uri("/Assets/Images/" + listAlphabetL1[4] + ".png", UriKind.Relative); img5.Source = new System.Windows.Media.Imaging.BitmapImage(uri5);

Page 13: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

uri6 = new Uri("/Assets/Images/" + listAlphabetL1[5] + ".png", UriKind.Relative); img6.Source = new System.Windows.Media.Imaging.BitmapImage(uri6);

}

private void btnStart_Click(object sender, RoutedEventArgs e) { // Load the alpahabet images when the start button is pressed. loadImages();

// Pick a random number between 0 and 6 // take a look at this. number = randomIndex.Next(0, 6);

// Pick a random number between 0 and 6 soundFile = listAlphabetL1[number];

// Set the location of the sound file for the assigned image file name. SoundClip.Source = new Uri("/Assets/Sounds/" + soundFile + ".m4a", UriKind.Relative);

// Set the sound to play. SoundClip.AutoPlay = true; SoundClip.Play(); }

// This is used to replay the sound which was just played, incase the player/user misheard it.

private void btnSound_Click(object sender, RoutedEventArgs e) { // Grab the sound file last played soundFile = listAlphabetL1[number];

// Set the location of the sound file for the assigned image file name. SoundClip.Source = new Uri("/Assets/Sounds/" + soundFile + ".m4a", UriKind.Relative);

// Set the sound to play. SoundClip.AutoPlay = true; SoundClip.Play(); }

private void img1_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[0]) { txtMessage.Text = "You have selected " + listAlphabetL1[0]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; }

Page 14: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

txtScore.Text = "Score: " + score.ToString();

checkCount(); }

private void img2_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[1]) { txtMessage.Text = "You have selected " + listAlphabetL1[1]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; } txtScore.Text = "Score: " + score.ToString();

checkCount(); }

private void img3_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[2]) { txtMessage.Text = "You have selected " + listAlphabetL1[2]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; } txtScore.Text = "Score: " + score.ToString();

checkCount(); }

private void img4_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[3]) { txtMessage.Text = "You have selected " + listAlphabetL1[3]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; }

Page 15: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson

txtScore.Text = "Score: " + score.ToString();

checkCount(); }

private void img5_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[4]) { txtMessage.Text = "You have selected " + listAlphabetL1[4]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; } txtScore.Text = "Score: " + score.ToString();

checkCount(); }

private void img6_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { // Every time the image is clicked, increase the check variable. check = check + 1;

if (soundFile == listAlphabetL1[5]) { txtMessage.Text = "You have selected " + listAlphabetL1[5]; btnStart.IsEnabled = true; score = score + 1; } else { txtMessage.Text = "Sorry, try again!"; } txtScore.Text = "Score: " + score.ToString();

checkCount(); } }

Page 16: UNit 8 – mobile development€¦  · Web viewUNit 8 – mobile development. Task 3 – Nicholas Robinson (1598235125) UNit 8 – mobile development. Task 3 – Nicholas Robinson