High Score Object
High Score Object
-------------------------------------------------------
-- ©2007 Josh Chunick
--
-- This parent script creates an object that can be
-- used to keep track of the high scores section in
-- a game.
--
-- To intitialize the object:
-- highScoreObj = script("highscore object").new(10, "AAA", 10000)
-- the first parameter is the number of entries in the highScore list
-- the second parameter is the name of the player - in this case, the default
-- using old style 3 letter arcade convention.
-- the third parameter is the default score that will be shown; arcade convention.
-- Passing the initial parameters are optional. The default values are 10, "AAA", 0
-- ***********
-- if you want to add other parameters then this format will work:
-- [[ #score: 3200, #player:"John", #time: the systemDate]]
-- in this format the sub-property list will be sorted using sort() property
-- based on the first property:item entry in the list.
-- ***********
various initParams configurations
-- [#loadMethod: {#getPref, #fileIO, #xtra}, #prefName: "", #filePath: {"C:\..\..",
http://../}, #handlerName: "someHandler"]
-- ie. [#loadMethod: #getPref, #prefName: "somePrefName"]
-- ie. [#loadMethod: #fileIO, #filePath: "C:\Documents and
Settings\<user>\Applications\<game>\highscore.txt"]
-- ie. [#loadMethod: #xtra, #handlerName: "someHandler"]
property pHighScoreList
-------------------------------------------------------
---------------- PUBLIC FUNCTIONS ---------------------
-------------------------------------------------------
end if
end if
return me
end
on getNumberOfHighScores me
return pHighScoreList.count
end
on getHighestScore me
return pHighScoreList.max()
end
on getLowestScore me
return pHighScoreList.min()
end
-------------------------------------------------------
---------------- PRIVATE FUNCTIONS --------------------
-------------------------------------------------------
on leftPadZero me, str, pad
repeat while length(str) < pad
str = "0" & str
end repeat
return str
end