

Javascriptを使ったゲームの改造を進めていこうと思う。
それほど時間はかからなそうだ。
1.画面を大きくする=>敷き詰めるタイルの配列要素を増やす+画面設定の定数を増やす
2.アイテムを増やす=>これまでの応用でできる
3.左右にも進めるようにする=>上から下に画面が遷移するところで、キー入力の判別式を入れる

このゲームが職場のタブレットでプレイできるので、改造してメールで送ろうと思う。
改造するまえに、コードリーディング
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
いつの日か、ファミコンみたいなゲームをたくさん作ってみたい、
って思ってたけど、
なかなか、まとまった時間が取れない。
時間が取れても、結局、今みたいに中国語地獄になって、ゲームプログラミングどころじゃなくなる。




Javaでゲームを作った。
それが、2013年。
アクションゲームやシューティングゲームであれば経験があるから作れる。
RPGを作りたいんだが、
管理する値・フラグが多過ぎて、挫折したな・・・・
格闘ゲームも作りたかったけど、
結局、スパルタンXみたいなものになってしまった・・・・
だから、ゲームプログラミングって、とても奥が深いんだよ。
でも、勉強したら、しただけ、面白い物が作れる。
10年前の自分だったら、↓↓↓みたいなプログラムコードをみたら、オゲェってなってたんだけど、
成長したな、自分。
って、思う。
だから、勉強って面白い。
またプログラミング、集中して勉強したい。
(function() {
var config = {
cols: 10, 変更点
rows: 15, 変更点
cellWidth: 32,
cellHeight: 32,
bulletWidth: 4,
bulletHeight: 4,
bulletSpeed: 20,
bitbulletSpeed: 40,
reloadCount: 2,
itemSpeed: 1
};//1,2
//アイテムを追加↑変数と↓画像の宣言
var status = {};
var imageName = ["my", "bullet", "rock1", "rock2", "rock3", "item10", "wepon10", "bit"];//3
var images = {};
var cacheControl = function() {
var cache = window.applicationCache;
if(cache) {
cache.addEventListener("updateready", function() {
try {
cache.swapCache();
} catch(e) {}
window.location.reload();
});
if(window.navigator.onLine && cache.status != 0) {
try {
cache.update();
} catch(e) {}
}
}
};
var drawBackground = function() {
var bottom = config.height + config.cellHeight - status.currentTop;
if(bottom) {
status.ctx.drawImage(status.bgCtx.canvas, 0, status.currentTop, config.width, bottom, 0, 0, config.width, bottom);
}
if(config.height - bottom) {
status.ctx.drawImage(status.bgCtx.canvas, 0, bottom);
}
};
var draw = function() {
drawBackground();
if(status.state == "gaming") {//生きているなら主人公を描画
status.ctx.drawImage(images["my"], status.x - (config.cellWidth / 2) | 0, status.y - (config.cellHeight / 2) | 0);
if(status.bit == 1){
status.ctx.drawImage(images["bit"], status.x - 64 | 0, status.y | 0);
}
if(status.bit >= 2){
status.ctx.drawImage(images["bit"], status.x - 64 | 0, status.y | 0);
status.ctx.drawImage(images["bit"], status.x + 48 | 0, status.y | 0);
}
} else if(status.state == "dying") {
status.ctx.drawImage(images["bomb" + status.dying], status.x - (config.cellWidth / 2) | 0, status.y - (config.cellHeight / 2) | 0);
if(++status.dying > 10) {
status.state = "gameover";
}
}
// タイミングがおかしいかも
createItem();
createWepon();//ここ追加
};
var drawSpace = function(x, y) {//背景を描画
status.bgCtx.drawImage(images["space" + Math.floor(Math.random() * 10 + 1)], x * config.cellWidth, y * config.cellHeight);
};
var createBullet = function(dx, dy) {//弾丸を描画
return {x: status.x, y: status.y, dx: config.bulletSpeed * dx, dy: config.bulletSpeed * dy};
};
//ここ追加ビット
var createbit1Bullet = function(dx, dy) {//ビット1弾丸を描画
return {x: status.x-64, y: status.y, dx: config.bitbulletSpeed * dx, dy: config.bitbulletSpeed * dy};
};
var createbit2Bullet = function(dx, dy) {//ビット2弾丸を描画
return {x: status.x+48, y: status.y, dx: config.bitbulletSpeed * dx, dy: config.bitbulletSpeed * dy};
};
var createRock = function() {//敵の描画 ここを改造してアイテムにする
var level = (status.frameCount / 500) | 0;
var x = status.x + Math.random() * 100 - 50;
var fy = (level >= 4)? ((Math.random() * 2) | 0) * config.height: 0;
var y = status.y + Math.random() * 100 - 50;
var fx = Math.random() * config.width;
var r = Math.atan2(y - fy, x - fx);
var d = Math.random() * (5.5 + level) + 1.5;
d = (d < 10)? d: 10;
var hp = (Math.random() * Math.random() * ((5 + level / 4) | 0)) | 1;
return {x: fx, y: fy, dx: Math.cos(r) * d, dy: Math.sin(r) * d, hp: hp, score: hp * hp * 100, state: "rock" + ((Math.random() * 3 + 1) | 0)};
};
//アイテム描画の追加
var createItem = function(){
// アイテムが存在しない場合
if (!status.items.flg) {
return;
}
// iy += config.itemSpeed;
// images["item10"];
// status.items.x;
// config.cellWidth;
// status.items.y;
// config.cellHeight;
status.items.y += config.itemSpeed;
status.ctx.drawImage(images["item10"], status.items.x - (config.cellWidth / 2) | 0, status.items.y - (config.cellHeight / 2) | 0);
if(status.items.x < 0 || status.items.x > config.width || status.items.y < 0 || status.items.y > config.height) {
// delete status.items[key];
status.items.flg = false;
}
//return {x: status.x, y: status.y, ix: 0, iy: config.itemSpeed};
};
//ウエポン描画の追加
var createWepon = function(){
// アイテムが存在しない場合
if (!status.wepons.flg) {
return;
}
status.wepons.y += config.itemSpeed;
status.ctx.drawImage(images["wepon10"], status.wepons.x - (config.cellWidth / 2) | 0, status.wepons.y - (config.cellHeight / 2) | 0);
if(status.wepons.x < 0 || status.wepons.x > config.width || status.wepons.y < 0 || status.wepons.y > config.height) {
status.wepons.flg = false;
}
};
//4
var tick = function() {
setTimeout(tick, 1000 / 30);
if(status.state == "loading") {
return;
}
status.frameCount++;
status.currentTop--;
status.currentTop = status.currentTop || (config.height + config.cellHeight);
if(status.currentTop % config.cellHeight == 0) {
var line = status.currentTop / config.cellHeight - 1;
for(var x = 0; x < config.cols; x++) {
drawSpace(x, line);
}
}
draw();
//ここ弾のパターン追加可能、他レベルの処理を敵撃破の近くに書く、ゲームオーバーと最初の初期化をする
if(status.state == "gaming" && status.frameCount % config.reloadCount == 0) {
if(status.powerUp <= 2){
//status.bullets[status.frameCount + "a"] = createBullet(-1, -1);
status.bullets[status.frameCount + "b"] = createBullet(0, -1);
//status.bullets[status.frameCount + "c"] = createBullet(1, -1);
//status.bullets[status.frameCount + "d"] = createBullet(-1, 1);
//status.bullets[status.frameCount + "e"] = createBullet(1, 1);
}else if(status.powerUp >= 3 && status.powerUp <= 5){
status.bullets[status.frameCount + "a"] = createBullet(-1, -1);
//status.bullets[status.frameCount + "b"] = createBullet(0, -1);
status.bullets[status.frameCount + "c"] = createBullet(1, -1);
//status.bullets[status.frameCount + "d"] = createBullet(-1, 1);
//status.bullets[status.frameCount + "e"] = createBullet(1, 1);
}else if(status.powerUp >= 6 && status.powerUp <= 10){
status.bullets[status.frameCount + "a"] = createBullet(-1, -1);
//status.bullets[status.frameCount + "b"] = createBullet(0, -1);
status.bullets[status.frameCount + "c"] = createBullet(1, -1);
status.bullets[status.frameCount + "d"] = createBullet(-1, 1);
status.bullets[status.frameCount + "e"] = createBullet(1, 1);
}else if(status.powerUp >= 11 && status.powerUp <= 16){
status.bullets[status.frameCount + "a"] = createBullet(-1, -1);
status.bullets[status.frameCount + "b"] = createBullet(0, -1);
status.bullets[status.frameCount + "c"] = createBullet(1, -1);
//status.bullets[status.frameCount + "d"] = createBullet(-1, 1);
//status.bullets[status.frameCount + "e"] = createBullet(1, 1);
}else if(status.powerUp >= 17 && status.powerUp <= 20){
status.bullets[status.frameCount + "a"] = createBullet(-1, -1);
status.bullets[status.frameCount + "b"] = createBullet(0, -1);
status.bullets[status.frameCount + "c"] = createBullet(1, -1);
status.bullets[status.frameCount + "d"] = createBullet(-1, 1);
status.bullets[status.frameCount + "e"] = createBullet(1, 1);
}
if(status.bit == 1){
status.bullets[status.frameCount + "f"] = createbit1Bullet(0, -1);
}else if(status.bit >= 2){
status.bullets[status.frameCount + "f"] = createbit1Bullet(0, -1);
status.bullets[status.frameCount + "g"] = createbit2Bullet(0, -1);
}
}
if(status.rockCount < 5 + status.frameCount / 500) {
status.rocks[status.frameCount + "r"] = createRock();
status.rockCount++;
}
for(var key in status.bullets) {
var bullet = status.bullets[key];
bullet.x += bullet.dx;
bullet.y += bullet.dy;
if(bullet.x < 0 || bullet.x > config.width || bullet.y < 0 || bullet.y > config.height) {
delete status.bullets[key];
} else {
status.ctx.drawImage(images["bullet"], bullet.x - ((config.bulletWidth / 2) | 0), bullet.y - ((config.bulletHeight / 2) | 0));
for(var rkey in status.rocks) {
var rock = status.rocks[rkey];
if(Math.abs(bullet.x - rock.x) < config.cellWidth / 2 && Math.abs(bullet.y - rock.y) < config.cellHeight / 2) {
if(rock.hp) {
delete status.bullets[key];
// hpが0の場合
if(--rock.hp == 0) {
status.score += rock.score;
status.score = (status.score > 999999999)? 999999999: status.score;
status.scoreElement.innerHTML = "000000000".substring(0, 9 - (status.score + "").length) + status.score;
rock.dx = rock.dy = 0;
// 爆発画像名を付与する
rock.state = "bomb1";
} else {
rock.state = (rock.state + "w").substring(0, 6);
}
}
}
}
}
}
for(var key in status.rocks) {
var rock = status.rocks[key];
rock.x += rock.dx;
rock.y += rock.dy;
if(rock.x < 0 || rock.x > config.width || rock.y < 0 || rock.y > config.height) {
delete status.rocks[key];
status.rockCount--;
} else {
status.ctx.drawImage(images[rock.state], rock.x - ((config.cellWidth / 2) | 0), rock.y - ((config.cellHeight / 2) | 0));
// hpが0の場合
if(rock.hp == 0) {
var next = (+rock.state.substring(4, 6)) + 1;
// 爆発画像が描画(bomb1~bomb10まで)終了した場合
if(next > 10) {
// 敵を消す
delete status.rocks[key];
status.rockCount--;
// 既ににアイテムがフィールド上に存在する場合
if (status.items["flg"]) {
continue;
}
// 既ににウエポンがフィールド上に存在する場合
if (status.wepons["flg"]) {
continue;
}
// アイテムになる確率を乱数で調整します
var random = Math.random();
random = random * 100;
if (random > 50 && random <= 89 && !status.wepons["flg"] == true) {
status.items["flg"] = true;
//status.wepons["flg"] = false;
status.items["state"] = "item10";
// 敵の座標を引き継ぐ
status.items["x"] = rock.x;
status.items["y"] = rock.y;
}
if (random >90 && !status.items["flg"] == true){
status.wepons["flg"] = true;
//status.items["flg"] = false;
status.wepons["state"] = "wepon10";
// 敵の座標を引き継ぐ
status.wepons["x"] = rock.x;
status.wepons["y"] = rock.y;
}
} else {
rock.state = "bomb" + next;//ここ改造してアイテムにif文追加
}
} else {
rock.state = rock.state.substring(0, 5);
if(status.state == "gaming" && Math.abs(status.x - rock.x) < config.cellWidth * 0.7 && Math.abs(status.y - rock.y) < config.cellHeight * 0.7) {
status.state = "dying";
status.dying = 1;
}
if(status.state == "gaming" && Math.abs(status.x - status.items.x) < config.cellWidth * 0.7 && Math.abs(status.y - status.items.y) < config.cellHeight * 0.7 && status.items.flg == true) {
status.items.flg = false;
status.powerUp += 1;
if(status.powerUp > 20){
status.powerUp = 20;
}
}
if(status.state == "gaming" && Math.abs(status.x - status.wepons.x) < config.cellWidth * 0.7 && Math.abs(status.y - status.wepons.y) < config.cellHeight * 0.7 && status.wepons.flg == true) {
status.wepons.flg = false;
status.bit += 1;
if(status.bit > 2){
status.bit = 2;
}
}
}
}
}
};
var initialize = function() {
for(var x = 0; x < config.cols; x++) {
for(var y = 0; y < config.rows + 1; y++) {
drawSpace(x, y);
}
}
for(var i = 0; i < 3; i++) {
var canvas = document.createElement("canvas");
canvas.width = config.cellWidth;
canvas.height = config.cellHeight;
var ctx = canvas.getContext("2d");
ctx.drawImage(images["rock" + (i + 1)], 0, 0);
ctx.globalCompositeOperation = "source-in";
ctx.fillStyle = "#fff";
ctx.fillRect(0, 0, canvas.width, canvas.height);
images["rock" + (i + 1) + "w"] = canvas;
}
//ここ初期化の処理
status.currentTop = config.height + config.cellHeight;
status.x = (config.width / 2) | 0;
status.y = (config.height * 3 / 4) | 0;
status.frameCount = 0;
status.rockCount = 0;
status.score = 0;
status.powerUp = 0;//ここ追加
status.bullets = {};
status.rocks = {};
status.items = {};//5
status.wepons = {};
status.bit = 0;
status.scoreElement.innerHTML = "000000000";
status.state = "gaming";
setTimeout(function() { window.scrollTo(0, 0); }, 250);
};
window.onload = function() {
cacheControl();
config.width = config.cols * config.cellWidth;
config.height = config.rows * config.cellHeight;
status.scoreElement = document.getElementsByTagName("div")[0];
status.scoreElement.style.width = config.width + "px";
var canvas = document.getElementById("canvas");
canvas.width = config.width;
canvas.height = config.height;
status.ctx = canvas.getContext("2d");
var bgCanvas = document.createElement("canvas");
bgCanvas.width = config.width;
bgCanvas.height = config.height + config.cellHeight;
status.bgCtx = bgCanvas.getContext("2d");
for(var i = 0; i < 10; i++) {
imageName.push("space" + (i + 1));
imageName.push("bomb" + (i + 1));//アイテム追加
}
var checkLoad = function() {
status.loadedCount++;
if(status.loadedCount == imageName.length) {
initialize();
}
};
status.loadedCount = 0;
for(var i = 0; i < imageName.length; i++) {
var image = document.createElement("img");
image.onload = checkLoad;
images[imageName[i]] = image;
image.src = "img/" + imageName[i] + ".png";
}
status.state = "loading";
tick();
document.body.onmousedown = document.body.ontouchstart = function(e) {
e.preventDefault();
e = (e.touches && e.touches[0]) || e;
status.lastX = e.pageX;
status.lastY = e.pageY;
if(status.state == "gameover") {
initialize();
}
};
document.body.onmousemove = document.body.ontouchmove = function(e) {
e = (e.touches && e.touches[0]) || e;
if(status.state == "gaming" && status.lastX != null) {
status.x += (e.pageX - status.lastX) * 2.5;
status.y += (e.pageY - status.lastY) * 3;
status.x = ((status.x < 0)? 0: ((status.x > config.width)? config.width: status.x)) | 0;
status.y = ((status.y < 0)? 0: ((status.y > config.height)? config.height: status.y)) | 0;
}
status.lastX = e.pageX;
status.lastY = e.pageY;
};
};
})();
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・

