onClipEvent(load) { // 基本設定 _x = _parent.WIDTH * 8 - 16; _y = (_parent.HEIGHT - 4) * 16 - 32; _visible = true; vx = vy = 0; jump = 0; pic = dir = g_count = 0; // スクロール速度 _parent.T_speed = 200; _parent.T_count = 0; // フラグ gameover = 0; // 表示 _parent._parent.floor_label = "Floor: 00000000"; _parent.fps_label = "FPS: 00/30"; // fps 管理 frame_count = 0; prev_time = (new Date()).getTime(); // エンコード encode = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '-' ]; } onClipEvent(enterFrame) { var acc, st, floor; var key_u = Key.isDown(Key.UP) || Key.isDown(Key.SPACE); var key_l = Key.isDown(Key.Left); var key_r = Key.isDown(Key.Right); t = (new Date()).getTime(); if(++frame_count >= 40) { var fps, str; frame_count = 0; fps = (int)(40000 / (t - prev_time)); str = "00" + fps; str = str.substring(str.length - 2); if(fps < 20) fps = 20; if(fps > 40) fps = 40; _parent.fps_label = "FPS: " + str.substring(str.length - 2) + "/30"; prev_time = t; } if(gameover > 0) { if(!key_u) gameover |= 1; /* if((gameover += 2) > 200 || (key_u && (gameover & 1) == 1)) _parent._parent.play(); */ return; } _x += (int)(vx / 2); _y += vy; if(_parent.T_speed < 5000) _parent.T_speed++; _parent.T_count += _parent.T_speed; if(_parent.T_count > 20000) { _parent.T_count -= 20000; _parent.scroll_up(); _y += 16; } if(_x < 16) { _x = 16; vx = -(int)(vx / 2); } if(_x > _parent.WIDTH * 16 - 48) { _x = _parent.WIDTH * 16 - 48; vx = -(int)(vx / 2); } if(_y < 80) { _parent.scroll_up(); _y += 16; _parent.T_count = 0; } else if(_y >= _parent.HEIGHT * 16) { gameover = 2; _visible = false; _parent.gameover_label._visible = true; _parent.form_label._visible = true; } ty = (int)((_y + 32) / 16); st = (vy >= 0) && (ty < _parent.HEIGHT) && (_parent.get_floor_l(ty) < _x + 24) && (_x + 8 < _parent.get_floor_r(ty)); floor = 0; if(st) { acc = 3; floor = (int)((_parent.Floor_top - (int)(_y / 16)) / 5) + 1; pic &= 1; _y = (int)(_y / 16) * 16; vy = 0; if(++g_count == 5) { g_count = 0; pic ^= 1; } if(key_u) { jump = (int)(Math.abs(vx) / 4) + 7; vy = -(int)(jump / 2) - 12; pic = 2; st = 0; } } else { acc = 2; } flag = true; if(key_l) { dir = 0; vx -= acc; if(vx < -32) vx = -32; flag = false; } if(key_r) { dir = 1; vx += acc; if(vx > 32) vx = 32; flag = false; } if(st && flag) { if(vx < -2) vx += 3; else if(vx > 2) vx -= 3; else vx = 0; } if(!st) { if(jump != 0) { vy = -(int)(jump / 2) - 12; if(key_u) jump--; else jump = 0; } else { vy += 2; if(vy > 0) pic = 3; if(vy > 16) vy = 16; } } if(floor > _parent.Score && gameover == 0) { _parent.Score = floor; str = "00000000" + _parent.Score; _parent._parent.floor_label = "Floor: " + str.substring(str.length - 8); } gotoAndStop(pic * 2 + dir + 1); } /* Todo: font の使い方を調べて text を貼る LoadVars */