-
Notifications
You must be signed in to change notification settings - Fork 0
Docs
CalSch edited this page Apr 27, 2021
·
9 revisions
Docs for HeliumJS v0.1
Initializes a Game
object.
Parameters:
-
canvas
: (Canvas) The canvas for the game to draw on -
frameRate
: (Number) The rate of the game loop (Optional, default is60
)
Properties:
-
canvas
: (Canvas) The canvas to draw on -
screenWidth
: (Number)The canvas' width -
screenHeight
: (Number) The canvas' height -
frame
: (Number) The current frame, increments every game loop -
bgColor
: (String) The background color of the game screen (Default: #ffffff) -
running
: (Bool) If the game is running -
deltaTime
: (Number) The number of milliseconds since the last frame -
sprites
: (List) The sprites in the game, (UseaddSprite
to add a sprite instead of manually adding one) -
pressedKeys
: (Dict) The keys being pressed (Ex. If D is pressedgame.pressedKeys.d
returnstrue
) -
activeCamera
: (Camera) The active camera, (UsesetCamera
to set the active camera) -
mousePos
: (Object) The current position of the mouse (Ex. To get the mouse X position usegame.mousePos.x
)
Initializes a Canvas
object.
Parameters:
-
width
: (Number) Width of the canvas -
height
: (Number) Height of the canvas -
id
: (String) id of the canvas element
Properties:
-
width
: (Number) Width of the canvas -
height
: (Number) Height of the canvas -
id
: (String) id of the canvas element -
element
: (HTML Element) The HTML element of the canvas -
ctx
: (Context2d) The 2d context of the canvas
Initializes a Rectangle
object.
Parameters:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
w
: (Number) Width of the rectangle -
h
: (Number) Height of the rectangle -
color
: (String) Color of the rectangle
Properties:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
w
: (Number) Width of the rectangle -
h
: (Number) Height of the rectangle -
color
: (String) Color of the rectangle -
scripts
: (List) The list of scripts it has (Each script gets run on update)
Initializes a Circle
object.
Parameters:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
r
: (Number) Radius of the circle -
color
: (String) Color of the circle
Properties:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
r
: (Number) Radius of the circle -
color
: (String) Color of the circle -
scripts
: (List) The list of scripts it has (Each script gets run on update)
Initializes a Image
object.
Parameters:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
w
: (Number) Width of the image -
h
: (Number) Height of the image -
src
: (String) Link to the image
Properties:
-
x
: (Number) Center X position -
y
: (Number) Center Y position -
w
: (Number) Width of the image -
h
: (Number) Height of the image -
src
: (String) Link to the image -
elm
: (HTML Element) Element of the image (not added to the document) -
scripts
: (List) The list of scripts it has (Each script gets run on update)
Initializes a Text
object.
Parameters:
-
x
: (Number) Top-left X position -
y
: (Number) Top-left Y position -
text
: (String) The text to display -
style
: (String) The style of the text (eg.12px red
)
Properties:
-
x
: (Number) Top-left X position -
y
: (Number) Top-left Y position -
text
: (String) The text to display -
style
: (String) The style of the text (eg.12px red
) -
scripts
: (List) The list of scripts it has (Each script gets run on update)
A base plate for making custom sprites.
Parameters:
-
update
: (Function) Update function (Gets called every frame update) -
draw
: (Function) Draw function (Gets called after every frame update)
Properties:
-
update
: (Function) Update function (Gets called every frame update) -
draw
: (Function) Draw function (Gets called after every frame update) -
scripts
: (List) The list of scripts it has
A camera for the game
Parameters:
-
x
: (Number) Top-left X position -
y
: (Number) Top-left Y position
Properties:
-
x
: (Number) Top-left X position -
y
: (Number) Top-left Y position -
scripts
: (List) The list of scripts it has (Unused)