Wednesday, 27 October 2010

A finite state machine for previous states and pseudo code







case START:
-Load Start Screen-

if(PlayerClickHighScore)
{
    state = HIGH_SCORE;
}

else if(playerClickStart)
{
    state = GAME_LOOP;
}

break;

case HIGH_SCORE:
-Show high scores-

if (PlayerClickPlay)
{
    state = START;
}
break;

case GAME_LOOP:
-Do game actions-

if(PlayerPressESC)
{
    case = START;
}


else if(PlayerPressPause)
{
    set gameispaused = true;
    state = PAUSE;
}


else if(timer = 0)
{
    case = GAME_OVER;
}
break;

case PAUSE:
-Pause game-

if ((gameispaused = true) && (PlayerPressPause))
{
    case = GAME_LOOP
}
break;

case GAME_OVER:
-show game over screen-

if(score > lowestHighScore)
{
    Enter initials;
    case = High_SCORE
}

else
{
    case = START;
}
break;


The point of this pseudo code is to give me a base to structure my code so that it decreases complexity.