-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverview.txt
executable file
·66 lines (41 loc) · 1.9 KB
/
overview.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
This is the overview file. it lays out the flow for pbrane.js.
to launch the use provides up to 4 functions, a CanvasId, and a World:
draw : World Scene -> Scene
This function controls drawing to the given canvas, pulled from the canvas id
for now the context is only 2d
tick : World -> datum
recreates the datum, which will then be drawn(?)
key : World KeyEventString KeyEvent -> World
recreates the World on key event
mouse : World MouseEventString MouseEvent -> World
recreates the World based on an key event code and the coord that it happend on
LOW LEVEL:
data:
a PBrain is an class
state is the current World
id is the canvasId
eventQ is an array as queue KeyEvent or of MouseEvents
tick is the tick function
onKey is the key function
onMouse is the mouse function
draw is the draw function
inFocus is a boolean. is the canvas in focus?
A MouseEvent is a class with a type, id, x, y
A Key Event is a class with a type and an id
A Scene is a function that takes in a context and draws to it. This representation is meant to not be seen on the client side.
A PImage is a internal rep of an image. it is a function that takes in an X,Y, and Scene and return a new scene with that image draw to the scene
A Color is a string of a hex code ie '#000000'
launch : World, CanvasId, draw, tick = null, key = null, mouse = null ->
launches PBrain
addKeyEventListener : PBrain ->
lauches a key event listener that adds key event to that PBrains queue
addMouseEventListener : PBrain ->
lauches a mouse event listener that adds key event to that PBrains queue
runThrough : PBrain ->
Deals with a tick, the possibilty of keyevents and mouse events, and drawing
tick : PBrain ->
ticks that brain
draw : PBrain ->
draws the brane
handleEvents : PBrain ->
handles all events in that brain, clears the que