-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameScene.js
More file actions
154 lines (140 loc) · 2.86 KB
/
GameScene.js
File metadata and controls
154 lines (140 loc) · 2.86 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* Base class for any game "activity" or "screen" that gets updated and drawn
*/
class GameScene
{
/**
* References the active player
*/
player = null;
/**
* Length of the long side of the game screen
*/
longSide =0;
/**
* Length of the short side of the game screen
*/
shortSide = 0;
/**
* Indicates whether the scene is paused.
*/
paused = false;
visible = true;
/**
* Contains the scene's objects.
*/
gameObjects = [];
/**
* Adds an object to the scene
* @param {GameObject} obj
*/
addObject(obj)
{
this.gameObjects.push(obj);
//console.log(this.gameObjects.length);
obj.scene = this;
//console.log(obj,this);
}
/**
* Initialises the scene.
*/
constructor()
{
// this currently defaults to portrait orientation
// #TODO: make this actually use and adapt to landscape
// sideways scrolling?
this.shortSide= window.innerWidth;
this.longSide=window.innerHeight;
}
/**
* Updates the scene.
* @param {number} dT - elapsed time
*/
update(dT)
{
}
/**
* Draws the scene.
* @param {CanvasRenderingContext2D} ctx
*/
draw(ctx)
{
}
/**
* Handles primary pointer movement.
* @param {PointerEvent} e - event from DOM
*/
handlePrimaryPointerMove(e)
{
}
/**
* Handles secondary pointer movement.
* @param {PointerEvent} e - event from DOM
*/
handleSecondaryPointerMove(e)
{
}
/**
* Handles primary pointer release.
* @param {PointerEvent} e - event from DOM
*/
handlePrimaryPointerUp(e)
{
}
/**
* Handles secondary pointer release.
* @param {PointerEvent} e - event from DOM
*/
handleSecondaryPointerUp(e)
{
}
/**
* Handles primary pointer press.
* @param {PointerEvent} e - event from DOM
*/
handlePrimaryPointerDown(e)
{
}
/**
* Handles secondary pointer press.
* @param {PointerEvent} e - event from DOM
*/
handleSecondaryPointerDown(e)
{
}
/**
* Handles primary pointer click.
* @param {PointerEvent} e - event from DOM
*/
handlePrimaryPointerClick(e)
{
}
/**
* Handles secondary pointer click.
* @param {PointerEvent} e - event from DOM
*/
handleSecondaryPointerClick(e)
{
}
/**
* Handles keydown event.
* @param {PointerEvent} e - event from DOM
*/
handleKeyDown(e)
{
}
/**
* Handles keyup event.
* @param {PointerEvent} e - event from DOM
*/
handleKeyUp(e)
{
}
/**
* Handles keypress event.
* @param {PointerEvent} e - event from DOM
*/
handleKeyPress(e)
{
}
}