-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.txt
executable file
·31 lines (25 loc) · 1.43 KB
/
docs.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This is the Documentation for the HTML5 Javascript game library 'pbrane.js.'
To create a game the library needs six things:
The World:
this is some datum that represents all data in the game. Every game function will take in this world, and return it with modifications (with the exception of drawing).
The CanvasId:
The unique id for a DOM canvas object. The game will render to this canvas.
Drawer:
World CanvasContext -> [void]
This function will be called by P-Brain to draw the current world. Before each call to this function the canvas is reset to be completely white.
the CanvasContext is
Ticker:
World -> World
This function is called every millisecond(or as fast as your browser will allow). The result will become the new world, which is then rendered.
KeyHandler:
World, KeyEventString, KeyEvent -> World
This function is called for every key event.
The KeyEventString is the string that represents the DOM event (ie "keydown", "keyup")
The KeyEvent is the actual event
MouseHandler:
World, MouseventString, MouseEvent -> World
This function is called for every key event.
The MouseventString is the string that represents the DOM event (ie "click", "mousedown")
The MouseEvent is the actual event
To launch the game include the p-brain.js file, write you functions, then in your canvas tag add:
onload="launch(<world>,<canvasid>,<drawer>,<ticker>,<keyhandler>,<mousehandler>);"