テニスを応援しているために占いは、来月の11日過ぎに載せます。
function mmain(){
tmr += 1;
di = 0;
ud = 0;
for(i=0; i
board_x[i] = 0;
board_ud[i] = 0;
}
for(i=0; i
di += curve[parseInt(car_y[0]+i)%CMAX];
ud += updown[parseInt(car_y[0]+i)%CMAX];
board_x[i] = 400 -BOARD_W[i]*car_x[0]/800 + di/2;
board_ud[i] = ud/30;
}
element = document.getElementById("idselect");
sec_time = element.value;
horizon = 400 + parseInt(ud/3);
sy = horizon;
vertical = vertical - parseInt(car_spd[0]*di/8000);
if(vertical < 0) vertical += 800;
if(vertical >= 800) vertical -= 800;
ctx.fillStyle = "rgb(0, 56, 255)";
ctx.fillRect(0, 0, WIDTH, HEIGHT);
ctx.drawImage(img_bg, vertical-800, horizon-400);
ctx.drawImage(img_bg, vertical, horizon-400);
ctx.drawImage(img_sea, board_x[BOARD-1]-780, sy);
msg_draw();
msg_time(s);
// var start = new Date();
//(描画処理)
for (i=BOARD-1; i >0; i--){
ux = board_x[i];
uy = sy - BOARD_UD[i]*board_ud[i];
uw = BOARD_W[i];
sy = sy + BOARD_H[i]*(600-horizon)/200;
bx = board_x[i-1];
by = sy - BOARD_UD[i-1]*board_ud[i-1];
bw = BOARD_W[i-1];
wkcolor = "rgb( 160, 160, 160)";
if(parseInt(car_y[0]+i)%CMAX === PLCAR_Y + 10){
wkcolor = "rgb(192, 0, 0)";
}
ctx.beginPath();
ctx.moveTo(ux,uy);
ctx.lineTo(ux+uw,uy);
ctx.lineTo(bx+bw,by);
ctx.lineTo(bx,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = wkcolor;
ctx.fill();
if(parseInt(car_y[0] +i)%10 <= 4){
ctx.beginPath();
ctx.moveTo(ux,uy);
ctx.lineTo(ux+uw*0.02,uy);
ctx.lineTo(bx+bw*0.02,by);
ctx.lineTo(bx,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = YELLOW;
ctx.fill();
ctx.beginPath();
ctx.moveTo(ux+uw*0.98,uy);
ctx.lineTo(ux+uw,uy);
ctx.lineTo(bx+bw,by);
ctx.lineTo(bx+bw*0.98,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = YELLOW;
ctx.fill();
}
if(parseInt(car_y[0] +i)%20 <= 10){
ctx.beginPath();
ctx.moveTo(ux+uw*0.24,uy);
ctx.lineTo(ux+uw*0.26,uy);
ctx.lineTo(bx+bw*0.26,by);
ctx.lineTo(bx+bw*0.24,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = WHITE;
ctx.fill();
ctx.beginPath();
ctx.moveTo(ux+uw*0.49,uy);
ctx.lineTo(ux+uw*0.51,uy);
ctx.lineTo(bx+bw*0.51,by);
ctx.lineTo(bx+bw*0.49,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = WHITE;
ctx.fill();
ctx.beginPath();
ctx.moveTo(ux+uw*0.74,uy);
ctx.lineTo(ux+uw*0.76,uy);
ctx.lineTo(bx+bw*0.76,by);
ctx.lineTo(bx+bw*0.74,by);
//全て座標を指定
ctx.closePath();
ctx.fillStyle = WHITE;
ctx.fill();
}
scale = 1.5*BOARD_W[i]/BOARD_W[0];
obj_l = object_left[parseInt(car_y[0]+i)%CMAX];
if(obj_l === 2) {
draw_obj(img_obj[obj_l], ux-uw*0.05, uy, scale);
}
if(obj_l === 3) {
draw_obj(img_obj[obj_l], ux-uw*0.5, uy, scale);
}
if(obj_l === 9) {
ctx.drawImage(img_sea, ux-uw*0.5-780, uy);
}
obj_r = object_right[parseInt(car_y[0]+i)%CMAX];
if(obj_r === 1) {
draw_obj(img_obj[obj_r], ux+uw*1.3, uy, scale);
}
for(c=1; c
if(parseInt(car_y[c])%CMAX === parseInt(car_y[0]+i)%CMAX){
lr = parseInt(4*(car_x[0]-car_x[c])/800);
if(lr < -3) lr = -3;
if(lr > 3) lr = 3;
draw_obj(img_car[(c%3)*7+3+lr], ux+car_x[c]*BOARD_W[i]/800, uy, 0.05+BOARD_W[i]/BOARD_W[0]);
}
}
if(i === PLCAR_Y){
draw_shadow(ux+car_x[0]*BOARD_W[i]/800, uy, 200*BOARD_W[i]/BOARD_W[0]);
// if(sw_ren === 1){
// if(cnt_draw
// draw_obj(img_sv , svx, svy, 1);
// cnt_draw += 1;
// } else {
// cnt_draw = 0;
// sw_ren = 0;
// }
// }
draw_obj(img_car[3+car_lr[0]+mycar*7], ux+car_x[0]*BOARD_W[i]/800, uy, 0.05+BOARD_W[i]/BOARD_W[0]);
sv_carx = ux+car_x[0]*BOARD_W[i]/800;
sv_cary = uy;
if(sw_ren === 1){
if(cnt_draw
draw_obj(img_sv , sv_carx, sv_cary, 2);
cnt_draw += 1;
} else {
cnt_draw = 0;
sw_ren = 0;
}
}
}
}
wtext = "" + parseInt(car_spd[0]) + "km/h";
draw_text(wtext, 630, 40, "red", fnt_m, moj_m);
draw_text("lap " + laps + "/" + LAPS, 100, 40, WHITE, fnt_m, moj_m);
draw_text("time " + time_str(rec), 100, 80, GREEN, fnt_s, moj_s);
for(i = 0; i
draw_text(laptime[i], 80, 130+40*i, YELLOW, fnt_s, moj_s);
}
// drive_car(keyw, keyw2);
// keyw = 0;
// keyw2 = 0;
// element = document.getElementById("idresult2");
// element.innerHTML = " tmr=" + tmr + " idx=" + idx;
if(idx === 0){
ctx.drawImage(img_title, 120, 120);
draw_text("[A] Start game",300, 320, WHITE, fnt_m, moj_m);
draw_text("[S] Select your car",300, 400, WHITE, fnt_m, moj_m);
move_car(0)
if(keyw2 != 0){
init_car()
idx = 1;
tmr = 0;
laps = 0;
rec = 0;
recbk = 0;
for(i=0; i
laptime[i] = "0'00.00";
}
}
if(keyw3 === 1){
idx = 4;
keyw3 = 0;
}
}
if(idx === 1){
n = 3 - parseInt(tmr/60);
draw_text("" + n,400, 240, YELLOW, fnt_l, moj_l);
if(tmr >= 179){
idx = 2;
tmr = 0;
}
}
if(idx === 2){
if(tmr
draw_text("Go!", 400, 240, RAD, fnt_l, moj_l);
if(wstartsw === 0){
var wstart = new Date();
wstarts = wstart.getTime();
wstartsw = 1;
}
}
rec = rec + 1/60;
drive_car(keyw, keyw2);
move_car(1);
}
if(idx === 3){
if(tmr === 1){
z = 1;
}
if(tmr === 30){
z = 1;
}
draw_text("GOAL!", 400, 240, RAD, fnt_l, moj_l);
car_spd[0] = car_spd[0]*0.96;
car_y[0] = car_y[0] + car_spd[0]/100;
if(wstartsw === 1){
var wend = new Date();
wstarte = wend.getTime();
wstartsw = 0;
}
ms = wstarte - wstarts;
s = ms / 1000;
msg_time(s);
move_car(1);
if(tmr > 60*8){
idx = 0;
}
}
if(idx === 4){
move_car(0);
draw_text("Select your car", 400, 160, WHITE, fnt_m, moj_m);
for(i=0; i
x = 160+240*i;
y = 300;
col = BLACK;
if(i+wn === mycar){
col = "rgb(0, 128, 255)";
}
ctx.fillStyle = col;
ctx.fillRect(x-100, y-80, 200, 160);
draw_text("[" + (i+1) + "]", x-40, y-50, WHITE, fnt_m, moj_m);
ctx.drawImage(img_car[3+(i+wn)*7], x-100, y-20);
}
if(3+wn
draw_text("→", 750, 350, GREEN, fnt_m, moj_m);
}
if(3+wn > 3){
draw_text("←", 5, 350, GREEN, fnt_m, moj_m);
}
draw_text("[Enter] OK!", 300, 430, GREEN, fnt_m, moj_m);
if(keyw4 === 1) mycar = 0+wn;
if(keyw4 === 2) mycar = 1+wn;
if(keyw4 === 3) mycar = 2+wn;
if(keyw3 === 2) { idx = 0; keyw3 = 0;}
}
sframe += 1;
if(sframe === 60) {
// var stop = new Date();
// ms = stop.getTime() - start.getTime();
// s = ms / 1000;
sframe = 0
}
gameover1 += 1
timer1 = setTimeout("mmain()", sec_time);
}
// ゲームオーバーの表示
function msg_draw(){
ctx.font = "20px 'MS Pゴシック'";
ctx.fillStyle = "white";
// ctx.fillText("カーソルキーの上、下、右、左を押してください",200,100);
ctx.fillText("マウスで車体位置を中心に上下左右に動かしてください",200,100);
}
function msg_time(s){
ctx.font = "20px 'MS Pゴシック'";
ctx.fillStyle = "white";
// ctx.fillText("カーソルキーの上、下、右、左を押してください",200,100);
time_s = " time=" + s;
ctx.fillText(time_s, 600, 130);
}
function draw_text(text, x, y, col, fnt, moj){
ctx.font = fnt;
wx = x - text.length*moj/2;
wy = y - moj/2;
ctx.fillStyle = "black";
ctx.fillText(text, x + 2, y + 2);
ctx.fillStyle = col;
ctx.fillText(text, x, y);
}
var canvas;
var ctx;
WIDTH = 800;
HEIGHT = 600;
var username = ["ipad","iphone","android"]; //端末の名前
WHITE = "rgb(255, 255, 255)";
YELLOW = "rgb(255, 224, 0)";
BLACK = "rgb( 0, 0, 0)";
RAD = "rgb(255, 0, 0)";
GREEN = "rgb( 0, 255, 0)";
var mycar = 0;
//DATA_LR = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 2, 1, 0, 2, 4, 2, 4, 2, 0, 0, 0,-2,-2,-4,-4,-2,-1, 0, 0, 0, 0, 0, 0, 0];
var DATA_LR = [0, 0, 0, 0, 0, 2, 4, 1,-2,-1, 0, 0,-2, 2, 0, 0, 1, 0, 2, 4, 2, 4, 2, 0, 0, 0,-2,-2,-4,-4,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0];
var DATA_UD = [0, 0, 1, 2, 3, 2, 1, 0,-2,-4,-2, 0, 0, 0, 0, 0,-1,-2,-3,-4,-3,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0,-6, 6, 0, 0];
var CLEN = DATA_LR.length;
su_lr = 0;
su_ud = 0;
var VLU0 = "MM 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\n";
var VLU1 = "DATA_LR, 0, 0, 0, 0, 0, 2, 4, 1,-2,-1, 0, 0,-2, 2, 0, 0, 1, 0, 2, 4, 2, 4, 2, 0, 0, 0,-2,-2,-4,-4,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0,DE\n";
var VLU2 = "DATA_UD, 0, 0, 1, 2, 3, 2, 1, 0,-2,-4,-2, 0, 0, 0, 0, 0,-1,-2,-3,-4,-3,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0,-6, 6, 0, 0,DE\n";
var VLU3 = "CAR,10\n";
var VLU4 = "EE\n";
BOARD = 120;
var CMAX = BOARD*CLEN;
ZAHYO_XY = [
"00,300,280,800,320,a",
"00,300,360,800,410,s",
"04,300,390,800,440,r",
"04,060,220,260,380,1",
"04,300,220,500,380,2",
"04,540,220,740,380,3",
"04,005,300,045,350,L",
"04,750,300,795,350,R",
];
ZAHYOMAX = 8;
img_bg = new Image();
img_bg.src = "bg.png";
img_sea = new Image();
img_sea.src = "image_pr/sea.png";
img_shotogo = new Image();
img_shotogo.src = "shotogo.png";
img_title = new Image();
img_title.src = "title02.png";
img_sv = new Image();
img_sv.src = "shotogo1.png";
//var audio = new Audio("sound_pr/02 無言坂.mp3");
MYCARMAX = 4;
var wn = 0;
var gameover1 = 0;
var curve = [];
var updown = [];
var object_left = [];
var object_right = [];
var BOARD_W = [];
var BOARD_H = [];
var BOARD_UD = [];
var board_x = [];
var board_ud = [];
var img_obj = [];
var img_car = [];
//var car_y = 0;
var keyw = 0;
var keyw2 = 0;
var keyw3 = 0;
var keyw4 = 0;
var keyp = 0;
var vertical = 0;
var di = 0;
var sy = 0;
var CAR = 10;
var car_x = [];
var car_y = [];
var car_lr = [];
var car_spd = [];
var PLCAR_Y = 10;
var coursecode = []; //ロボットデータテーブル
var bwr = 41,bhr = 5; //ロボットデータテーブル(サイズ、横、縦)
var idy = 0; // 連携用インデックスy
var cdatasu = 0;
var coursearea = " "; //テキストエリアからの読込用
var coursetext = []; //テキストエリアの第一次分割エリア(行)
var courseitem = []; //テキストエリアの第二次分割エリア(項目)
LAPS = 3;
laptime = [];
var sv_y = 0;
var sv_carx = 0;
var sv_cary = 0;
var sec_time = 20;
var sframe = 0;
var s = 0;
var wstarts = 0;
var wstarte = 0;
var wstartsw = 0;
var idx = 0;
var tmr = 0;
var laps = 0;
var rec = 0;
var recbk = 0;
var sw_ren = 0;
var sw_ren1 = 0;
var cnt_draw = 0;
var svx = 0;
var svy = 0;
var svsc = 1;
var fnt_s = "40px 'MS Pゴシック'";
var fnt_m = "50px 'MS Pゴシック'";
var fnt_l = "120px 'MS Pゴシック'";
var moj_s = 40;
var moj_m = 50;
var moj_l = 120;
var errflg = 0;
function init(){
canvas = document.getElementById('world');
canvas.width = WIDTH;
canvas.height = HEIGHT;
ctx = canvas.getContext('2d');
ctx.font = "48px 'MS Pゴシック'";
user = window.navigator.userAgent.toLowerCase();
for(i=0; i
if(user.indexOf(username[i]) > 0)break;
}
if(i
document.addEventListener("touchmove", touchmove);
}else{
document.addEventListener("mousemove", mousemove);
}
if(i
document.addEventListener("touchstart", touchstart);
}else{
document.addEventListener("mousedown", mousedown);
}
document.addEventListener("keydown", keydown);
document.addEventListener("keyup", keyupop);
for(i=0; i <=CMAX; i++){
curve[i] = 0;
updown[i] = 0;
object_left[i] = 0;
object_right[i] = 0;
}
for(i=0; i
laptime[i] = "0'00.00";
}
element = document.getElementById("idselect");
sec_time = element.value;
document.myFORM.myTEXT.value = VLU0 + VLU1 + VLU2 + VLU3 + VLU4;
for(i=0; i
img_obj[i] = new Image();
}
img_obj[1].src = "board.png";
img_obj[2].src = "yashi.png";
img_obj[3].src = "yacht.png";
for(i=0; i
img_car[i] = new Image();
}
img_car[0].src = "car00.png";
img_car[1].src = "car01.png";
img_car[2].src = "car02.png";
img_car[3].src = "car03.png";
img_car[4].src = "car04.png";
img_car[5].src = "car05.png";
img_car[6].src = "car06.png";
img_car[7].src = "image_pr/car10.png";
img_car[8].src = "image_pr/car11.png";
img_car[9].src = "image_pr/car12.png";
img_car[10].src = "image_pr/car13.png";
img_car[11].src = "image_pr/car14.png";
img_car[12].src = "image_pr/car15.png";
img_car[13].src = "image_pr/car16.png";
img_car[14].src = "image_pr/car20.png";
img_car[15].src = "image_pr/car21.png";
img_car[16].src = "image_pr/car22.png";
img_car[17].src = "image_pr/car23.png";
img_car[18].src = "image_pr/car24.png";
img_car[19].src = "image_pr/car25.png";
img_car[20].src = "image_pr/car26.png";
img_car[21].src = "car30.png";
img_car[22].src = "car31.png";
img_car[23].src = "car32.png";
img_car[24].src = "car33.png";
img_car[25].src = "car34.png";
img_car[26].src = "car35.png";
img_car[27].src = "car36.png";
main();
}
function init_car(){
// if(sec_time === 20){
// CAR = 10;
// } else {
// if(sec_time === 10){
// CAR = 20;
// } else {
// CAR = 30;
// }
// }
for(i=0; i
car_x[i] = 0;
car_y[i] = 0;
car_lr[i] = 0;
car_spd[i] = 0;
}
for(i=1; i
car_x[i] = Math.floor(Math.random()*700)+50;
car_y[i] = Math.floor(Math.random()*(CMAX-400))+200;
car_lr[i] = 0;
car_spd[i] = Math.floor(Math.random()*100)+100;
}
car_x[0] = 400;
car_y[0] = 0;
car_lr[0] = 0;
car_spd[0] = 0;
}
function touchmove(e){
if (e.targetTouches.length == 1){
touch = e.targetTouches[0];
touchpice(touch.pageX ,touch.pageY);
}
}
function touchstart(e){
if (e.targetTouches.length == 1){
touch = e.targetTouches[0];
touchkey(touch.pageX ,touch.pageY);
}
}
//pcのマウスクリックイベントで起動する関数
function mousemove(e){
touchpice(e.x ,e.y);
}
function mousedown(e){
touchkey(e.x ,e.y);
}
//引数で指定した位置にある駒の移動処理(※変更前です)
function touchpice(tx,ty){
mx = tx;
my = ty;
element = document.getElementById("idselect");
sec_time = element.value;
if(ty
if(tx
if(tx > sv_carx + 80) keyw = 2;
if(ty - 50 > sv_y) keyw2 = 6;
if(ty > sv_cary - 30) keyw2 = 6;
if(idx != 2) keyw2 =0;
sv_y = ty;
// element = document.getElementById("idresult2");
// element.innerHTML = " x=" + tx + " y=" + ty;
}
// A,S,R
function touchkey(tx,ty){
mx = tx;
my = ty;
element = document.getElementById("idselect");
sec_time = element.value;
hmoj = "0";
for(i = 0; i
tidx = parseInt(ZAHYO_XY[i].substr(0,2));
tx1 = parseInt(ZAHYO_XY[i].substr(3,3));
ty1 = parseInt(ZAHYO_XY[i].substr(7,3));
tx2 = parseInt(ZAHYO_XY[i].substr(11,3));
ty2 = parseInt(ZAHYO_XY[i].substr(15,3));
tmoj = ZAHYO_XY[i].substr(19,1);
if(idx === tidx){
if((tx >= tx1) && (tx <= tx2) && (ty >= ty1) && (ty <= ty2)){
hmoj = tmoj;
break;
}
}
}
if(hmoj === "a") keyw2 = 5;
if(hmoj === "s") keyw3 = 1;
if(hmoj === "r") keyw3 = 2;
if(hmoj === "1") keyw4 = 1;
if(hmoj === "2") keyw4 = 2;
if(hmoj === "3") keyw4 = 3;
if(hmoj === "L") wn -= 1;
if(hmoj === "R") wn += 1;
if(wn + 3 > MYCARMAX) wn = MYCARMAX - 3;
if(wn < 0) wn = 0;
// element = document.getElementById("idresult2");
// element.innerHTML = " x=" + tx + " y=" + ty + " hmoj=" + hmoj + " idx= " + idx;
}
//コースデーターの取得
function get_cdata(){
errflg = 0;
clearTimeout(timer1);
coursearea = document.myFORM.myTEXT.value;
//ロボットエリアのデーターを改行(¥n)で分ける。
//行ごとにテーブルに入る。
coursetext = coursearea.split("\n");
//bhの数だけテーブル(配列)にする。(ちなみにhはハイ(高さ)です)
for(y=0; y
if(coursetext[y].substr(0,2) === "EE") break;
//bwの数だけテーブル(配列)にする。(ちなみにwはワイド(幅)です)
//行を項目に分ける。(¥t)タブで分ける。
if((coursetext[y].substr(0,2) != "DD") && (coursetext[y].substr(0,2) != "MM")){
cdatasu = cdatasu + 1;
courseitem = coursetext[y].split(",");
if(courseitem[0] === "DATA_LR") set_lr();
else if(courseitem[0] === "DATA_UD") set_ud();
else if(courseitem[0] === "CAR") set_car();
}
}
for(i=0; i
car_x[i] = 0;
car_y[i] = 0;
car_lr[i] = 0;
car_spd[i] = 0;
}
if(su_lr != su_ud) errflg = 1; else { CLEN = su_lr; CMAX = BOARD*CLEN; }
// element = document.getElementById("idresult2");
// element.innerHTML = "DATA_LR=" + DATA_LR + " su_lr =" + su_lr + " su_ud=" + su_ud;
if(errflg === 0){
idx = 0;
keyw2 = 0;
main();
// make_course();
// init_car();
}
}
function set_lr(){
for(x=1; x
//配列(テーブル)に収納する。
if(courseitem[x].substr(0,2) === "DE") break;
if(courseitem[x].substr(0,1) === "-") s1 = -1; else s1 = 1;
DATA_LR[x-1] = s1 * parseInt(courseitem[x].substr(1,1));
}
su_lr = x - 1;
}
function set_ud(){
for(x=1; x
//配列(テーブル)に収納する。
if(courseitem[x].substr(0,2) === "DE") break;
if(courseitem[x].substr(0,1) === "-") s1 = -1; else s1 = 1;
DATA_UD[x-1] = s1 * parseInt(courseitem[x].substr(1,1));
}
su_ud = x - 1;
}
function set_car(){
CAR = 1 * parseInt(courseitem[1]);
}
function make_course(){
for(i=0; i
lr1 = DATA_LR[i];
lr2 = DATA_LR[(i+1)%CLEN];
ud1 = DATA_UD[i];
ud2 = DATA_UD[(i+1)%CLEN];
for(j=0; j
pos = j+BOARD*i;
curve[pos] = lr1*(BOARD-j)/BOARD + lr2*j/BOARD;
updown[pos] = ud1*(BOARD-j)/BOARD + ud2*j/BOARD;
if(j === 60) object_right[pos] = 1;
if(i%8 < 7){
if(j%12 === 0) object_left[pos] = 2;
} else {
if(j%20 === 0) object_left[pos] = 3;
}
if(j%12 === 6) object_left[pos] = 9;
}
}
}
function draw_shadow(x, y, siz){
ctx.globalAlpha= 0.3;
ctx.beginPath();
ctx.scale(1, 1/3);
ctx.fillStyle = "black";
ctx.arc(x, (y-siz/6)*3, siz/2, 0, Math.PI*2, false);
ctx.fill();
ctx.setTransform(1,0,0,1,0,0);
ctx.globalAlpha=1;
}
function drive_car(key, key2){
if(key === 1){
if(car_lr[0] > -3) car_lr[0] -= 1;
car_x[0] = car_x[0] + (car_lr[0]-3) * car_spd[0]/100 -5;
} else if(key === 2){
if(car_lr[0]
car_x[0] = car_x[0] + (car_lr[0]+3) * car_spd[0]/100 +5;
} else {
car_lr[0] = parseInt(car_lr[0]*0.9);
}
if(key2 === 5){
car_spd[0] += 3;
} else if(key2 === 6){
// car_spd[0] -= 10;
car_spd[0] -= 4;
} else {
// car_spd[0] -= 0.25;
car_spd[0] -= 0.05;
}
if(car_spd[0] < 0) car_spd[0] = 0;
if(car_spd[0] > 320) car_spd[0] = 320;
car_x[0] -= car_spd[0]*curve[parseInt(car_y[0]+ PLCAR_Y)%CMAX]/50;
if(car_x[0] < 0){
car_x[0] = 0;
car_spd[0] *= 0.9;
}
if(car_x[0] > 800){
car_x[0] = 800;
car_spd[0] *= 0.9;
}
car_y[0] = car_y[0] + car_spd[0]/100;
if(car_y[0] > CMAX-1){
car_y[0] -= CMAX;
laptime[laps] = time_str(rec - recbk);
recbk = rec;
laps +=1
if(laps == LAPS){
idx = 3;
tmr = 0;
}
}
}
//キーが押された時の処理
function keydown(e){
element = document.getElementById("idselect");
sec_time = element.value;
k = e.keyCode;
if(k==37) { keyw = 1; keyw2 = 5;}
// if(k==38) { keyw2 = 5; keyw = 3; sec_time = 20;}
if(k==38) { keyw2 = 5; keyw = 3;}
if(k==39) { keyw = 2; keyw2 = 5;}
if(k==40) keyw2 = 6;
if(k==65) keyw2 = 5;
if(k==90) keyw2 = 6;
if(k==83) keyw3 = 1; //s
if(k==13) keyw3 = 2; //enter
if(k===49 || k===35) keyw4 = 1; //1
if(k===50 || k===40) keyw4 = 2; //2
if(k===51 || k===34) keyw4 = 3; //3
keyp = 1;
if(idx === 4){
if(k ===39){
wn +=1;
if(wn+3 > MYCARMAX) wn = MYCARMAX - 3;
}
if(k ===37){
wn -=1;
if(wn < 0) wn = 0;
}
}
}
function keyupop(e){
if(keyp = 1){ keyw = 0;; keyw2 = 0; keyp = 0;}
}
function draw_obj(img, x, y, sc){
// img_sv.src = img.src;
// if(sw_ren1 === 1){
svx = x;
svy = y;
svsc = sc;
sw_ren1 = 0;
// }
w = img.width*sc;
h = img.height*sc;
ctx.drawImage(img, x - w/2, y - h, w, h);
}
function time_str(val){
sec = parseInt(val);
ms = parseInt((val- sec)*100);
mi = parseInt(sec/60);
return(""+ mi + "'" + ( '00' + sec%60 ).slice(-2) + "." + ( '00' + ms ).slice(-2));
}
function move_car(cs){
for(i = cs; i
if(car_spd[i]
car_spd[i] += 3;
}
if(i === tmr%120){
car_lr[i] += Math.floor(Math.random() * 3) -1;
if(car_lr[i] < -3) car_lr[i] = -3;
if(car_lr[i] > 3) car_lr[i] = 3;
}
car_x[i] = car_x[i] + car_lr[i]*car_spd[i]/100;
if(car_x[i]
car_x[i] = 50;
car_lr[i] = parseInt(car_lr[i]*0.9)
}
if(car_x[i] > 750){
car_x[i] = 750;
car_lr[i] = parseInt(car_lr[i]*0.9)
}
car_y[i] += car_spd[i]/100;
if(car_y[i] > CMAX-1){
car_y[i] -= CMAX;
}
if(idx === 2){
cx = car_x[i] - car_x[0];
cy = car_y[i] - (car_y[0]+PLCAR_Y)%CMAX;
if( (-100 <= cx) && (cx <= 100) && (-10 <= cy) && (cy <= 10) ){
sw_ren = 1;
sw_ren1 = 1;
draw_obj(img_shotogo, car_x[i] - cx/2, car_y[i] - cy/2, 5);
car_x[0] -= cx/4;
car_x[i] += cx/4;
car_spdsv = car_spd[0];
car_spd[0] = car_spd[i]*0.3;
car_spd[i] = car_spdsv*0.3;
// audio.play();
}
}
}
}
function main(){
minit();
//クロックの処理
mmain();
}
function minit(){
//**イメージ・テーブル作成**
for(i=0; i <=BOARD; i++){
BOARD_W[i] = 0;
BOARD_H[i] = 0;
BOARD_UD[i] = 0;
}
for(i=0; i
BOARD_W[i] = 10+(BOARD-i)*(BOARD-i)/12;
BOARD_H[i] = 3.4*(BOARD-i)/BOARD;
BOARD_UD[i] = 2*Math.sin(i*1.5*(Math.PI/180));
}
make_course();
init_car();
vertical = 0;
}
命を捧げましょう神様に、
愛を捧げましょう仏様に、
善の欲望を捧げましょう悪魔に。
Let's give our lives to God
Let's give love to the Buddha
Dedicate your desire for good to the devil.
カーコース・データのチェック
1)データーは、2桁。
2)一桁目は、スペースか'-'。
3)2桁目は、数字で0~6。
4)データの個数を数える。LRとUDは同じデータ数。
5)LRデータ(左右)、UDデータ(上下)、CARデータ(ジャマー数)
6)5)以外を無視する。
7)DEは、データエンドで必須です。
http://hirohirosystem.com/003_cargame/cargameSV40.html
***データ***
DATA_LR, 0, 0, 0, 0, 0, 2, 4, 1,-2,-1, 0, 0,-2, 2, 0, 0, 1, 0, 2, 4, 2, 4, 2, 0, 0, 0,-2,-2,-4,-4,-2,-1, 0, 0, 0, 0, 0, 0, 0,DE
DATA_UD, 0, 0, 1, 2, 3, 2, 1, 0,-2,-4,-2, 0, 0, 0, 0, 0,-1,-2,-3,-4,-3,-2,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,-3, 3, 0,-6, 6, 0,DE
CAR,10