• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revisión755aa619f6519a1a4db4174569a45284f7dedf93 (tree)
Tiempo2016-12-16 21:38:41
AutorYu Hayashi <yu011301@teca...>
CommiterYu Hayashi

Log Message

600x600

Cambiar Resumen

Diferencia incremental

--- a/WebContent/Asteroid.html
+++ b/WebContent/Asteroid.html
@@ -30,8 +30,8 @@
3030 }
3131
3232 function Ship() {
33- this.cx = 400;
34- this.cy = 400;
33+ this.cx = 300;
34+ this.cy = 300;
3535 this.w = 90;
3636 this.h = 60;
3737 this.dx = 0;
@@ -52,13 +52,18 @@
5252 getX: function() { return (this.cx - this.w / 2); },
5353 getY: function() { return (this.cy - this.h / 2); },
5454 isHit: function(o) {
55- return !(((o.getX() + o.w) < this.getX()) || ((this.getX() + this.w) < o.getX()) || ((o.getY() + o.h) < this.getY()) || ((this.getY() + this.h) < o.getY()));
55+ return !(((o.getX() + o.w) < this.getX())
56+ || ((this.getX() + this.w) < o.getX())
57+ || ((o.getY() + o.h) < this.getY())
58+ || ((this.getY() + this.h) < o.getY()));
5659 },
5760 update: function() {
58- this.cx = (this.cx + this.dx + 800) % 800;
59- this.cy = (this.cy + this.dy + 800) % 800;
61+ this.cx = (this.cx + this.dx + 600) % 600;
62+ this.cy = (this.cy + this.dy + 600) % 600;
6063 }
6164 }
65+
66+ function rand(r) { return Math.floor(Math.random() *r) }
6267
6368 function init() {
6469 ctx = document.getElementById('canvas').getContext('2d');
@@ -103,7 +108,7 @@
103108
104109 // 岩の初期化
105110 for (var i=0; i < level; i++) {
106- var x = rand(800), y = rand(800);
111+ var x = rand(600), y = rand(600);
107112 while(true) {
108113 var r = new Rock(x, y, 64);
109114 if (!r.isHit(ship)) {
@@ -138,8 +143,8 @@
138143 ship.dy = Math.sin(ship.rotate) * ship.poower;
139144 ship.update();
140145
141- bgX = (bgX + ship.dx / 2 + 1600) % 800;
142- bgY = (bgY + ship.dy / 2 + 1600) % 800;
146+ bgX = (bgX + ship.dx / 2 + 1200) % 600;
147+ bgY = (bgY + ship.dy / 2 + 1200) % 600;
143148
144149 // 弾丸の位置を更新
145150 var fire = false;
@@ -204,7 +209,8 @@
204209
205210 function draw() {
206211 // 背景を描画
207- ctx.drawImage(bg, bgX, bgY, 400, 400, 0, 0, 800, 800);
212+ var bg = document.getElementById("bg");
213+ ctx.drawImage(bg, bgX, bgY, 300, 300, 0, 0, 600, 600);
208214
209215 // 弾丸の描画
210216 ctx.fillStyle = 'rgb(0,255,255)';
@@ -241,9 +247,9 @@
241247 }
242248 </script>
243249 </head>
244- <body onload="iniit()">
250+ <body onload="init()">
245251 <div>
246- <canvas id="canvas" width="800" height="800"></canvas>
252+ <canvas id="canvas" width="600" height="600"></canvas>
247253 </div>
248254 <img id="ship" src="ship90x60.png" style="display:none" />
249255 <img id="bg" src="bg.png" style="display:none" />