Вы находитесь на странице: 1из 7

States Machines

Mario Bros Water Company


Leaf State Machine

LEAF_VALID
Post LEAF_ACTIVATED | Leaf LED Off

Leaf LED On

LeafNotInserted LeafInserted

LEAF_REMOVED
Post LEAF_RESET | Leaf LED On
Control State Machine
LEAF_ACTIVATED DIFFICULTY_CHANGE
ES_INIT Restart Inactivity timer
Start Inactive Timer | Pulse Difficulty LED initially
VisualBlast | Stop the visual blast
Set the inactive timer
Switching on Start Button LED
Welcoming
Reading
Setup Difficulty
LEAF_RESET
MARIO_START_AND_FLAG_DOWN
ANALOG_READ_COMPLETE*
VisualBlast
Pulse LED Accordingly
INACTIVE TIMER TIMEOUT
Post INACTIVE_RESET START_BUTTON_PRESSED
Post START_MARIO|START_GAME
Restart the Inactivity Timer | Switch
MovingMarioBack Resetting off pulsing of the difficulty led |
Post difficulty for the pipe timer (as
MARIO_START
LEAF_RESET an event param to the
Post RESET|Flash Leaf LED START_GAME) |
Play Game Start sound |
INACTIVE_RESET Switch off start button LED
FLAG_UP Post INACTIVE_RESET In Game
Move Mario to the back | Stop the flag

Ending
MARIO_END Notes
1. Reset includes both LEAF_RESET and INACTIVE_RESET
Start Flag|Start Sound|Start Stamp | Stop Mario 2. ANALOG_READ_COMPLETE should be passed
immediately after reading difficulty from the hardware
read of difficulty.
Game State Machine
START_GAME
Post ACTIVATE_RANDOM_PIPE | Set Pipe Timer from received
difficulty| Set Score Timer | Initialize the random pipe index
ES_INIT
Uninitialized Selecting Pipe
RESET
MARIO_END ACTIVATE_RANDOM_PIPE
Select a Pipe, Restart/Start Pipe Timer | Start Pipe
PIPE_TIMER_TIMEOUT Lights|Restart/Start Score Timer | Restart
Post ACTIVATE_RANDOM_PIPE WATER_FLOW_TIMER

RESET
WATER_FLOW_TIMER_TIMEOUT
Water IR Connection (no bucket placed)
SR_Write a random number to
simulate following water Flowing Post SCORE_DEC|Restart Score Timer|Bad
Sound | Restart the inactivity timer

ND IR No Connection (bucket placed)


A RIO_E
M Score Timer Timeout Start Score Timer|Good Sound | Restart the
inactivity timer

Wait for Reset MARIO_END


IR Read
RESET

Notes
RESET 1. There is a check at the starting itself if the ControlSM is in
the InGame State to make any changes to this SM. If not,
the state is set to Uninitialized
2. Reset refers to both LEAF_RESET and INACTIVE_RESET
3. Scoring for the activated pipe is done by checking for the
IR connection
Scoring State Machine
SCORE_DEC
RESET
ES_INIT Decrease Score

START_GAME
ON Green|Initialize Score
Uninitialized Green LED Score below T1 SCORE_DEC
ON Yellow Decrease Score
RESET
MARIO_END
Play Good Sound Green Yellow
FLAG_UP LED
MARIO_E RESET
ND
Play Good
Sound
Score below T2
OFF Green
Wait for
Ending MARIO_END SCORE_DEC
RESET Play Inter. Sound Score decrease
Yellow LED
MARIO_END
MARIO_END
Play Bad Sound
Play Inter Sound Score below T3
ON Red

Yellow Red
Red LED
RESET Score below T4
LED SCORE_DEC RESET

OFF Yellow Decrease Score


SCORE_DEC Points to Remember
1. Reset includes both LEAF_RESET
Score decrease and INACTIVE_RESET
2. Sound play being taken care of
in ControlSM
Visual Blast State Machine

VISUAL_BLAST_OFF
Switch off all the hill LEDs and pipe LEDs
VISUAL_BLAST_ON
Post GLOW_RANDOM_PIPE to this SM | Glow a random hill led

SelectingPipeLed

GLOW_RANDOM_PIPE
ES_INIT VISUALBLAST_PIPE_TIMER_TIMEOUT Select a random Pipe, Restart VisualBlast_Pipe
Switch off hill Timer | Start Pipe LED | Glow a random hill led
Post GLOW_RANDOM_PIPE to this SM | switching off the last one
and pipe leds Switch off the last Pipe LEDs
VisualBlastOff

GlowingPipeLed

VISUAL_BLAST_OFF
Switch off all the hill LEDs and pipe LEDs

Points to Remember
1. Reset, both types, should post to this service
Mario Movement State Machine

MOVE_MARIO or ES_TIMEOUT (9 sec)[Mario Not at End and ControlSM is in InGame state]


Restart timer for 1 sec | Move Mario towards right

ES_INIT

MarioNotMoving

MarioMoving

ES_TIMEOUT (1 sec)
Restart timer for 9 sec | Stop Mario movement

Points to Remember
1. This SM syncs Mario motion with game time

Вам также может понравиться