Coding the game engine
Let's get started with the most significant class of this project- SnakeGame
. This will be the game engine for the Snake game.
Coding the members
In the SnakeGame
class that you created previously, add the following import statements along with all the member variables shown next. Study the names and the types of the variables as you add them because they will give a good insight into what we will be coding in this class.
import android.content.Context; import android.content.res.AssetFileDescriptor; import android.content.res.AssetManager; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.graphics.Point; import android.media.AudioAttributes; import android.media.AudioManager; import android.media.SoundPool; import android.os.Build; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; import java.io.IOException; class SnakeGame extends SurfaceView implements...