Class: RPM

RPM

Utility class with a lot of functions

new RPM ()

Properties:
Name Type Argument Default Description
RPM.PATH_BR string <optional>
""
RPM.ROOT_DIRECTORY_LOCAL string <optional>
"."
RPM.PATH_FILES string <optional>
"file:///"
RPM.PATH_DATAS string <optional>
Platform.ROOT_DIRECTORY + "/Content/Datas/"
RPM.EXTENSION_JSON string <optional>
".json"
RPM.FILE_MAPS string <optional>
RPM.PATH_DATAS + "Maps/"
RPM.FILE_MAP_INFOS string <optional>
"/infos" + RPM.EXTENSION_JSON
RPM.FILE_MAP_OBJECTS string <optional>
"/objects" + RPM.EXTENSION_JSON
RPM.FILE_PICTURES_DATAS string <optional>
RPM.PATH_DATAS + "pictures" + RPM.EXTENSION_JSON
RPM.FILE_VIDEOS_DATAS string <optional>
RPM.PATH_DATAS + "videos" + RPM.EXTENSION_JSON
RPM.FILE_SONGS_DATAS string <optional>
RPM.PATH_DATAS + "songs" + RPM.EXTENSION_JSON
RPM.FILE_SHAPES_DATAS string <optional>
RPM.PATH_DATAS + "shapes" + RPM.EXTENSION_JSON
RPM.FILE_COMMON_EVENTS string <optional>
RPM.PATH_DATAS + "commonEvents" + RPM.EXTENSION_JSON
RPM.FILE_ITEMS string <optional>
RPM.PATH_DATAS + "items" + RPM.EXTENSION_JSON
RPM.FILE_SKILLS string <optional>
RPM.PATH_DATAS + "skills" + RPM.EXTENSION_JSON
RPM.FILE_WEAPONS string <optional>
RPM.PATH_DATAS + "weapons" + RPM.EXTENSION_JSON
RPM.FILE_ARMORS string <optional>
RPM.PATH_DATAS + "armors" + RPM.EXTENSION_JSON
RPM.FILE_HEROES string <optional>
RPM.PATH_DATAS + "heroes" + RPM.EXTENSION_JSON
RPM.FILE_MONSTERS string <optional>
RPM.PATH_DATAS + "monsters" + RPM.EXTENSION_JSON
RPM.FILE_TROOPS string <optional>
RPM.PATH_DATAS + "troops" + RPM.EXTENSION_JSON
RPM.FILE_BATTLE_SYSTEM string <optional>
RPM.PATH_DATAS + "battleSystem" + RPM.EXTENSION_JSON
RPM.FILE_TITLE_SCREEN_GAME_OVER string <optional>
RPM.PATH_DATAS + "titlescreenGameover" + RPM.EXTENSION_JSON
RPM.FILE_KEYBOARD string <optional>
RPM.PATH_DATAS + "keyBoard" + RPM.EXTENSION_JSON
RPM.FILE_SYSTEM string <optional>
RPM.PATH_DATAS + "system" + RPM.EXTENSION_JSON
RPM.FILE_CLASSES string <optional>
RPM.PATH_DATAS + "classes" + RPM.EXTENSION_JSON
RPM.FILE_TILESETS_DATAS string <optional>
RPM.PATH_DATAS + "tilesets" + RPM.EXTENSION_JSON
RPM.FILE_SPECIAL_ELEMENTS string <optional>
RPM.PATH_DATAS + "specialElements" + RPM.EXTENSION_JSON
RPM.FILE_VARIABLES string <optional>
RPM.PATH_DATAS + "variables" + RPM.EXTENSION_JSON
RPM.FILE_SETTINGS string <optional>
RPM.PATH_DATAS + "settings" + RPM.EXTENSION_JSON
RPM.FILE_DLCS string <optional>
RPM.PATH_DATAS + "dlcs" + RPM.EXTENSION_JSON
RPM.FILE_ANIMATIONS string <optional>
RPM.PATH_DATAS + "animations" + RPM.EXTENSION_JSON
RPM.PATH_PICTURES string <optional>
"/Content/Images"
RPM.PATH_VIDEOS string <optional>
"/Content/Videos"
RPM.PATH_HUD string <optional>
RPM.PATH_PICTURES + "/HUD/"
RPM.PATH_TEXTURES2D string <optional>
RPM.PATH_PICTURES + "/Textures2D/"
RPM.PATH_BARS string <optional>
RPM.PATH_HUD + "Bars"
RPM.PATH_FACESETS string <optional>
RPM.PATH_HUD + "Facesets"
RPM.PATH_ICONS string <optional>
RPM.PATH_HUD + "Icons"
RPM.PATH_WINDOW_SKINS string <optional>
RPM.PATH_HUD + "WindowSkins"
RPM.PATH_TITLE_SCREEN string <optional>
RPM.PATH_HUD + "TitleScreen"
RPM.PATH_HUD_PICTURES string <optional>
RPM.PATH_HUD + "Pictures"
RPM.PATH_ANIMATIONS string <optional>
RPM.PATH_HUD + "Animations"
RPM.PATH_AUTOTILES string <optional>
RPM.PATH_TEXTURES2D + "Autotiles"
RPM.PATH_CHARACTERS string <optional>
RPM.PATH_TEXTURES2D + "Characters"
RPM.PATH_TILESETS string <optional>
RPM.PATH_TEXTURES2D + "Tilesets"
RPM.PATH_WALLS string <optional>
RPM.PATH_TEXTURES2D + "Walls"
RPM.PATH_BATTLERS string <optional>
RPM.PATH_TEXTURES2D + "Battlers"
RPM.PATH_OBJECTS_3D string <optional>
RPM.PATH_TEXTURES2D + "Objects3D"
RPM.PATH_MOUNTAINS string <optional>
RPM.PATH_TEXTURES2D + "Mountains"
RPM.PATH_SKYBOXES string <optional>
RPM.PATH_TEXTURES2D + "SkyBoxes"
RPM.PATH_SONGS string <optional>
"/Content/Songs/"
RPM.PATH_MUSICS string <optional>
RPM.PATH_SONGS + "Musics"
RPM.PATH_BACKGROUND_SOUNDS string <optional>
RPM.PATH_SONGS + "BackgroundSounds"
RPM.PATH_SOUNDS string <optional>
RPM.PATH_SONGS + "Sounds"
RPM.PATH_MUSIC_EFFECTS string <optional>
RPM.PATH_SONGS + "MusicEffects"
RPM.PATH_SHAPES string <optional>
"/Content/Shapes/"
RPM.PATH_OBJ string <optional>
RPM.PATH_SHAPES + "OBJ"
RPM.PATH_MTL string <optional>
RPM.PATH_SHAPES + "MTL"
RPM.PATH_OBJ_COLLISIONS string <optional>
RPM.PATH_SHAPES + "Collisions"
RPM.PATH_SHADERS string <optional>
RPM.PATH_DATAS + "Scripts/System/shaders/"
RPM.PATH_SAVES string <optional>
RPM.PATH_DATAS + "Saves"
RPM.SMALL_FONT_SIZE number <optional>
8
RPM.MEDIUM_FONT_SIZE number <optional>
10
RPM.BASIC_SQUARE_SIZE number <optional>
32
RPM.BATLLER_STEPS number <optional>
9
RPM.SMALL_SLOT_HEIGHT number <optional>
30
RPM.MEDIUM_SLOT_WIDTH number <optional>
200
RPM.MEDIUM_SLOT_HEIGHT number <optional>
40
RPM.LARGE_SLOT_HEIGHT number <optional>
60
RPM.MEDIUM_SPACE number <optional>
5
RPM.LARGE_SPACE number <optional>
10
RPM.HUGE_SPACE number <optional>
20
RPM.PORTIONS_RAY_FAR number <optional>
0
RPM.PORTION_SIZE number <optional>
16
RPM.MAX_PICTURE_SIZE number <optional>
4096
RPM.SCREEN_X number <optional>
640
RPM.SCREEN_Y number <optional>
480
RPM.NONE_PADDING Array.<number> <optional>
[0, 0, 0, 0]
RPM.VERY_SMALL_PADDING_BOX Array.<number> <optional>
[5, 5, 5, 5]
RPM.SMALL_PADDING_BOX Array.<number> <optional>
[10, 10, 10, 10]
RPM.MEDIUM_PADDING_BOX Array.<number> <optional>
[20, 20, 20, 20]
RPM.HUGE_PADDING_BOX Array.<number> <optional>
[30, 30, 30, 30]
RPM.DIALOG_PADDING_BOX Array.<number> <optional>
[30, 50, 30, 50]
RPM.SMALL_SLOT_PADDING Array.<number> <optional>
[10, 5, 10, 5]
RPM.ONE_SECOND_MILLI number <optional>
1000
RPM.NUM_BOOL_TRUE number <optional>
1
RPM.NUM_BOOL_FALSE number <optional>
0
RPM.COEF_TEX number <optional>
0.2
RPM.LOADING_MIN_DELAY number <optional>
100
RPM.CLASS_HIDDEN string <optional>
"hidden"
RPM.STRING_RGBA string <optional>
"rgba"
RPM.STRING_EMPTY string <optional>
""
RPM.STRING_PARENTHESIS_LEFT string <optional>
"("
RPM.STRING_PARENTHESIS_RIGHT string <optional>
")"
RPM.STRING_BRACKET_LEFT string <optional>
"["
RPM.STRING_BRACKET_RIGHT string <optional>
"]"
RPM.STRING_COMA string <optional>
","
RPM.STRING_COLON string <optional>
":"
RPM.STRING_SLASH string <optional>
"/"
RPM.STRING_NEW_LINE string <optional>
"\n"
RPM.STRING_EQUAL string <optional>
"="
RPM.STRING_DASH string <optional>
"-"
RPM.STRING_SPACE string <optional>
" "
RPM.STRING_ZERO string <optional>
"0"
RPM.UNDEFINED string <optional>
'undefined'
RPM.NUMBER string <optional>
"number"
RPM.STRING string <optional>
"string"
RPM.TAG_BOLD string <optional>
"b"
RPM.TAG_ITALIC string <optional>
"i"
RPM.TAG_LEFT string <optional>
"l"
RPM.TAG_CENTER string <optional>
"c"
RPM.TAG_RIGHT string <optional>
"r"
RPM.TAG_SIZE string <optional>
"size"
RPM.TAG_FONT string <optional>
"font"
RPM.TAG_TEXT_COLOR string <optional>
"textcolor"
RPM.TAG_BACK_COLOR string <optional>
"backcolor"
RPM.TAG_STROKE_COLOR string <optional>
"strokecolor"
RPM.TAG_VARIABLE string <optional>
"var"
RPM.TAG_PARAMETER string <optional>
"par"
RPM.TAG_PROPERTY string <optional>
"pro"
RPM.TAG_HERO_NAME string <optional>
"hname"
RPM.TAG_ICON string <optional>
"ico"
RPM.DEFAULT_FONT string <optional>
"sans-serif"
RPM.JSON_KEY string <optional>
"k"
RPM.JSON_VALUE string <optional>
"v"
RPM.COLOR_GREEN SystemColor <optional>
SystemColor.createColor(25, 214, 25)
RPM.COLOR_RED SystemColor <optional>
SystemColor.createColor(216, 33, 17)
RPM.COLOR_WHITE SystemColor <optional>
SystemColor.createColor(255, 255, 255)
RPM.COLOR_BLACK SystemColor <optional>
SystemColor.createColor(0, 0, 0)
RPM.elapsedTime number <optional>
0
RPM.averageElapsedTime number <optional>
0
RPM.lastUpdateTime number <optional>
new Date().getTime()
RPM.keysPressed Array.<number> <optional>
new Array
RPM.fontSize number <optional>
13
RPM.fontName string <optional>
"sans-serif"
RPM.escaped boolean <optional>
false
RPM.blockingHero boolean <optional>
false
RPM.game Game <optional>
null
RPM.textureLoader THREE.TextureLoader <optional>
new THREE.TextureLoader()
RPM.requestPaintHUD boolean <optional>
true
RPM.currentObject MapObject <optional>
null
RPM.currentParameters Array.<SystemParameter> <optional>
null
RPM.currentMap SceneMap <optional>
null
RPM.currentReaction ReactionInterpreter <optional>
null
RPM.displayedPictures Array.<Picture2D> <optional>
[]
RPM.screenTone THREE.Vector4 <optional>
new THREE.Vector4(0, 0, 0, 1)
RPM.allowSaves boolean <optional>
true
RPM.allowMainMenu boolean <optional>
true
RPM.isInMainMenu boolean <optional>
false
RPM.BB_BOX THREE.Mesh <optional>
MapPortion.createBox()
RPM.BB_BOX_DETECTION THREE.Mesh <optional>
MapPortion.createBox()
RPM.BB_BOX_DEFAULT_DETECTION THREE.Mesh <optional>
MapPortion.createBox()
RPM.BB_ORIENTED_BOX THREE.Mesh <optional>
MapPortion.createOrientedBox()
RPM.OBJ_LOADER THREE.OBJLoader <optional>
new THREE.OBJLoader()
RPM.CUBE_TEXTURE_LOADER THREE.CubeTextureLoader <optional>
new THREE.CubeTextureLoader()
RPM.operators_compare function
RPM.operators_numbers function

