Chapter 8
Q1) What about a visual improvement for our game screen, perhaps a nice, light green grassy background instead of just black?
A) You can use most graphics programs such as Gimp or Photoshop to get the RGB value of a nice, light green grassy color. Alternatively, you can use an online color picker such as http://www.colorpicker.com/. Then look at this line in our drawGame
method:
canvas.drawColor(Color.BLACK);//the background
Change it to the following line:
canvas.drawColor(Color.argb(255,186,230,177));//the background
Q2) How about adding some nice flowers to the background?
A) Here is the way to do this. Create a flower bitmap (or use mine), load it, and scale it in the usual way, in the configureDisplay
method. Decide how many flowers to draw. Choose and store locations on the board in the SnakeView
constructor (or write and call a special method, perhaps plantFlowers
).
Draw them before the snake and the apple in the drawGame
method. This will ensure that they can never hide an apple...