Reader small image

You're reading from  Learning Java by Building Android Games - Third Edition

Product typeBook
Published inMar 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800565869
Edition3rd Edition
Languages
Right arrow
Author (1)
John Horton
John Horton
author image
John Horton

John Horton is a programming and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles. He is the founder of Game Code School.
Read more about John Horton

Right arrow

Rotating Bitmaps

Let's do a little bit of theory before we dive into the code and consider exactly how we are going to bring the snake to life. Look at this image of the snake's head:

Figure 17.1 – Snake's head

And now look at one of the snake's body segments:

Figure 17.2 – Snake's body

Regarding the body segment, it is a near-perfect circle, it is symmetrical horizontally and vertically through the center. This means that it will look OK whatever way the snake is headed.

The head, on the other hand, is facing right and will look ridiculous when it is headed in any direction other than to the right.

It would be quite easy to use Photoshop or whatever your favorite image editing software happens to be and create three more Bitmaps from the head Bitmap to face in the other three directions.

Then when we come to draw the Snake, we can simply detect which way it is heading and draw the appropriate...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Java by Building Android Games - Third Edition
Published in: Mar 2021Publisher: PacktISBN-13: 9781800565869

Author (1)

author image
John Horton

John Horton is a programming and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles. He is the founder of Game Code School.
Read more about John Horton