Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Play a sound as the snake moves through the tiles. Play a sound when the snake eats an apple. Play a sound when the snake

  • Play a sound as the snake moves through the tiles.
  • Play a sound when the snake eats an apple.
  • Play a sound when the snake hits either the wall or himself.

You will also create a technical memo for developers describing the new updates to the snake game application.

Instructions

  • Download the Snake Game Code from the Unit 1 studies and import the snake code into Android Studio.
  • Verify that the Snake Android game application can execute without error.
  • Locate and initialize three sounds for the snake game.
    • Research free sounds to be included in games on the Internet. One optional resource is Free Sound, linked in the Resources.
    • Choose three sounds to add to the game.
  • Choose implementation direction of using MediaPlayer, AudioManager, or both, and add the sound files to the appropriate resource area in the Project Area or make external calls to ULRs with the sounds.
  • Play sound as the snake moves through tiles.
  • Play sound when the snake eats an apple.
  • Play sound when the snake hits a wall or itself.
package com.example.android.snake; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.widget.TextView; import android.media.MediaPlayer; /** * Snake: a simple game that everyone can enjoy. * * This is an implementation of the classic Game "Snake", in which you control a * serpent roaming around the garden looking for apples. Be careful, though, * because when you catch one, not only will you become longer, but you'll move * faster. Running into yourself or the walls will end the game. * */ public class Snake extends Activity { private SnakeView mSnakeView; private static String ICICLE_KEY = "snake-view"; /** * Called when Activity is first created. Turns off the title bar, sets up * the content views, and fires up the SnakeView. * */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.snake_layout); mSnakeView = (SnakeView) findViewById(R.id.snake); mSnakeView.setTextView((TextView) findViewById(R.id.text)); if (savedInstanceState == null) { // We were just launched -- set up a new game mSnakeView.setMode(SnakeView.READY); } else { // We are being restored Bundle map = savedInstanceState.getBundle(ICICLE_KEY); if (map != null) { mSnakeView.restoreState(map); } else { mSnakeView.setMode(SnakeView.PAUSE); } } } @Override protected void onPause() { super.onPause(); // Pause the game along with the activity mSnakeView.setMode(SnakeView.PAUSE); } @Override public void onSaveInstanceState(Bundle outState) { //Store the game state outState.putBundle(ICICLE_KEY, mSnakeView.saveState()); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions