How to move the mouth of pacman?

3 views (last 30 days)
Airas Akhtar
Airas Akhtar on 11 Oct 2014
Answered: Geoff Hayes on 11 Oct 2014
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)

Geoff Hayes
Geoff Hayes on 11 Oct 2014
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

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!