O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — saving the high score list

  1. Create a new method called SaveHighScore.
    Method SaveHighScore:Int ()
    
  2. Use the SaveToString method of the engine's scoreList to save it to a string.
    Local hs:String = g.eng.scoreList.SaveToString()
    
  3. Save this string with a call to SaveState. Then close this method.
    SaveState(hs)
    Return 0
    End
    

What just happened?

By creating more specialized help methods, we can easily plug them into the game where we need them. Also, we have avoided creating redundant code, which means we don't have duplicate code sections in the game.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required