Members

fileExists

Check if a file exists

openFile

Open an existing file

parseFileJSON

Open and parse an existing file

saveFile

Write a json file

createFont

Link the fontSize and the fontName to a string that can be used by the canvasHUD

positionCenterZ

Extract the z center from position

drawHUD

Draw HUD for the current stack

Methods

RPM.describe (obj)string static

Describe a javascript object
Name Type Description
obj Object The javascript object
Returns:
Type Description
string

RPM.show (text) static

Show alert dialog box
Name Type Description
text string text to display

RPM.getStringDate (total)string static

Return a string of the date by passing all the seconds
Name Type Description
total number Total number of seconds
Returns:
Type Description
string

RPM.formatNumber (num, size)string static

Return the string of a number and parse with 0 according to a given size
Name Type Description
num number Number
size number Max number to display
Returns:
Type Description
string

RPM.generateMapName (id)string static

Generate the map name according to the ID
Name Type Description
id number ID of the map
Returns:
Type Description
string

RPM.positionJSONToIndex (position)number static

Transform a json position to index position on X/Z axis
Name Type Description
position Array.<number> The json position
Returns:
Type Description
number

RPM.positionToIndex (position)number static

Transform a quare position to index position on X/Z axis
Name Type Description
position Array.<number> The json position
Returns:
Type Description
number

