|
Lessons from BOB : PART TWO
ANIMATING THE FACE
To animate the face, you will need to draw an image on the GLCD and then wait for a while – anything more than 50 msec and then draw a second image.
Let’s just say we want the right eye to blink. We first draw the whole face. Then we draw the right eye close and wait for 500 msec. We now draw the right eye open again. This will give the illusion that the eye is blinking. Try the following code: CODE :
Most of the codes are from lesson one; the additional codes are the last 6 lines.
We can do the same for the mouth. To make it look like the face is talking we will need to draw different positions of the mouth again and again.
To make things a little more interesting, we can make use of a random generator to randomly decide which mouth to draw. The RND function will return a random value every time it is called. Check the ‘FIDE System Library’ documentation for details of the RND function.
CODE :
The above code will randomly return a number from 0 to 2. (Don’t forget to declare POS at the top of your code eg. Dim POS As Integer).
But, our mouth images for talking are positions 3, 4 and 5. So we add 3 to get these values.
CODE :
To draw the mouth repeatedly, we use DO LOOP. Try out the code below.
CODE :
That is all that you will need to make the GLCD face blink and talk.
CODE :
Don't understand certain parts? Try starting from Part One Here. Continue to Part THREE >>>
|
Resources

