BlueGit

timfa raytracer

automagically scale the gun

timfa Tim Falken · pushed by timfa

Authored 2020-10-17 · 6 years ago

Hash
1f3b58eda0854e7d8a10848a65fd283b2b95ec48
Parent
e9b2b374
2 files changed +7 −3
js/Canvas.js +2 −2
@@ -45,8 +45,8 @@ var Canvas =
45 45 this.context.fillRect(xStart, yStart, xEnd, yEnd);
46 46 },
47 47
48 drawImage(img, x, y)
48 drawImage(img, x, y, w, h)
49 49 {
50 this.context.drawImage(img, x, y);
50 this.context.drawImage(img, x, y, w, h);
51 51 }
52 52 }
@@ -45,8 +45,8 @@ var Canvas =
45 this.context.fillRect(xStart, yStart, xEnd, yEnd);
45 this.context.fillRect(xStart, yStart, xEnd, yEnd);
46 },
46 },
47
47
48 drawImage(img, x, y)
48 drawImage(img, x, y, w, h)
49 {
49 {
50 this.context.drawImage(img, x, y);
50 this.context.drawImage(img, x, y, w, h);
51 }
51 }
52}
52}
js/Player.js +5 −1
@@ -184,7 +184,11 @@ var Player =
184 184 break;
185 185 }
186 186
187 Canvas.drawImage(gunImg.g_image, GameWindow.width * this.gunX, GameWindow.height * this.gunY);
187 var p = (GameWindow.height / 1080)
188 var w = p * gunImg.g_image.width;
189 var h = p * gunImg.g_image.height;
190
191 Canvas.drawImage(gunImg.g_image, GameWindow.width * this.gunX, GameWindow.height * this.gunY, w, h);
188 192 }
189 193 }
190 194
@@ -184,7 +184,11 @@ var Player =
184 break;
184 break;
185 }
185 }
186
186
187 Canvas.drawImage(gunImg.g_image, GameWindow.width * this.gunX, GameWindow.height * this.gunY);
187 var p = (GameWindow.height / 1080)
188 var w = p * gunImg.g_image.width;
189 var h = p * gunImg.g_image.height;
190
191 Canvas.drawImage(gunImg.g_image, GameWindow.width * this.gunX, GameWindow.height * this.gunY, w, h);
188 }
192 }
189}
193}
190
194