DisplayMode
@@ -37,10 +37,10 @@ function image(url, subImgTotal, perRow)
37
37
if(dy < -Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))
38
38
shouldDraw = false;
39
39
40
if(dx > scene.size.x + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))
40
if(dx > scene.real_size.x + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))
41
41
shouldDraw = false;
42
42
43
if(dy > scene.size.y + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))
43
if(dy > scene.real_size.y + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))
44
44
shouldDraw = false;
45
45
46
46
if(shouldDraw)
@@ -37,10 +37,10 @@ function image(url, subImgTotal, perRow)37
if(dy < -Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))37
if(dy < -Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))38
shouldDraw = false;38
shouldDraw = false;39
39
40
if(dx > scene.size.x + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))40
if(dx > scene.real_size.x + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))41
shouldDraw = false;41
shouldDraw = false;42
42
43
if(dy > scene.size.y + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))43
if(dy > scene.real_size.y + Math.sqrt(Math.pow(dw, 2) + Math.pow(dh, 2)))44
shouldDraw = false;44
shouldDraw = false;45
45
46
if(shouldDraw)46
if(shouldDraw)@@ -5,9 +5,14 @@ class Scene
5
5
activeObjects = [];
6
6
position = null;
7
7
size = null;
8
real_position = null;
9
real_size = null;
8
10
cameraPosition = null;
9
11
parentScene = null;
10
fullscreen = false;
12
13
static DisplayModes = {absolute: 0, relativeToParent: 1}
14
15
displayMode = Scene.DisplayModes.absolute;
11
16
12
17
cv_canvas = null;
13
18
cv_context = null;
@@ -15,21 +20,17 @@ class Scene
15
20
16
21
game = null;
17
22
18
constructor(x, y, width, height, fullscreen = false)
23
constructor(x, y, width, height, displayMode = 0)
19
24
{
20
25
Scene.idCount++;
21
26
this.id = 'canvas_' + Scene.idCount;
22
27
23
28
this.position = new vector(x, y);
24
29
this.size = new vector(width, height);
30
this.real_position = new vector(x, y);
31
this.real_size = new vector(width, height);
25
32
this.cameraPosition = new vector(0, 0)
26
this.fullscreen = fullscreen;
27
28
if(this.fullscreen)
29
{
30
this.size.x = window.innerWidth;
31
this.size.y = window.innerHeight;
32
}
33
this.displayMode = displayMode;
33
34
34
35
let body = document.body;
35
36
@@ -106,19 +107,37 @@ class Scene
106
107
if(this.destroyed)
107
108
return;
108
109
109
if(this.fullscreen)
110
if(this.displayMode == Scene.DisplayModes.relativeToParent)
110
111
{
111
this.size.x = window.innerWidth;
112
this.size.y = window.innerHeight;
112
if(this.parentScene)
113
{
114
115
}
116
else
117
{
118
this.real_position.x = window.innerWidth * this.position.x;
119
this.real_position.y = window.innerHeight * this.position.y;
120
121
this.real_size.x = window.innerWidth * this.size.x;
122
this.real_size.y = window.innerHeight * this.size.y;
123
}
113
124
}
125
else if (this.displayMode == Scene.DisplayModes.absolute)
126
{
127
this.real_position.x = this.position.x;
128
this.real_position.y = this.position.y;
129
130
this.real_size.x = this.size.x;
131
this.real_size.y = this.size.y;
132
}
114
133
115
this.canvas.width = this.size.x;
116
this.canvas.height = this.size.y;
134
this.canvas.width = this.real_size.x;
135
this.canvas.height = this.real_size.y;
117
136
118
this.canvas.style = 'position: absolute; left: ' + this.position.x + 'px; top: ' + this.position.y + 'px;'; //todo: only call when changed?
137
this.canvas.style = 'position: absolute; left: ' + this.real_position.x + 'px; top: ' + this.real_position.y + 'px;'; //todo: only call when changed?
119
138
120
139
this.context.fillStyle = "rgb(" + this.backgroundColor.r + "," + this.backgroundColor.g + "," + this.backgroundColor.b + ")"; // sets the color to fill in the rectangle with
121
this.context.fillRect(0, 0, this.size.x, this.size.y);
140
this.context.fillRect(0, 0, this.real_size.x, this.real_size.y);
122
141
123
142
for(var i = 0; i < this.activeObjects.length; i++)
124
143
{
@@ -5,9 +5,14 @@ class Scene5
activeObjects = [];5
activeObjects = [];6
position = null;6
position = null;7
size = null;7
size = null;8
real_position = null;9
real_size = null;8
cameraPosition = null;10
cameraPosition = null;9
parentScene = null;11
parentScene = null;10
fullscreen = false;12
13
static DisplayModes = {absolute: 0, relativeToParent: 1}14
15
displayMode = Scene.DisplayModes.absolute;11
16
12
cv_canvas = null;17
cv_canvas = null;13
cv_context = null;18
cv_context = null;@@ -15,21 +20,17 @@ class Scene15
20
16
game = null;21
game = null;17
22
18
constructor(x, y, width, height, fullscreen = false)23
constructor(x, y, width, height, displayMode = 0)19
{24
{20
Scene.idCount++;25
Scene.idCount++;21
this.id = 'canvas_' + Scene.idCount;26
this.id = 'canvas_' + Scene.idCount;22
27
23
this.position = new vector(x, y);28
this.position = new vector(x, y);24
this.size = new vector(width, height);29
this.size = new vector(width, height);30
this.real_position = new vector(x, y);31
this.real_size = new vector(width, height);25
this.cameraPosition = new vector(0, 0)32
this.cameraPosition = new vector(0, 0)26
this.fullscreen = fullscreen;33
this.displayMode = displayMode;27
28
if(this.fullscreen)29
{30
this.size.x = window.innerWidth;31
this.size.y = window.innerHeight;32
}33
34
34
let body = document.body;35
let body = document.body;35
36
@@ -106,19 +107,37 @@ class Scene106
if(this.destroyed)107
if(this.destroyed)107
return; 108
return; 108
109
109
if(this.fullscreen)110
if(this.displayMode == Scene.DisplayModes.relativeToParent)110
{111
{111
this.size.x = window.innerWidth;112
if(this.parentScene)112
this.size.y = window.innerHeight;113
{114
115
}116
else117
{118
this.real_position.x = window.innerWidth * this.position.x;119
this.real_position.y = window.innerHeight * this.position.y;120
121
this.real_size.x = window.innerWidth * this.size.x;122
this.real_size.y = window.innerHeight * this.size.y;123
}113
}124
}125
else if (this.displayMode == Scene.DisplayModes.absolute)126
{127
this.real_position.x = this.position.x;128
this.real_position.y = this.position.y;129
130
this.real_size.x = this.size.x;131
this.real_size.y = this.size.y;132
}114
133
115
this.canvas.width = this.size.x;134
this.canvas.width = this.real_size.x;116
this.canvas.height = this.size.y;135
this.canvas.height = this.real_size.y;117
136
118
this.canvas.style = 'position: absolute; left: ' + this.position.x + 'px; top: ' + this.position.y + 'px;'; //todo: only call when changed?137
this.canvas.style = 'position: absolute; left: ' + this.real_position.x + 'px; top: ' + this.real_position.y + 'px;'; //todo: only call when changed?119
138
120
this.context.fillStyle = "rgb(" + this.backgroundColor.r + "," + this.backgroundColor.g + "," + this.backgroundColor.b + ")"; // sets the color to fill in the rectangle with139
this.context.fillStyle = "rgb(" + this.backgroundColor.r + "," + this.backgroundColor.g + "," + this.backgroundColor.b + ")"; // sets the color to fill in the rectangle with121
this.context.fillRect(0, 0, this.size.x, this.size.y);140
this.context.fillRect(0, 0, this.real_size.x, this.real_size.y);122
141
123
for(var i = 0; i < this.activeObjects.length; i++)142
for(var i = 0; i < this.activeObjects.length; i++)124
{143
{