RPM.positionToVector3 (position)THREE.Vector3 static

Transform a json position to a THREE.Vector3
Name Type Description
position Array.<number> The json position
Returns:
Type Description
THREE.Vector3

RPM.positionToBorderVector3 (position)THREE.Vector3 static

Transform a json position to a THREE.Vector3
Name Type Description
position Array.<number> The json position
Returns:
Type Description
THREE.Vector3

RPM.positionTotalY (position)number static

Get the complete number of Y of a position
Name Type Description
position Array.<number> The json position
Returns:
Type Description
number

RPM.positionLayer (position) static

Extract the layer from position
Name Type Description
position Array.<number> The json position
Returns:
number

RPM.positionCenterX (position) static

Extract the x center from position
Name Type Description
position Array.<number> The json position
Returns:
number

RPM.positionAngleY (position) static

Extract the angle from position
Name Type Description
position Array.<number> The json position
Returns:
number

RPM.positionAngleX (position) static

Extract the angle from position
Name Type Description
position Array.<number> The json position
Returns:
number

RPM.positionAngleZ (position) static

Extract the angle from position
Name Type Description
position Array.<number> The json position
Returns:
number

RPM.getScreenX (x)number static

Get the pixel position transformation according to screen size
Name Type Description
x number The position on screen
Returns:
Type Description
number

