
最近、英語の発話スピードが遅くなってきたので、
再度トレーニングをするために、アマゾンでかなりの安値で買ったテキスト。
このテキストを何度も音読する。
このテキストはもう、15年ぐらい前に一度買って、
カナダにいた時代に何度も何度も、朝の5:00に音読していたテキストだった。
あのころは、DMM英会話もレアジョブもない時代だったから、
朝5:00に起きてからのテキストの音読は英語力アップのために必須だった。
このゆっくりニュースダイジェストは、本当、脊髄反射レベルで言えるまで音読を繰り返した記憶がある。
それこそ、100回以上は余裕で音読を繰り返した記憶がある。
それを、この2020年。
もう一度、音読を繰り返すために買いました。
前のはもう、ボロボロすぎて、ゴミと間違えて捨ててしまいましたから。
中国語も英語もテキストがボロボロになるまで音読してきました。
それでこそ、流暢に話せるようになるというものです。
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
中国語がかなり聞き取れるようになってきました。
言いたいことを言うこともだんだんできるようになってきました。
毎日1時間スカイプで勉強しているだけのことはあります。
これまで何度も中国語検定2級に落第しているこれまでの自分の中国語とはレベルが変わってきているように思います。
今度また保護者とのやり取りがあるから、そのときに向かってがんばります。
それにしても、本当に喋れるようになるまでには、自分のプライベートをここまで犠牲にしなければいけないんだなぁ、、、、
週1時間の片手間の趣味、外国語会話スクールじゃあ、喋れるようにならないんだなぁぁぁ、、、、
この1年間、、、1年半、、、、
プライベートなんて何も無かったなぁ。。。。
中国語の勉強ばかりしてて、、、、
それでも、
まだ、ペラペラ自由自在というレベルには程遠いなぁぁぁぁ・・・
結婚も、仕事の充実も、友達関係も、他の趣味も全くなく、そして、中国語だけ勉強してきた約1年半でした。
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・
・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・

子どもたちに自由にパソコンで絵を描かせて、動いて遊べるゲームにする。
そのために、Javascriptのソースをいじっているんだけど、
うまく変更が反映されない。
職場のPCで書いていたからだろうか。
たいして長いソースコードじゃないんだけど、
コードリーディングをすることにした。
ゲームプログラミングはここのところやっていないんだけど、
過去にガチでやっていたこともあるので、
1日、2日、ソースコードをながめていれば、問題は解決するはずなんだけど。
(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);
//ここを書き換えて敵を増やす必要あり。2020/9/12
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;
};
};
})();