BlueGit

timfa frameworkv3

better build script, scene position

timfa Tim · pushed by timfa

Authored 2022-10-15 · 4 years ago

Hash
595a59f86763ca05b2eedafa00b33ceece09976f
Parent
edc98a09
3 files changed +29 −1
.vscode/tasks.json added +17 −0
@@ -0,0 +1,17 @@
1 {
2 // See https://go.microsoft.com/fwlink/?LinkId=733558
3 // for the documentation about the tasks.json format
4 "version": "2.0.0",
5 "tasks": [
6 {
7 "label": "Build Framework",
8 "type": "shell",
9 "command": "sh ./framework/build.sh",
10 "problemMatcher": [],
11 "group": {
12 "kind": "build",
13 "isDefault": true
14 }
15 }
16 ]
17 }
@@ -0,0 +1,17 @@
1{
2 // See https://go.microsoft.com/fwlink/?LinkId=733558
3 // for the documentation about the tasks.json format
4 "version": "2.0.0",
5 "tasks": [
6 {
7 "label": "Build Framework",
8 "type": "shell",
9 "command": "sh ./framework/build.sh",
10 "problemMatcher": [],
11 "group": {
12 "kind": "build",
13 "isDefault": true
14 }
15 }
16 ]
17}
framework/build.sh added +9 −0
@@ -0,0 +1,9 @@
1 unlink ./js/framework.js
2 for i in ./framework/*.js;
3 do
4 printf "\n/*\n * Start File:\n * "$i"\n */ \n" >> ./js/framework.js;
5 printf "Building "$i"\n";
6 cat $i >> ./js/framework.js;
7 printf "\n/*\n * End File:\n * "$i"\n */ \n" >> ./js/framework.js;
8 done
9 printf "DONE"
@@ -0,0 +1,9 @@
1unlink ./js/framework.js
2for i in ./framework/*.js;
3do
4 printf "\n/*\n * Start File:\n * "$i"\n */ \n" >> ./js/framework.js;
5 printf "Building "$i"\n";
6 cat $i >> ./js/framework.js;
7 printf "\n/*\n * End File:\n * "$i"\n */ \n" >> ./js/framework.js;
8done
9printf "DONE"
framework/scene.js +3 −1
@@ -23,7 +23,7 @@ class Scene
23 23
24 24 let body = document.body;
25 25
26 body.insertAdjacentHTML('beforeend', '<canvas id="canvas_' + Scene.idCount + '" style="position: absolute; left: ' + x + 'px; top: ' + y + 'px; border: 1px solid black;" width="' + GameWindow.width + '" height="' + GameWindow.height + '"></canvas>');
26 body.insertAdjacentHTML('beforeend', '<canvas id="canvas_' + Scene.idCount + '" style="position: absolute; left: ' + x + 'px; top: ' + y + 'px;" width="' + GameWindow.width + '" height="' + GameWindow.height + '"></canvas>');
27 27
28 28 this.cv_canvas = document.getElementById('canvas_' + Scene.idCount);
29 29 this.cv_canvasContext = this.cv_canvas.getContext('2d');
@@ -70,6 +70,8 @@ class Scene
70 70 this.canvas.width = this.size.width;
71 71 this.canvas.height = this.size.height;
72 72
73 this.canvas.style = 'position: absolute; left: ' + this.position.x + 'px; top: ' + this.position.y + 'px;'; //todo: only call when changed?
74
73 75 this.canvasContext.fillStyle = "rgb(" + this.backgroundColor.r + "," + GameWindow.backgroundColor.g + "," + GameWindow.backgroundColor.b + ")"; // sets the color to fill in the rectangle with
74 76 this.canvasContext.fillRect(0, 0, this.size.width, this.size.height);
75 77
@@ -23,7 +23,7 @@ class Scene
23
23
24 let body = document.body;
24 let body = document.body;
25
25
26 body.insertAdjacentHTML('beforeend', '<canvas id="canvas_' + Scene.idCount + '" style="position: absolute; left: ' + x + 'px; top: ' + y + 'px; border: 1px solid black;" width="' + GameWindow.width + '" height="' + GameWindow.height + '"></canvas>');
26 body.insertAdjacentHTML('beforeend', '<canvas id="canvas_' + Scene.idCount + '" style="position: absolute; left: ' + x + 'px; top: ' + y + 'px;" width="' + GameWindow.width + '" height="' + GameWindow.height + '"></canvas>');
27
27
28 this.cv_canvas = document.getElementById('canvas_' + Scene.idCount);
28 this.cv_canvas = document.getElementById('canvas_' + Scene.idCount);
29 this.cv_canvasContext = this.cv_canvas.getContext('2d');
29 this.cv_canvasContext = this.cv_canvas.getContext('2d');
@@ -70,6 +70,8 @@ class Scene
70 this.canvas.width = this.size.width;
70 this.canvas.width = this.size.width;
71 this.canvas.height = this.size.height;
71 this.canvas.height = this.size.height;
72
72
73 this.canvas.style = 'position: absolute; left: ' + this.position.x + 'px; top: ' + this.position.y + 'px;'; //todo: only call when changed?
74
73 this.canvasContext.fillStyle = "rgb(" + this.backgroundColor.r + "," + GameWindow.backgroundColor.g + "," + GameWindow.backgroundColor.b + ")"; // sets the color to fill in the rectangle with
75 this.canvasContext.fillStyle = "rgb(" + this.backgroundColor.r + "," + GameWindow.backgroundColor.g + "," + GameWindow.backgroundColor.b + ")"; // sets the color to fill in the rectangle with
74 this.canvasContext.fillRect(0, 0, this.size.width, this.size.height);
76 this.canvasContext.fillRect(0, 0, this.size.width, this.size.height);
75
77