RPM.getScreenY (y)number static

Get the pixel position transformation according to screen size
Name Type Description
y number The position on screen
Returns:
Type Description
number

RPM.getScreenXY (xy)number static

Get the pixel position transformation according to screen size
Name Type Description
xy number The position on screen
Returns:
Type Description
number

RPM.getScreenMinXY (xy)number static

Get the min pixel position transformation according to screen size
Name Type Description
xy number The position on screen
Returns:
Type Description
number

RPM.getDoubleScreenX (x)number static

Get the pixel position transformation according to screen size, but without rounding it
Name Type Description
x number The position on screen
Returns:
Type Description
number

RPM.getDoubleScreenY (y)number static

Get the pixel position transformation according to screen size, but without rounding it
Name Type Description
y number The position on screen
Returns:
Type Description
number

RPM.getSquare (x)number static

Get the position according to the square size
Name Type Description
x number The position
Returns:
Type Description
number

RPM.countFields (obj)number static

Get the number of fields of an object
Name Type Description
obj Object The object to count fields
Returns:
Type Description
number

RPM.isEmpty (array)boolean static

Check if an array is empty
Name Type Description
array Array.<any> The array to test
Returns:
Type Description
boolean

RPM.cos (w)number static

Get the cos
Name Type Description
w number The value
Returns:
Type Description
number