昨日は東小金井でマンツーマン。
リスニングに特化して勉強してました。
ピラセタム(頭の良くなる薬)を半錠飲んで取り組む、
分からない単語が多過ぎてとてもへこみました。
つまり、まだまだ先は長いということです。
CCレッスンでも、毎回、リスニングを練習する時間を取ろうと思う。
昨日は、脳を使いすぎたため、また、歩き始めたらフラフラとめまいがしました。
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
CCレッスン用のテキスト
便捷的网络、更新换代的智能手机给人们的生活带来更大的便利,对于自制力较薄弱的青少年来说,却可能带来负面影响。用智能手机长时间玩游戏、聊天、看视频的“低头族”开始在青少年人群里蔓延,日本也不例外。
日本内阁府于2019年3月公布了对青少年互联网使用情况的调查报告。该调查从2018年11月3日至2018年12月3日为期一个月的时间内,分别对5000名10周岁至17周岁的青少年及5000名与青少年同居的监jian1护人进行调查,并收到了3288名青少年和3469名监护人的调查样本。调查结果显示,在青少年使用智能手机的监护人中,通过过滤lǜ或技术手段等来管理孩子使用网络的监护人高达84.9%。
在这些对青少年使用智能手机进行管控的家长中,“通过过滤手段”进行管控kong4的占36.1%,“掌握孩子的网络使用情况的”占36.2%,“在大人的视线xi4范围内使用”占34.4%,“指定使用时间及场所的”则占29.8%。即便如此,日本文部科学省2019年3月公布的调查显示,日本中小学生的视力不足1.0的人数已经创造了历史最高纪录。在文部科学省2018年对日本340多万的学生进行调查后发现,小学生视力不足1.0的占34.1%,高中生占67.23%,这两个比列均达到自1979年开始进行该调查以来的最高值。日本国内认为,造成该结果的很大一个因素在于青少年长时间使用智能手机和便携式游戏机。
日本人曾经把眼镜看作优等生的标志。随着使用普通手机的青少年逐渐向使用智能手机过渡,他们使用智能手机的时间也在增加。2018年日本青少年日平均使用智能手机的时间比2017年增加9分钟,高达169分钟,而在日本小学生当中更是增加了21分钟。在日本的青少年中,使用智能手机看视频、进行交际和打游戏的占据前三位,分别为77.1%、75%和70.5%,通过智能手机进行学习的只占到33.3%。因此,现如今在日本戴眼镜的学生未必就是学习好的学生。
此外,据日本某移动运营商调查显示,每三个中学生中就有一个曾经浏览过不良网页。曾经受到短信、广告等欺诈的占到了三成。鉴jiàn此,日本政府为了给青少年使用智能手机营造安全互联网的环境,制定了相关法律进行限制。如果手机签约者是未满18岁的青少年,原则上规定手机运营商有义务向用户提供过滤服务。如根据年龄层不同限制使用手机软件的范围等。日本在2018年2月1日修订的相关法律中规定,运营商有义务在签订新手机合同时向青少年进行确认,将进行过滤设定等限制青少年使用手机网络的相关措施,以此为青少年营造利于学习的网络氛围。同时,日本手机运营商们也会根据不同年龄段的青少年出售不同的手机类型。有的手机被限制了邮件的使用和互联网的使用,有的则只能进行点对点的联系或只能打电话发信息。因此,日本青少年家长大多情况下会选择给孩子购买此类智能手机。日本还有一些新的机种帮助青少年家长对青少年使用手机情况进行管理,他们能够通过智能手机的实时定位、防走路看手机、求救和防霸凌等功能掌握孩子的安全状况。
据记者了解,有不少日本青少年认为经常访问互联网可以有效地学习课外知识以及防止与社会脱节。但是,这并不能说明他们愿意分享自己的网络活动,特别是把智能手机看成是个人隐私。由于青少年生理和心理尚未成熟,对不良信息缺乏甄zhēn别能力,因此造成沉迷手机问题尤为突出,严重的不仅对青少年的学习、生活和身心健康产生影响,还有可能衍生出其他社会性问题,形成新的社会矛盾。
阻止青少年使用智能手机是不符合时代发展潮流的,但如何让青少年的手机不再是游戏机,而是互联网时代的学习工具,又考验着每一个日本家长甚至是学校。
引用元:http://media.people.com.cn/n1/2019/0530/c40606-31109739.html
家长科学的引导对孩子使用手机的用途影响显著
游戏一直是家长们控诉的主要内容。调研发现,有40.59%的未成年受访者表示使用手机的主要用途为玩游戏,位居玩手机的主要用途中的第四。虽然游戏是孩子使用手机的主要用途之一,但并没有家长和老师们认为的那样严重:老师认为孩子使用手机的用途中,游戏排第一;家长则认为排第三。
被称为“互联网原住民”的这代未成年人,学习和生活都是在智能手机的陪伴下展开的。手机带给孩子们的利大还是弊大?对此,不同的群体态度不同。调查结果显示,孩子自身对于手机对未成年人的影响持正面态度;家长的态度是好坏参半;老师则持较为负面的态度。
但几类群体的一个相同的态度是:家长在引导未成年人使用手机中扮演主要角色。调研深入分析发现,在家长对孩子使用手机的时间和方式作出管理和要求的情况下,孩子的手机应用内消费、遭遇网络欺凌、遭遇色情、暴力信息等情况均有显著减少。比如,在家长进行管理的情况下,未成年人遭遇网络色情、暴力信息的概率会从36%降至18.5%。
不过,有约四成的受访家长表示不太懂得如何引导孩子正确使用手机。
家长管理孩子使用手机的方式一般有三种:设置密码,规定使用时间段和有条件使用。调查显示,这三种方式均有一定的效果。其中,有条件使用手机这一方式效果最为明显,能将孩子使用手机学习的概率提高77%,规定使用时间段和设置密码分别能将孩子使用手机学习的概率提高52.6%和39%。
同时,家长的以身作则也十分重要。调查显示,父母每天在家使用手机的时间越长,孩子使用手机进行学习的比例越低。
“在调查中,当我们研究员问几名父母经常不在身边的初二学生:如果爸爸陪在身边和每天能自由使用手机中选一个,你会怎么选?‘选择爸爸陪在身边’是他们的一致回答。”娜迪娅nà dí yà 对此表示,“所以我们的感受是,能够科学合理引导孩子使用手机的,可能并不是学历最高或最懂互联网的家长,而是能够有更多时间陪伴孩子的家长。”
引用元:http://www.handannews.com.cn/news/content/2019-08/08/content_8021258.html

200時間の法則
とあるサイトで見かけた言葉です。
人間はあることに集中して学習していると、200時間程度で一つの段階を達成することができるらしいです。
以前、1000時間の法則とか、10000時間の法則とかみましたけどね。
1000時間やれば、どんなこともみにつく。
10000時間やれば、上級者になれる・・・など。
私は平日は30分程度しか中国語を勉強する時間はとれません。
その代わり、土日は3~4時間は勉強するようにしています。
週10時間勉強したとして、20週間(5ヶ月)で次のステップに進めるということでしょうか。
いずれにしても、
もう、これ以上時間をかけたくありません。
もっと早く、
もっと早く、
中国語を上達したいものです。