This is the full documentation for every class used in the Budgie game engine. Hidden fields are not shown here, as they should not be accessed directly or it may cause unintended behavior. Documentation is split up by classes, where each class has multiple fields and methods.
Here are shortcuts to each of the classes:
This class represents that entire game engine. It is automatically instantiated, so you should never have to call the constructor. You can access this class with the budgie variable.
This is an instance of StorageManager and allows you to save or load save data for your game
This is an instance of AssetsManager and allows you to access your loaded game assets
This is an instance of KeysManager and helps with key event processing
This is an invisible Sprite that represents the player's mouse pointer
This function gets called by Budgie when all the assets are done loading. It is a hook that you'll have to implement yourself. You can do this like so:
This function gets called whenever the player clicks with the mouse. It is a hook that you'll have to implement yourself. You can do this like so:
This function gets called whenever the player presses, holds or releases a key on the keyboard. It is a hook that you'll have to implement yourself. You can do this like so:
This function gets called once every frame. It is a hook that you'll have to implement yourself. You can do this like so:
This function prints an error message to the browser console and halts the game loop. It is called at several points in the engine to catch potential errors made by game developers. You can also use it for debugging. This function takes the following parameters:
This function returns the intended canvas width for your game
This function returns the intended canvas height for your game
This function adds a new sprite object onto the view. It takes in the following parameters:
This function adds a new sprite object onto the view. It takes in the following parameters:
This class represents a basic game object within the engine. You can instantiate a new Sprite by calling new Sprite().
Initializes a new Sprite instance
A list of this sprite's child sprites
This sprite's parent sprite. Will be null if this sprite has no parent.
Returns true if this sprite overlaps with the sprite given as an argument. Overlap is calculated by bounding rectangles. This function takes the following arguments:
Extends the area of this sprite's bounding rectangle. This function takes the following arguments:
Returns this sprite's bounding rectangle in absolute coordinates. Returns an object with x, y, width, and height fields.
This hook is called every time the sprite is supposed to redraw itself onto the canvas. You can implement it like so:
Sets the color to be used for draw functions. Takes the following arguments:
Sets the draw style, whether that be fill or stroke. Takes the following arguments:
Sets the line width of your draw functions. Takes the following arguments:
Renders an image as part of this sprite. Takes the following arguments:
Renders a rectangle as part of this sprite. Takes the following arguments:
Renders an oval as part of this sprite. Takes the following arguments:
Sets the font to be used when rendering text. Uses the following arguments:
Renders text on the canvas as part of this sprite. This function takes the following arguments:
This function is called every frame. You can implement it like so:
This function is called whenever this sprite is clicked on. You can implement it like so:
Adds a child sprite to this sprite. Takes the following arguments:
Removes a child sprite from this sprite. Takes the following arguments:
Tells this sprite's parent to draw this sprite behind its siblings
Tells this sprite's parent to draw this sprite in front of its siblings
Tells this sprite's parent to draw this sprite behind sprite. Takes the following arguments:
Tells this sprite's parent to draw this sprite in front of sprite. Takes the following arguments:
Returns an object with x and y fields representing this sprite's offset from its parent
Increments this sprite's offset from its parent. Takes the following arguments:
Sets this sprite's offset from its parent. Takes the following arguments:
Draws a line on this sprite. Takes the following arguments:
Draws a polygon on this sprite. This function take two arguments (x and y) for every point in your desired shape. You must provide at least three points (six arguments) or this function will throw an error. Takes the following arguments:
...
Returns the HTML5 2D canvas context object associated with this sprite. You can extend Budgie's capabilities by accessing the underlying HTML5 context directly.
This class is used by the engine to load and control access to assets. You can access it via budgie.assets.
This function returns a value between 0 and 1 representing the percentage of assets that have been loaded. You can use this function to implement loading screens, for example.
This function gives you a handle to any loaded asset you'd like. It takes the following parameters:
This class is used by the engine to load and save game data. It allow you to pull saved state from the browser, edit it, and later write it back for storage. You can access it via budgie.storage.
This function gets one piece of data from saved state. It takes the following parameters:
This function puts one piece of data into saved state. It takes the following parameters:
This function removes one piece of data from saved state. It takes the following parameters:
This function clears your saved state from the browser storage
This function writes your saved state to the browser storage
This function reads your saved state from the browser storage
This class is used by the engine to handle key events. You can access it via budgie.keys.
Represents the action where a key was pressed
Represents the action where a key is being held down
Represents the action where a key was released
Represents the backspace key
Represents the tab key
Represents the enter key
Represents the shift key
Represents the ctrl key
Represents the alt key
Represents the caps_lock key
Represents the esc key
Represents the space key
Represents the page_up key
Represents the page_down key
Represents the end key
Represents the home key
Represents the left key
Represents the up key
Represents the right key
Represents the down key
Represents the insert key
Represents the delete key
Represents the 0 key
Represents the 1 key
Represents the 2 key
Represents the 3 key
Represents the 4 key
Represents the 5 key
Represents the 6 key
Represents the 7 key
Represents the 8 key
Represents the 9 key
Represents the a key
Represents the b key
Represents the c key
Represents the d key
Represents the e key
Represents the f key
Represents the g key
Represents the h key
Represents the i key
Represents the j key
Represents the k key
Represents the l key
Represents the m key
Represents the n key
Represents the o key
Represents the p key
Represents the q key
Represents the r key
Represents the s key
Represents the t key
Represents the u key
Represents the v key
Represents the w key
Represents the x key
Represents the y key
Represents the z key
Represents the num_0 key
Represents the num_1 key
Represents the num_2 key
Represents the num_3 key
Represents the num_4 key
Represents the num_5 key
Represents the num_6 key
Represents the num_7 key
Represents the num_8 key
Represents the num_9 key
Represents the mult key
Represents the add key
Represents the sub key
Represents the decimal key
Represents the div key
Represents the f1 key
Represents the f2 key
Represents the f3 key
Represents the f4 key
Represents the f5 key
Represents the f6 key
Represents the f7 key
Represents the f8 key
Represents the f9 key
Represents the f10 key
Represents the f11 key
Represents the f12 key
Represents the num_lock key
Represents the scroll_lock key
Represents the semicolon key
Represents the equal key
Represents the comma key
Represents the dash key
Represents the period key
Represents the forward_slash key
Represents the open_bracket key
Represents the back_slash key
Represents the close_bracket key
Represents the single_quote key