RPM.sin (w)number static

Get the sin
Name Type Description
w number The value
Returns:
Type Description
number

RPM.getPortion (position)Array.<number> static

Get portion according to a position
Name Type Description
position THREE.Vector3 The position
Returns:
Type Description
Array.<number>

RPM.getPortionArray (p)Array.<number> static

Get portion according to array position
Name Type Description
p Array.<number> The array position
Returns:
Type Description
Array.<number>

RPM.getPosition (position)Array.<number> static

Get an array position according to position
Name Type Description
position THREE.Vector3 The position
Returns:
Type Description
Array.<number>

RPM.arePortionEquals (portion1, portion2)boolean static

Check if two portions are equals
Name Type Description
portion1 Array.<number>
portion2 Array.<number>
Returns:
Type Description
boolean

RPM.showError (e) static

Show an error object
Name Type Description
e Error The error message

RPM.showErrorMessage (msg) static

Show an error message
Name Type Description
msg string The error message

RPM.mod (x, m)number static

Give a modulo without negative value
Name Type Description
x number
m number
Returns:
Type Description
number

RPM.getMaxID (list)number static

Get the list max ID
Name Type Description
list Array.<number> A list containing only IDs
Returns:
Type Description
number

RPM.fillNullList (size)Array.<any> static

Create a new array list initialed with null everywhere
Name Type Description
size number The list size
Returns:
Type Description
Array.<any>

RPM.random (min, max)number static

Create a random number between min and max
Name Type Description
min number
max number
Returns:
Type Description
number

RPM.loadTexture (path)THREE.ShaderMaterial asyncstatic

Load a texture
Name Type Description
path string The path of the texture
Returns:
Type Description
THREE.ShaderMaterial

RPM.loadTextureEmpty ()THREE.MeshBasicMaterial static

Load a texture empty
Returns:
Type Description
THREE.MeshBasicMaterial

RPM.createMaterial ()THREE.ShaderMaterial static

Create a material from texture.
Returns:
Type Description
THREE.ShaderMaterial

RPM.updateBackgroundColor (color) static

Update the background color
Name Type Description
color SystemColor

RPM.toScreenPosition (vector, camera)THREE.Vector2 static

Convert 3D vector to a 2D point on screen
Name Type Description
vector THREE.Vector3 The 3D vector
camera THREE.Camera The three.js camera
Returns:
Type Description
THREE.Vector2

RPM.variance (value, variance)number static

Get random value according to value and variance
Name Type Description
value number
variance number
Returns:
Type Description
number

RPM.evaluateFormula (formula, user, target, damage)any static

Eval a formula
Name Type Description
formula string The formula
user GamePlayer The user
target GamePlayer The target
damage number Damage value
Returns:
Type Description
any

RPM.evaluateScript (script)any static

Eval a script
Name Type Description
script string The script
Returns:
Type Description
any

RPM.formulaContainsUser (formula)boolean static

