Avoid White Blocks
白背景上の白いブロックを、ソナーを頼りに避け続けるだけのゲーム
操作方法(How to Play)
・PC
・マウス位置(Mouse Move)
・スマホ(Smartphone)
・傾ける(Tilt)
/**
* Copyright o_healer ( http://wonderfl.net/user/o_healer )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/ab81
*/
/*
「Avoid White Blocks」
・白背景上の白いブロックを、ソナーを頼りに避け続けるだけのゲーム
(Avoid white blocks. That's all.)
操作方法(How to Play)
・PC
・マウス位置(Mouse Move)
・スマホ(Smartphone)
・傾ける(Tilt)
その他
・当初は回転まで入れようかと思ったが、思いのほか難しくなったので却下した
・どこかで見た気もするので、すでに他の人が作ってたかもしれない
*/
package
{
import flash.display.*;
import flash.display3D.*;
import flash.desktop.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.media.*;
import flash.sensors.*;
import flash.utils.*;
[SWF(width="465", height="465", frameRate="30", backgroundColor="0xFFFFFF")]
// [SWF(width="480", height="800", frameRate="30", backgroundColor="0xFFFFFF")]//Galaxy S, Galaxy S2
// [SWF(width="720", height="1280", frameRate="30", backgroundColor="0xFFFFFF")]//Galaxy S3, Xperia Acro HD, SC-03E, SH02E
// [SWF(width="800", height="1280", frameRate="30", backgroundColor="0xFFFFFF")]//Asus Nexus 7
// [SWF(width="320", height="480", frameRate="30", backgroundColor="0xFFFFFF")]//iPhone 3G
// [SWF(width="640", height="960", frameRate="30", backgroundColor="0xFFFFFF")]//iPhone 4
// [SWF(width="768", height="1024", frameRate="30", backgroundColor="0xFFFFFF")]//iPad
// [SWF(width="1536", height="2048", frameRate="30", backgroundColor="0xFFFFFF")]//Retina
//!!test
// [SWF(width="320", height="480", frameRate="30", backgroundColor="0x000000")]//iPhone 3G
public class Main extends Sprite {
//==Const==
//実際の表示サイズ
public function GetTotalW():int{
return stage.stageWidth;
// return Capabilities.screenResolutionX;
}
public function GetTotalH():int{
return stage.stageHeight;
// return Capabilities.screenResolutionY;
}
//Block
static public const CREATE_INTERVAL_MIN:Number = 1.7;
static public const CREATE_INTERVAL_MAX:Number = 1.7;
static public const VEL_FALL_MIN:Number = 60;
static public const VEL_FALL_MAX:Number = 60;
static public const VEL_ROT_MIN:Number = 0;
static public const VEL_ROT_MAX:Number = 0;
static public const BLOCK_W_MIN:Number = 100;
static public const BLOCK_W_MAX:Number = 200;
static public const BLOCK_H_MIN:Number = 50;
static public const BLOCK_H_MAX:Number = 70;
//Sonar
static public const SONAR_INTERVAL:Number = 1.0;
static public const SONAR_VEL:Number = 80;
static public const SONAR_W:Number = 4;
static public const SONAR_COLOR:uint = 0x99CCFF;
//Mode
static public var s_ModeIter:int = 0;
static public const MODE_TITLE :int = s_ModeIter++;
static public const MODE_GAME :int = s_ModeIter++;
static public const MODE_END :int = s_ModeIter++;
//==Var==
//Pseudo Singleton
static public var Instance:Main;
//Layer
public var m_Layer_Root :Sprite = new Sprite();
public var m_Layer_Sonar :Sprite = new Sprite();
public var m_Layer_Block :Sprite = new Sprite();
public var m_Layer_Player :Sprite = new Sprite();
public var m_Layer_UI :Sprite = new Sprite();
//Player
public var m_Player:Shape;
public var m_PlayerRad:Number;
//傾け操作
public var m_Accel:Accelerometer = null;
public var m_GravityRatioX:Number = 0;
//Block
public var m_Blocks:Vector.<Block> = new Vector.<Block>();
public var m_Timer_CreateBlock:Number;
//Sonar
public var m_Graphics_Sonar:Graphics;
public var m_Timer_CreateSonar:Number;
public var m_SonarInfo:Vector.<SonarInfo> = new Vector.<SonarInfo>();
//Mode
public var m_Mode:int = 0;
//Score
public var m_Timer_Score:Number;
public var m_TextField_Score:TextField = new TextField();
//Title
public var m_Bitmap_Title:Bitmap;
//Result
public var m_Bitmap_Tweet:Bitmap;
public var m_Bitmap_Retry:Bitmap;
//==Function==
//=Init=
//Init : Constructor
public function Main(){
//最初に一度だけ設定するもの
var i:int;
var xx:int, yy:int;
//alias
var total_w:int = GetTotalW();
var total_h:int = GetTotalH();
//Pseudo Singleton
{
Instance = this;
}
//Random
{
var seed:uint = 0;//再現性のある乱数にして、ちゃんとスコアを競えるように
Util.set_seed(seed);
}
//Layer
{
addChild(m_Layer_Root);
m_Layer_Root.addChild(m_Layer_Sonar);
m_Layer_Root.addChild(m_Layer_Block);
m_Layer_Root.addChild(m_Layer_Player);
m_Layer_Root.addChild(m_Layer_UI);
}
//m_Graphics_Sonar
{
var shape:Shape = new Shape();
m_Layer_Sonar.addChild(shape);
m_Graphics_Sonar = shape.graphics;
}
//m_Player
{
m_Player = new Shape();
m_Layer_Player.addChild(m_Player);
m_PlayerRad = GetTotalW()/32;
var g:Graphics = m_Player.graphics;
g.lineStyle(0,0,0);
g.beginFill(SONAR_COLOR, 1.0);
g.drawCircle(0, 0, m_PlayerRad);
g.endFill();
m_Player.x = GetTotalW()/2;
m_Player.y = GetTotalH() * 90/100;
}
//Tilt
{
if(Accelerometer.isSupported){
m_Accel = new Accelerometer();
m_Accel.setRequestedUpdateInterval(100);
m_Accel.addEventListener(AccelerometerEvent.UPDATE, SetGravity_Listener);
}
}
//m_TextField_Score
{
m_TextField_Score.textColor = 0x0000AA;
m_TextField_Score.x = 0;
m_TextField_Score.y = 0;
m_Layer_UI.addChild(m_TextField_Score);
}
//Title
{
var bmd_title:BitmapData = new BitmapData(total_w, total_h, true, 0x00000000);
FontText.DrawText(bmd_title, "Avoid\nWhite\nBlocks", total_w/2, total_h*25/100, total_w*20/100, 0xFF000000 | SONAR_COLOR);
FontText.DrawText(bmd_title, "Avoid\nWhite\nBlocks", total_w/2-2, total_h*25/100-2, total_w*20/100, 0xFFFFFFFF);
FontText.DrawText(bmd_title, "touch to start", total_w/2, total_h*70/100, total_w*10/100, 0xFF000000 | SONAR_COLOR);
m_Bitmap_Title = new Bitmap(bmd_title);
m_Layer_UI.addChild(m_Bitmap_Title);
}
//Result
{
var bmd:BitmapData;
var w:int = total_w * 80/100;
var h:int = w/3;
const offset:int = 4;
var inner_rect:Rectangle = new Rectangle(offset, offset, w-2*offset, h-2*offset);
bmd = new BitmapData(w, h, false, 0x0000AA);
bmd.fillRect(inner_rect, 0xFFFFFF);
FontText.DrawText(bmd, "Tweet", w/2, h/2, w*20/100, 0xFF000000 | SONAR_COLOR);
m_Bitmap_Tweet = new Bitmap(bmd);
m_Bitmap_Tweet.x = total_w / 2 - w/2;
m_Bitmap_Tweet.y = total_h * 1/4 - h/2;
m_Layer_UI.addChild(m_Bitmap_Tweet);
bmd = new BitmapData(w, h, false, 0x0000AA);
bmd.fillRect(inner_rect, 0xFFFFFF);
FontText.DrawText(bmd, "Retry", w/2, h/2, w*20/100, 0xFF000000 | SONAR_COLOR);
m_Bitmap_Retry = new Bitmap(bmd);
m_Bitmap_Retry.x = total_w / 2 - w/2;
m_Bitmap_Retry.y = total_h * 2/4 - h/2;
m_Layer_UI.addChild(m_Bitmap_Retry);
}
//Touch
{
stage.addEventListener(MouseEvent.MOUSE_UP, OnMouseUp);
}
//Updateの登録
{
addEventListener(Event.ENTER_FRAME, Update);
}
//残りはResetで
{
Reset();
}
}
//Reset
public function Reset():void{
//ステージが始まるたびに実行するもの
m_Timer_CreateBlock = 0;
//Remove Old
while(0 < m_Blocks.length){
var block:Block = m_Blocks[0];
block.parent.removeChild(block);
m_Blocks.splice(0,1);
}
m_SonarInfo = new Vector.<SonarInfo>();
m_Timer_CreateSonar = 0;
m_Timer_Score = 0;
m_TextField_Score.scaleX = m_TextField_Score.scaleY = 1;
m_Bitmap_Tweet.visible = false;
m_Bitmap_Retry.visible = false;
}
//=Update=
//Update
public function Update(e:Event=null):void{
var DeltaTime:Number = 1.0 / 30.0;
switch(m_Mode){
case MODE_TITLE:
//Do Nothing
break;
case MODE_GAME:
Update_Score(DeltaTime);
Update_Player(DeltaTime);
Update_Blocks(DeltaTime);
Update_Sonar(DeltaTime);
HitCheck();
break;
case MODE_END:
//Do Nothing
break;
}
}
//Update : Score
public function Update_Score(in_DeltaTime:Number):void{
var i:int;
var val:int;
//Timer
m_Timer_Score += in_DeltaTime;
//Text
const SCORE_NUM_L:int = 8;
// const SCORE_NUM_R:int = 2;
var score:Number = m_Timer_Score;
for(i = 1; i < SCORE_NUM_L; ++i){
score /= 10;
}
m_TextField_Score.text = "score : ";
for(i = 0; i < SCORE_NUM_L; ++i){
val = score;
m_TextField_Score.appendText(val.toString());
score -= val;
score *= 10;
}
// m_TextField_Score.appendText(".");
// for(i = 0; i < SCORE_NUM_R; ++i){
// val = score;
// m_TextField_Score.appendText(val.toString());
//
// score -= val;
// score *= 10;
// }
}
//Update : Player
public function Update_Player(in_DeltaTime:Number):void{
if(m_Accel){
//傾け操作
var VEL:Number = m_PlayerRad * 2;
m_Player.x += VEL * m_GravityRatioX * in_DeltaTime;
if(m_Player.x < 0){m_Player.x = 0;}
if(GetTotalW() < m_Player.x){m_Player.x = GetTotalW();}
}else{
//PC用:マウス操作
const LERP_RATIO:Number = 0.5;
m_Player.x = Lerp(m_Player.x, mouseX, LERP_RATIO);
}
}
//Update : Block
public function Update_Blocks(in_DeltaTime:Number):void{
var i:int;
var num:int;
var block:Block;
//Create
{
m_Timer_CreateBlock -= in_DeltaTime;
if(m_Timer_CreateBlock <= 0){
m_Timer_CreateBlock += Lerp(CREATE_INTERVAL_MIN, CREATE_INTERVAL_MAX, Util.random());
// var xx:Number = Lerp(0, GetTotalW(), Util.random());//単純なランダム
// var xx:Number = Lerp(0, GetTotalW(), 0.5 - 0.5*Math.cos(Math.PI * Util.random()));//端を多く
var rand:Number = Util.random();
var xx:Number = Lerp(0, GetTotalW(), (0.5 - 0.5*Math.cos(Math.PI * rand) + rand)/2);//上2つの平均
var yy:Number = -BLOCK_H_MAX;
var w:Number = Lerp(BLOCK_W_MIN, BLOCK_W_MAX, Util.random());
var h:Number = Lerp(BLOCK_H_MIN, BLOCK_H_MAX, Util.random());
var v_y:Number = Lerp(VEL_FALL_MIN, VEL_FALL_MAX, Util.random());
var v_rot:Number = Lerp(VEL_ROT_MIN, VEL_ROT_MAX, Util.random());
block = new Block(w, h, v_y, v_rot);
block.x = xx;
block.y = yy;
m_Blocks.push(block);
m_Layer_Block.addChild(block);
}
}
//Delete
{
var LIMIT_Y:Number = GetTotalH() * 2;
num = m_Blocks.length;
for(i = 0; i < num; ++i){
block = m_Blocks[i];
if(LIMIT_Y < block.y){
block.parent.removeChild(block);
m_Blocks.splice(i,1);
--i;
--num;
}
}
}
//Move
{
num = m_Blocks.length;
for(i = 0; i < num; ++i){
block = m_Blocks[i];
block.Update(in_DeltaTime);
}
}
}
//Update : Sonar
public function Update_Sonar(in_DeltaTime:Number):void{
var sonar_info:SonarInfo;
//Create
m_Timer_CreateSonar -= in_DeltaTime;
if(m_Timer_CreateSonar < 0){
var center_x:Number = m_Player.x;
var center_y:Number = m_Player.y;
sonar_info = new SonarInfo();
sonar_info.x = center_x;
sonar_info.y = center_y;
sonar_info.timer = -m_Timer_CreateSonar;
m_SonarInfo.push(sonar_info);
m_Timer_CreateSonar += SONAR_INTERVAL;
}
//Draw
m_Graphics_Sonar.clear();
m_Graphics_Sonar.lineStyle(SONAR_W, SONAR_COLOR, 1.0);
for(var i:int = 0; i < m_SonarInfo.length; ++i){
sonar_info = m_SonarInfo[i];
sonar_info.timer += in_DeltaTime;
var rad:Number = SONAR_VEL * sonar_info.timer;
m_Graphics_Sonar.drawCircle(sonar_info.x, sonar_info.y, rad);
if(2*GetTotalH() < rad){
m_SonarInfo.splice(i, 1);
--i;
}
}
}
//HitCheck
public function HitCheck():void{
var xx:Number = m_Player.x;
var yy:Number = m_Player.y;
var rad:Number = m_PlayerRad;
for(var i:int = 0; i < m_Blocks.length; ++i){
if(m_Blocks[i].HitCheck(xx, yy, rad)){
OnEnd();
break;
}
}
}
//
public function OnEnd():void{
if(m_Mode == MODE_END){
return;
}
m_Mode = MODE_END;
m_Graphics_Sonar.clear();
m_Graphics_Sonar.lineStyle(0,0,0);
m_Graphics_Sonar.beginFill(SONAR_COLOR, 1.0);
m_Graphics_Sonar.drawRect(0, 0, GetTotalW(), GetTotalH());
m_Graphics_Sonar.endFill();
m_TextField_Score.scaleX = m_TextField_Score.scaleY = 2;
m_Bitmap_Tweet.visible = true;
m_Bitmap_Retry.visible = true;
}
//=Touch=
//Up
public function OnMouseUp(e:MouseEvent):void{
switch(m_Mode){
case MODE_TITLE:
//Start
m_Bitmap_Title.parent.removeChild(m_Bitmap_Title);
m_Mode = MODE_GAME;
break;
case MODE_GAME:
//Do Nothing
break;
case MODE_END:
if(m_Bitmap_Tweet.bitmapData.rect.contains(m_Bitmap_Tweet.mouseX, m_Bitmap_Tweet.mouseY)){
//Tweet
Navigate_Twitter();
}
if(m_Bitmap_Retry.bitmapData.rect.contains(m_Bitmap_Retry.mouseX, m_Bitmap_Retry.mouseY)){
//Restart
Reset();
m_Mode = MODE_GAME;
}
break;
}
}
//=Gravity=
//Accelometorからの重力受け取り
public function SetGravity_Listener(e:AccelerometerEvent):void{
m_GravityRatioX = -e.accelerationX;
}
//=Navigation=
//Twitter
public function Navigate_Twitter():void{
navigateToURL(new URLRequest(
"http://twitter.com/share?" +
"text=" + escapeMultiByte("Avoid White Blocks \n- Score : " + int(m_Timer_Score).toString() + "\n #wonderfl") +
// "&url=" + loaderInfo.url
"&url=" + "http://wonderfl.net/c/ab81"
));
}
//=Util=
//Lerp
public function Lerp(in_Src:Number, in_Dst:Number, in_Ratio:Number):Number{
return (in_Src * (1 - in_Ratio)) + (in_Dst * in_Ratio);
}
}
}
import flash.display.*;
import flash.display3D.*;
import flash.desktop.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.media.*;
class Block extends Sprite
{
//==Var==
public var m_FallVel:Number;
public var m_RotVel:Number;
public var m_BitmapData:BitmapData;
//==Function==
//Init
public function Block(in_W:int, in_H:int, in_FallVel:Number, in_RotVel:Number){
m_FallVel = in_FallVel;
m_RotVel = in_RotVel;
m_BitmapData = new BitmapData(in_W, in_H, false, 0xFFFFFF);
var bmp:Bitmap = new Bitmap(m_BitmapData);
bmp.x = -in_W/2;
bmp.y = -in_H/2;
addChild(bmp);
}
//Update
public function Update(in_DeltaTime:Number):void{
this.y += m_FallVel * in_DeltaTime;
this.rotation += m_RotVel * in_DeltaTime;
}
//HitCheck
public function HitCheck(in_TrgX:Number, in_TrgY:Number, in_Rad:Number):Boolean{
//Alias
var w:Number = m_BitmapData.width;
var h:Number = m_BitmapData.height;
//中心同士の絶対差
var gap_x:Number = in_TrgX - this.x;
var gap_y:Number = in_TrgY - this.y;
//ブロックの回転量
var theta:Number = -this.rotation * Math.PI/180;
var cos:Number = Math.cos(theta);
var sin:Number = Math.sin(theta);
//ブロックから見た相対的な相手の位置
var rel_x:Number = gap_x * cos - gap_y * sin;
var rel_y:Number = gap_x * sin + gap_y * cos;
//ブロック内の座標で相手に一番近い位置
var src_x:Number = rel_x;
if(src_x < -w/2){src_x = -w/2;}
if( w/2 < src_x){src_x = w/2;}
var src_y:Number = rel_y;
if(src_y < -h/2){src_y = -h/2;}
if( h/2 < src_y){src_y = h/2;}
//距離
var fin_gap_x:Number = src_x - rel_x;
var fin_gap_y:Number = src_y - rel_y;
var distance:Number = Math.sqrt(fin_gap_x*fin_gap_x + fin_gap_y*fin_gap_y);
return (distance < in_Rad);
}
}
class SonarInfo
{
public var x:Number;
public var y:Number;
public var timer:Number = 0;
}
class FontText
{
//==Embed==
// [Embed(
// source='ume-tgc4.ttf',
// fontFamily='myfont',
// embedAsCFF='false',
// mimeType='application/x-font',
// unicodeRange='U+002F,U+002A,U+000D,U+000A,U+6B8B,U+308A,U+663C,U+4F11,U+307F,U+30FB,U+30D0,U+30C3,U+30AF,U+30DC,U+30BF,U+30F3,U+306E,U+52D5,U+4F5C,U+78BA,U+8A8D,U+3000,U+30B2,U+30FC,U+30E0,U+753B,U+9762,U+2192,U+30B9,U+30C6,U+30B8,U+9078,U+629E,U+30E1,U+30CB,U+30E5,U+30EA,U+30B6,U+30EB,U+30C8,U+30A4,U+30B3,U+30B0,U+30E9,U+7D42,U+4E86,U+0069,U+004F,U+0053,U+6A2A,U+6301,U+3061,U+3060,U+3068,U+0052,U+0065,U+0073,U+006F,U+006C,U+0075,U+0074,U+006E,U+0058,U+0059,U+304C,U+9006,U+306B,U+306A,U+308B,U+30B5,U+6E96,U+5099,U+30D7,U+30D5,U+30A9,U+3054,U+30A1,U+7528,U+610F,U+6570,U+FF12,U+FF10,U+304F,U+3089,U+3044,U+FF08,U+3092,U+30C7,U+81EA,U+4F53,U+304B,U+524A,U+9664,U+3057,U+3066,U+304A,U+3053,U+FF09,U+0077,U+0064,U+0072,U+0066,U+7248,U+0047,U+0054,U+0061,U+0048,U+306F,U+0067,U+0057,U+0068,U+53C2,U+7167,U+3001,U+0046,U+57CB,U+3081,U+8FBC,U+305B,U+305A,U+3069,U+5C0E,U+7DDA,U+5916,U+3082,U+50CF,U+0045,U+006D,U+0062,U+0041,U+9A13,U+6700,U+5927,U+6709,U+6599,U+7279,U+6B8A,U+30B7,U+30E7,U+5BB6,U+3067,U+0076,U+0079,U+3042,U+5B9F,U+884C,U+3059,U+3051,U+6210,U+0050,U+30D3,U+30C9,U+5225,U+004D,U+004C,U+30A2,U+4F7F,U+666E,U+901A,U+305D,U+4ED6,U+FF1F,U+53D6,U+5F97,U+65B9,U+30E2,U+30AE,U+30DF,U+7D39,U+4ECB,U+30AD,U+683C,U+5B50,U+6A21,U+69D8,U+8996,U+899A,U+7684,U+30D1,U+6587,U+5B57,U+305F,U+0070,U+5185,U+4EE5,U+4E0B,U+8A2D,U+5B9A,U+5FC5,U+8981,U+0063,U+0049,U+6CE8,U+0055,U+0071,U+63A5,U+7D9A,U+FF13,U+5206,U+5207,U+308C,U+300C,U+767D,U+9ED2,U+8FF7,U+56F3,U+0020,U+002D,U+007A,U+300D,U+30DE,U+30DB,U+50BE,U+4E16,U+754C,U+30B4,U+76EE,U+6307,U+30BA,U+30ED,U+00D7,U+30C0,U+0042,U+0026,U+64CD,U+6CD5,U+0043,U+4E2D,U+5FC3,U+5BFE,U+30A6,U+4F4D,U+7F6E,U+79FB,U+672C,U+6B21,U+56DE,U+60C5,U+5831,U+77E5,U+003A,U+002E,U+005F,U+003F,U+003D,U+004A,U+690D,U+FF06,U+7121,U+304D,U+6B63,U+5F62,U+8FD1,U+8868,U+793A,U+307E,U+6F70,U+FF1D,U+5FAE,U+8ABF,U+6574,U+6163,U+6027,U+308F,U+5168,U+FF0B,U+8272,U+3005,U+8FFD,U+52A0,U+006B,U+007B,U+0009,U+003B,U+0078,U+0033,U+0044,U+005B,U+0028,U+0022,U+0034,U+0036,U+0035,U+002C,U+0030,U+0029,U+005D,U+0038,U+0031,U+0032,U+0037,U+004E,U+0039,U+0027,U+0056,U+969B,U+007D,U+004B,U+4E00,U+3055,U+003C,U+30BB,U+53EF,U+80FD,U+7269,U+7406,U+7DCF,U+542B,U+3080,U+3064,U+534A,U+9023,U+7D50,U+30D6,U+91CD,U+529B,U+6F14,U+51FA,U+7D20,U+5730,U+4E0A,U+5DE6,U+53F3,U+FF11,U+FF5E,U+FF15,U+5FDC,U+7A7A,U+30EC,U+30E4,U+7403,U+FF1A,U+0051,U+003E,U+898B,U+3084,U+697D,U+7C21,U+5358,U+6B62,U+5C11,U+601D,U+8003,U+89E3,U+96E3,U+500B,U+4EBA,U+958B,U+767A,U+6A5F,U+7A2E,U+516C,U+691C,U+8A3C,U+8CB7,U+3063,U+3046,U+9AD8,U+8CA0,U+8377,U+5165,U+30CF,U+005A,U+005C,U+002B,U+30C1,U+30E3,U+679C,U+03B1,U+FF0D,U+30A7,U+6642,U+98DB,U+3070,U+6DF1,U+5EA6,U+66F4,U+65B0,U+51E6,U+6271,U+5411,U+5316,U+696D,U+5F53,U+8FD4,U+5024,U+6E21,U+90E8,U+5834,U+5408,U+59CB,U+5B8C,U+4FDD,U+5F8C,U+521D,U+671F,U+79D2,U+30AB,U+4E8B,U+524D,U+5E45,U+9577,U+30A3,U+3088,U+62E1,U+77ED,U+8A08,U+7B97,U+9802,U+70B9,U+63CF,U+624B,U+901F,U+0021,U+5404,U+629C,U+30D4,U+63DB,U+3048,U+9014,U+007C,U+518D,U+5E30,U+4E0D,U+5341,U+006A,U+7E26,U+4E26,U+3073,U+8CEA,U+5909,U+7BC4,U+56F2,U+5E8F,U+76E4,U+6319,U+6BCE,U+547C,U+3076,U+64EC,U+4F3C,U+9032,U+30B1,U+6765,U+964D,U+4F55,U+8A70,U+3050,U+5883,U+8DDD,U+96E2,U+4E08,U+592B,U+5FF5,U+53CD,U+5C04,U+30D2,U+5143,U+6C42,U+3071,U+8D77,U+56FA,U+4ECA,U+5230,U+9054,U+885D,U+7A81,U+5224,U+4EEE,U+5EA7,U+6A19,U+9CF4,U+8EFD,U+632F,U+58C1,U+007E,U+4FB5,U+76F8,U+6BBA,U+96A3,U+65AD,U+7559,U+6BB5,U+968E,U+97F3,U+6C7A,U+5148,U+540C,U+3058,U+5012,U+57FA,U+67A0,U+904E,U+52B9,U+9650,U+80CC,U+666F,U+95A2,U+4FC2,U+554F,U+7B54,U+8131,U+89E6,U+512A,U+6620,U+3078,U+906E,U+3072,U+4E57,U+63D0,U+89D2,U+7AEF,U+308D,U+5B58,U+5728,U+9055,U+73FE,U+8EAB,U+9818,U+30CD,U+616E,U+51F9,U+84C4,U+7A4D,U+963B,U+984C,U+751F,U+500D,U+53CE,U+77E2,U+5370,U+304E,U+975E,U+7D75,U+6D41,U+FF03,U+826F,U+5C0F,U+30AA,U+9632,U+306D,U+8EE2,U+5E38,U+7DD2,U+900F,U+660E,U+7701,U+7565,U+9069,U+72B6,U+5473,U+592E,U+5DEE,U+5236,U+5FA1,U+53D7,U+0023,U+5897,U+3093,U+7BA1,U+5426,U+5E95,U+69CB,U+5C45,U+6240,U+756A,U+63A1,U+6C17,U+FF14,U+8FBA,U+62BC,U+30DD,U+517C,U+30D9,U+76F4,U+623B,U+9593,U+3041,U+8A55,U+4FA1,U+4F9D,U+983C,U+54C1,U+0025,U+89AA,U+4E3B,'
// )]
// private var font:Class
//==Const==
//
static public var s_AlignIter:int = 0;
static public const ALIGN_CENTER:int = s_AlignIter++;//Default
static public const ALIGN_LEFT :int = s_AlignIter++;
static public const ALIGN_RIGHT :int = s_AlignIter++;
static public const ALIGN_UP :int = ALIGN_LEFT;
static public const ALIGN_DOWN :int = ALIGN_DOWN;
//==Var==
static public var s_TextField:TextField = null;
static public var s_TextFormat:TextFormat = new TextFormat();
static public var s_TextSprite:Sprite = new Sprite();
//==Function==
static public function DrawText(out_BMD:BitmapData, in_Text:String, in_X:Number, in_Y:Number, in_Size:int, in_Color:uint, in_AlignX:int = 0, in_AlignY:int = 0):void{
if(s_TextField == null){
s_TextField = new TextField();
// s_TextField.embedFonts = true;
s_TextField.autoSize = TextFieldAutoSize.LEFT;
// s_TextFormat.font = "myfont";
s_TextSprite.addChild(s_TextField);
}
//Param
s_TextFormat.size = in_Size;
s_TextFormat.color = in_Color;
s_TextFormat.align = TextFormatAlign.CENTER;
s_TextField.defaultTextFormat = s_TextFormat;
s_TextField.text = in_Text;
//Align
switch(in_AlignX){
case ALIGN_LEFT:
s_TextField.x = in_X;
break;
case ALIGN_CENTER:
s_TextField.x = in_X - s_TextField.textWidth/2;
break;
case ALIGN_CENTER:
s_TextField.x = in_X - s_TextField.textWidth;
break;
}
switch(in_AlignY){
case ALIGN_UP:
s_TextField.y = in_Y;
break;
case ALIGN_CENTER:
s_TextField.y = in_Y - s_TextField.textHeight/2;
break;
case ALIGN_DOWN:
s_TextField.y = in_Y - s_TextField.textHeight;
break;
}
//Draw
out_BMD.draw(s_TextSprite);
}
}
class Util
{
//==Const==
static private const MT_N:uint = 624;
static private const MT_M:uint = 397;
static private const MATRIX_A:uint = 0x9908b0df;
static private const UPPER_MASK:uint = 0x80000000;
static private const LOWER_MASK:uint = 0x7fffffff;
static private const MAG01:Vector.<uint> = new <uint>[0x0, MATRIX_A];
//==Var==
static private var iter:int = MT_N;
static private var mt:Vector.<uint> = new Vector.<uint>(MT_N);
//==Function==
//Init
static public function set_seed(in_Seed:uint):void{
mt[0] = in_Seed;
var a:uint = 1812433253;
for(var i:int = 1; i < MT_N; ++i){
var b:uint = mt[i-1] ^ (mt[i-1] >>> 30);
var al:uint = a & 0xFFFF;
var ah:uint = a >>> 16;
var bl:uint = b & 0xFFFF;
var bh:uint = b >>> 16;
var cl:uint = (al * bl) + i;
var ch:uint = (cl >>> 16) + ((al * bh) & 0xFFFF) + ((ah * bl) & 0xFFFF);
mt[i] = ((ch << 16) | (cl & 0xFFFF));
}
iter = MT_N;
}
//Get
static public function random():Number{
//*
//再現性のない乱数
return Math.random();
/*/
//再現性のある乱数(MersenneTwister)
var y:int;
if(MT_N <= iter){
var kk:uint = 0;
for(; kk < MT_N - MT_M; ++kk){
y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+MT_M] ^ (y >>> 1) ^ MAG01[y & 0x1];
}
for(; kk < MT_N - 1; ++kk){
y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK);
mt[kk] = mt[kk+MT_M-MT_N] ^ (y >>> 1) ^ MAG01[y & 0x1];
}
y = (mt[MT_N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
mt[MT_N-1] = mt[MT_M-1] ^ (y >>> 1) ^ MAG01[y & 0x1];
iter = 0;
}
y = mt[iter++];
y ^= (y >>> 11);
y ^= (y << 7) & 0x9D2C5680;
y ^= (y << 15) & 0xEFC60000;
y ^= (y >>> 18);
//-0x80000000~0x7FFFFFFF => 0~0.9999...
var result:Number = y / 4294967296.0;//= y / 0x100000000
if(result < 0){result += 1;}
return result;
//*/
}
}