How to move the mouth of pacman?

I want the mouth of the pacman to open and close.For that I have to change the circle as it moves.Can I use the mod function somehow in it?

Answers (1)

Airas - yes, you could use mod to determine the state of the packman. Referring back to your question at how to move a circle on a sine curve, you could do
for ii=0:200
if mod(ii,2)
% k is even so mouth is closed
% draw closed yellow circle
else
% k is odd so mouth is open
% draw open yellow circle
end
end
The trick is how will you draw the two versions of the pacman - will you have two sets of vertices, one for the closed mouth and one for the open, and then just alternate showing one or the other? (By setting the Visible property to on or off.)

Categories

Asked:

on 11 Oct 2014

Answered:

on 11 Oct 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!