Check if formula contains user string
Name Type Description
formula string The formula
Returns:
Type Description
boolean

RPM.formulaContainsTarget (formula)boolean static

Check if formula contains target string
Name Type Description
formula string The formula
Returns:
Type Description
boolean

RPM.defaultValue (value, defaultValue)any static

Return default value if undefined, else the value
Name Type Description
value any The value
defaultValue any The default value
Returns:
Type Description
any

RPM.isUndefined (value)boolean static

Check if the value is undefined
Name Type Description
value any The value
Returns:
Type Description
boolean

RPM.isNumber (value)boolean static

Check if the value is a number
Name Type Description
value any The value
Returns:
Type Description
boolean

RPM.isString (value)boolean static

Check if the value is a string
Name Type Description
value any The value
Returns:
Type Description
boolean

RPM.numToBool (num)boolean static

Convert a number to boolean
Name Type Description
num number The number
Returns:
Type Description
boolean

RPM.boolToNum (b)number static

Convert a boolean to number
Name Type Description
b boolean The boolean
Returns:
Type Description
number

RPM.numToString (n)string static

Convert number to string
Name Type Description
n number The number
Returns:
Type Description
string

RPM.indexOfProp (array, attr, value)number static

Get the index of an object in a array containing a property with a specific value
Name Type Description
array Array.<Object> The array to check
attr string The attribute of the object to check
value any The value to check on the object attribute
Returns:
Type Description
number

RPM.readJSONSystemList (jsonList, func, isConstructor)Array.<any> static

Read a json list and create a system list sorted by ID
Name Type Default Description
jsonList Array.<Object> The json list to read
func function The function to apply
isConstructor boolean true optional Indicate if the function is a constructor class
Returns:
Type Description
Array.<any>

RPM.readJSONSystemListByIndex (jsonList, func, isConstructor)Array.<any> static

Read a json list and create a system list sorted by index
Name Type Default Description
jsonList Array.<Object> The json list to read
func function The function to apply
isConstructor boolean true optional Indicate if the function is a constructor class
Returns:
Type Description
Array.<any>

RPM.readJSONSystemListByIDIndex (jsonList, listIDs, listIndexes, func, isConstructor)number static

Read a json list and create a system list by ID and another list by index (containing IDs), and return the max possible ID
Name Type Default Description
jsonList Array.<Object> The json list to
listIDs Array.<any> The system list by ID
listIndexes Array.<number> The IDs list by index
func function The function to apply
isConstructor boolean true optional Indicate if the function is a constructor class
Returns:
Type Description
number

RPM.readJSONSystemListHash (jsonList, func, isConstructor)Array.<any> static

Read a json list and create a hash list
Name Type Default Description
jsonList Array.<Object> The json list to read
func function The function to apply
isConstructor boolean true optional Indicate if the function is a constructor class
Returns:
Type Description
Array.<any>

RPM.tryCatch (func)any asyncstatic

Try catch for async functions
Name Type Description
func function The async function to apply
Returns:
Type Description
any

RPM.initialize () static

Initialize the game stack and datas

RPM.load () asyncstatic

Load the game stack and datas

RPM.clearHUD () static

Clear the HUD canvas

RPM.initializeGL () static

Initialize the openGL stuff

RPM.resizeGL () static

Set the camera aspect while resizing the window

RPM.update () static

Update the current stack

RPM.onKeyPressed (key) static

First key press handle for the current stack
Name Type Description
key number The key ID pressed

RPM.onKeyReleased (key) static

First key release handle for the current stack
Name Type Description
key number The key ID released

RPM.onKeyPressedRepeat (key)boolean static

Key pressed repeat handle for the current stack
Name Type Description
key number The key ID pressed
Returns:
Type Description
boolean false if the other keys are blocked after it

RPM.onKeyPressedAndRepeat (key)boolean static

Key pressed repeat handle for the current stack, but with a small wait after the first pressure (generally used for menus)
Name Type Description
key number The key ID pressed
Returns:
Type Description
boolean false if the other keys are blocked after it

RPM.draw3D () static

Draw the 3D for the current stack

RPM.loop () static

Main loop of the game