forked from: テトリスver0.11
forked from テトリスver0.11 (diff: 33)
Copyright asfgu ( http://wonderfl.net/user/asfgu ) * MIT License ( http://www.opensource.org/licenses/mit-license.php ) * Downloaded from: http://wonderfl.net/c/1wWa ここで使用しているコードはPoisonCodeさんのところで紹介されている物を 引用させていただいています PoisonCode→http://poisoncode.blog77.fc2.com/ サブクラス描画がうまくいきません メインの書き方が間違っているのでしょうか?
ActionScript3 source code
/**
* Copyright asfgu ( http://wonderfl.net/user/asfgu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/f8oM
*/
// forked from asfgu's テトリスver0.11
/**
* Copyright asfgu ( http://wonderfl.net/user/asfgu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1wWa
*/
/*
ここで使用しているコードはPoisonCodeさんのところで紹介されている物を
引用させていただいています
PoisonCode→http://poisoncode.blog77.fc2.com/
*/
/*
サブクラス描画がうまくいきません
メインの書き方が間違っているのでしょうか?
*/
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import flash.utils.Timer;
import flash.events.TimerEvent;
[SWF(width="1000", height="400", backgroundColor="0x45b482", frameRate="30")]
public class Main extends Sprite {
private var tetris_left:Tetris;
private var tetris_right:Tetris;
private var base:Sprite = new Sprite;
public function Main() {
tetris_left = new Tetris();
//tetris_right = new Tetris();
addChild(base);
base.addChild(tetris_left);
//tetris_right.x = 500;
//stage.addChild(tetris_right);
/*
if(base.contains(tetris_left)){
var canvas:Sprite = new Sprite();
canvas.x = 100;
canvas.y = 100;
canvas.graphics.beginFill(0x0);
canvas.graphics.drawCircle(0, 0, 100);
canvas.graphics.endFill();
base.addChildAt(canvas,1);
}
*/
}
}
}
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import flash.utils.Timer;
import flash.events.TimerEvent;
class Tetris extends Sprite {
private const FIELD_WIDTH:uint = 14;//テトリス盤の幅
private const FIELD_HEIGHT:uint = 24;//テトリス盤の高さ
private const CELL_WIDTH:uint = 15;//セル一つの幅、つまりブロック一個の幅
private const CELL_HEIGHT:uint = 15;//セル一つの高さ、つまりブロック一個の高さ
private const EMPTY:uint = 0;//中身が空のセル
private const WALL:uint = 9;//中身が壁のセル
private const LOCKED:uint = 10;
private const WALL_COLOR:uint = 0x7A5B52;//壁の色
private const GRID_COLOR:uint = 0xFFFFFF;//グリッドの色、わかりやすく言うと壁を囲む線の色
private const TET_WIDTH:uint = 4;//テトリミノの枠の幅
private const TET_HEIGHT:uint = 4;//テトリミノの枠の高さ
private const DELAY_RANGE:Number = 1000;//テトリミノが落ちるスピード
private const DELAY_MIN:Number = 100;//テトリミノの最速落下速度
private const DELETE_RAG:Number = 150;//揃ったラインが消えるまでのラグ
private const MAP_BLANK:Array = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9];//新しいラインの配列
//private var left:Boolean = false;
//private var right:Boolean = false;
//テトリミノの色の2次元配列
private const TET_COLORS:Array = [
0xE9EE11, // tetPattern01
0x4DE6E1, // tetPattern02
0xEA68E7, // tetPattern03
0xE49E1B, // tetPattern04
0x2746D8, // tetPattern05
0x46DF20, // tetPattern06
0xED2212 // tetPattern07
];
//テトリミノの形の3次元配列
private const tetPattern01:Array = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]];//正方形
private const tetPattern02:Array = [[0, 0, 0, 0], [2, 2, 2, 2], [0, 0, 0, 0], [0, 0, 0, 0]];//棒
private const tetPattern03:Array = [[0, 0, 0, 0], [0, 0, 3, 0], [0, 3, 3, 3], [0, 0, 0, 0]];//テトラ
private const tetPattern04:Array = [[0, 0, 0, 0], [0, 0, 0, 4], [0, 4, 4, 4], [0, 0, 0, 0]];//L
private const tetPattern05:Array = [[0, 0, 0, 0], [0, 5, 0, 0], [0, 5, 5, 5], [0, 0, 0, 0]];//逆L
private const tetPattern06:Array = [[0, 0, 0, 0], [0, 0, 6, 6], [0, 6, 6, 0], [0, 0, 0, 0]];//逆Z
private const tetPattern07:Array = [[0, 0, 0, 0], [0, 7, 7, 0], [0, 0, 7, 7], [0, 0, 0, 0]];//Z
private const TETROMINOS:Array = [
tetPattern01, tetPattern02, tetPattern03, tetPattern04, tetPattern05, tetPattern06, tetPattern07
];
private var location:Point;//描画のポイントの指定
private var currentTetromino:Array;//現在のテトリミノ
private var currentIndex:uint;//テトリミノの形と色をつなげる変数
private var nextIndex:uint;//次のテトリミノのインデックス
private var deleteLineIndex:Array;//揃った列の消去
private var ragTimer:Timer;//揃った列が消えるのを計るタイマー
private var dropTimer:Timer;//テトリミノが落ちるスピードを計るタイマー
private var gameover:Boolean;
private var score:int = 0;
private var texsc:TextField;
//private var nextBorad:NextTetrrominoDisplay;
//フィールドに空のセルと壁のセルを設定する
private var fieldMap:Array = [
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9],
[9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]
];
//フィールドに配置されているセルの色の描画設定をする
private var fieldMapColor:Array = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];private var gameField:Shape;
//Tetrisクラスの初期化
public function Tetris():void {
init()
}
//テトリスゲームフィールド生成
public function init():void {
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);//キーイベントの追加
/*
var canvas:Sprite = new Sprite();
addChild(canvas);
canvas.graphics.beginFill(0x45b482);
canvas.graphics.drawRect(0, 0, 500, 500);
canvas.graphics.endFill();
var tetboard:Shape = new Shape();
addChild(tetboard);
tetboard.graphics.beginFill(0x7A5B52);
tetboard.graphics.drawRoundRect(0, 0, 250, 400, 50);
tetboard.graphics.endFill();
var scoreboard:Shape = new Shape();
addChild(scoreboard);
scoreboard.graphics.beginFill(0x7A5B52);
scoreboard.graphics.drawRoundRect(300, 300, 150, 100, 50);
scoreboard.graphics.endFill();
*/
gameField = new Shape();//新しいフィールドをshapeで生成
addChild(gameField);
gameField.x = CELL_WIDTH;//セルの幅の設定
gameField.y = CELL_HEIGHT;//セルの高さの設定
currentTetromino = new Array();//新しいテトリミノの生成
currentIndex = createTetromino(); //テトリミノの選択
currentTetromino = TETROMINOS[currentIndex];//テトリミノの登録
location = new Point(5, 0);//描画ポイントの設定
nextTetromino(true);
fullDrawing();
dropTimer = new Timer(DELAY_RANGE);//落下タイマーの生成
dropTimer.addEventListener(TimerEvent.TIMER, onDropTetromino);//イベントの追加
dropTimer.start();//タイマーの開始
ragTimer = new Timer(DELETE_RAG, 1);//消去ラグの生成
ragTimer.addEventListener(TimerEvent.TIMER, fillMapBlank);//イベントの追加
texsc = createTextField("score : "+score, 20, 0x0);
texsc.x = 330;
texsc.y = 360;
addChild(texsc);
//addEventListener(Event.ENTER_FRAME, onEnterFrame);
//stage.addEventListener(KeyboardEvent.KEY_UP, onKeyDown);
} // init() close
private function createTextField(text:String, size:int, color:int):TextField
{
var tf:TextField = new TextField();
tf.defaultTextFormat = new TextFormat("", size, color, false);
tf.text = text;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.selectable = false;
return tf;
}
//揃った列の消去と新たな列の挿入
private function fillMapBlank(event:TimerEvent):void {
tetrominoClear();
for (var y:int = deleteLineIndex.length - 1; y >= 0; y--) {
fieldMap.splice(deleteLineIndex[y], 1);//揃った行の削除
fieldMapColor.splice(deleteLineIndex[y], 1);//揃った行の色の削除
fieldMap.splice(0, 0, MAP_BLANK.concat());//新規の行の挿入
fieldMapColor.splice(0, 0, MAP_BLANK.concat());//新規の行の色の挿入
score = score + 10;
removeChild(texsc);
texsc = createTextField("score : " + score, 20, 0x0);
texsc.x = 330;
texsc.y = 360;
addChild(texsc);
}
fullDrawing();
} // fillMapBlank() close
//タイマーによるブロックの落下
private function onDropTetromino(event:TimerEvent):void {
tetrominoAction(Keyboard.DOWN);
}
//ランダムにテトリミノを決める
private function createTetromino():uint {
return Math.floor(Math.random()*7);//戻り値をランダムに決める(1~7)
} // createTetromino() close
/*
private function onEnterFrame(event:Event):void
{
if (left) location.x--;
if (right) location.x++;
tetrominoClear();
fullDrawing();
}
*/
//次のテトリミノの生成と出現
private function nextTetromino(first:Boolean = false):void {
currentTetromino = new Array();//現在のテトリミノを新しく生成
currentIndex = (first)? createTetromino(): nextIndex;//最初のテトリミノの場合、2回テトリミノを作る
for (var y:int = 0; y < TET_HEIGHT; y++) {
currentTetromino[y] = TETROMINOS[currentIndex][y].concat();//テトリミノの配列から現在のテトリミノにコピーする
}
location = new Point(5, 0);//描画ポイントの設定
gameover = overlapCheck(currentTetromino);//ゲームオーバー判定
if (gameover) {
var end:TextField = createTextField("game over", 20, 0x0);//テキストのフォーマット設定
dropTimer.stop();
removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);//イベントリスナーの除去
fullDrawing();
//ゲームオーバー画面の設定
//gameField.graphics.beginFill(0x000000, 0.3);//黒幕の設定
//gameField.graphics.drawRect(0, 0, 500, 500);
end.x = 70;//テキストのx位置
end.y = 150;//テキストのy位置
addChild(end);//テキストの描画
//nextBorad.tetrominoClear();
}
else {
nextIndex = createTetromino();
} // nextTetromino() close
}
//キーボード入力の種類の判定
private function onKeyDown(event:KeyboardEvent):void {//キーが押された
switch(event.keyCode) {//switchを使い押されたキーによってプロセスを選択する
case Keyboard.LEFT://左が押された場合
tetrominoAction(Keyboard.LEFT);
break;
case Keyboard.RIGHT://右が押された場合
tetrominoAction(Keyboard.RIGHT);
break;
case Keyboard.DOWN://下が押された場合
tetrominoAction(Keyboard.DOWN);
break;
case Keyboard.UP:
tetrominoAction(Keyboard.UP);
break;
}
} // onKeyDown() close
//テトリミノの移動の可否判定と再描画
private function tetrominoAction(key:int):void {
switch(key) {
case Keyboard.LEFT:
if (getLeftHit())
break;
tetrominoClear();
location.x--;
fullDrawing();
break;
case Keyboard.RIGHT:
if (getRightHit())
break;
tetrominoClear();
location.x++;
fullDrawing();
break;
case Keyboard.DOWN:
if (getBottomHit()) {
lockTetromino();
nextTetromino();
fullDrawing();
break;
}
tetrominoClear();
location.y++;
fullDrawing();
break;
case Keyboard.UP:
if (turnTetromino())
break;
fullDrawing();
break;
}
} // onKeyDown() close
//下に障害物がある場合にテトリミノを固定する
private function lockTetromino():void {
for (var y:int = 0; y < TET_HEIGHT; y++) {
for (var x:int = 0; x < TET_WIDTH; x++) {
if (currentTetromino[y][x]) {
var mx:int = location.x + x;
var my:int = location.y + y;
fieldMap[my][mx] = LOCKED; // 固定を表す定数を代入
fieldMapColor[y][x] += TET_COLORS[currentIndex];//色のマッピングも固定する
}
}
}
lineCheck();
if (dropTimer.delay > DELAY_MIN)
dropTimer.delay = dropTimer.delay-5;
} // lockTetromino() close
//行が揃っているかどうかをチェックする
private function lineCheck():void {
deleteLineIndex = new Array();
var end:Boolean;
var x:int, y:int;
for (y = FIELD_HEIGHT - 2; y >= 0 && !end; y--) {
var zero:Boolean = false;
for (x = 0; x < FIELD_WIDTH && !zero; x++) {
if (fieldMap[y][x] <= 0)
zero = true;
}
//揃った行を削除する
if (!zero) {
fieldMap.splice(y, 1, MAP_BLANK.concat());
fieldMapColor.splice(y, 1, MAP_BLANK.concat());
deleteLineIndex.push(y);//削除する行の配列インデックスを保存しておく
}
}
if (deleteLineIndex.length > 0) ragTimer.start();//ラグの発生
} // lineCheck() close
//テトリミノを回転させる
private function turnTetromino():Boolean {
var x:int, y:int;
var myValue:int;
//回転用の一時的なテトリミノ
var pTurn:Array = [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
];
//現在のテトリミノを一時的なテトリミノにコピーする
var tetTemp:Array = new Array();
for (y = 0; y < TET_HEIGHT; y++) tetTemp[y] = currentTetromino[y].concat();
//一時的なテトリミノを時計回りに90度回転させる
for (y = 0; y < TET_HEIGHT; y++) {
for (x = 0; x < TET_WIDTH; x++) {
pTurn[x][TET_HEIGHT - 1 - y] = tetTemp[y][x];
}
}
if (overlapCheck(pTurn))
return true;//変更なし
tetrominoClear();
for (y = 0; y < TET_HEIGHT; y++)
currentTetromino[y] = pTurn[y].concat();
return false;//テトリミノの変更
} // turnTetromino() close
//回転したテトリミノが障害とかぶらないかをチェック
private function overlapCheck(pTurn:Array):Boolean {
for (var y:int = 0; y < TET_HEIGHT; y++) {
for (var x:int = 0; x < TET_WIDTH; x++) {
if (pTurn[y][x]) {//テトリミノがある場合
var mx:int = location.x + x;
var my:int = location.y + y;
if (fieldMap[my][mx] && fieldMap[my][mx] != currentIndex + 1)
return true;//かぶっている
}
}
}
return false;//かぶっていない
} // overlapCheck() clos
/*
private function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == 37) left = false;
if (event.keyCode == 39) right = false;
}
*/
//セルの隣の座標を調べます
private function adjacentCheck(tx:int, ty:int, direct:uint):Boolean {
var mx:int, my:int;
switch(direct) {
case Keyboard.LEFT:
mx = location.x + tx -1; //一つ左隣を調べたい
my = location.y + ty;
if (fieldMap[my][mx] && (fieldMap[my][mx] != currentIndex + 1))
return true;
else
return false;
case Keyboard.RIGHT:
mx = location.x + tx +1; //一つ右隣を調べたい
my = location.y + ty;
if (fieldMap[my][mx] && fieldMap[my][mx] != currentIndex + 1)
return true;
else
return false;
case Keyboard.DOWN:
mx = location.x + tx;
my = location.y + ty + 1; //一つ下を調べたい
if (fieldMap[my][mx] && fieldMap[my][mx] != currentIndex + 1)
return true;
else
return false;
}
return true;
} // adjacentCheck() close
//テトリミノのブロックの位置を下から探す
private function getBottomHit():Boolean {
var result:Boolean;
for (var x:int = 0; x < TET_WIDTH; x++) {//左から
for (var y:int = TET_HEIGHT - 1; y >= 0; y--) {//下から
if (currentTetromino[y][x]) {
result = adjacentCheck(x, y, Keyboard.DOWN);//テトリミノがあればチェック
break;
}
}
if (result) //結果が正ならばループを抜ける
break;
}
return result;
} // getBottomHit() close
//テトリミノのブロックの位置を左から探す
private function getLeftHit():Boolean {
var result:Boolean;
for (var y:int = 0; y < TET_HEIGHT; y++) {//上から
for (var x:int = 0; x < TET_WIDTH; x++) {//左から
if (currentTetromino[y][x]) {
result = adjacentCheck(x, y, Keyboard.LEFT);//テトリミノがあればチェック
break;
}
}
if (result) //結果が正ならばループを抜ける
break;
}
return result;
} // getLeftHit() close
//テトリミノのブロックの位置を右から探す
private function getRightHit():Boolean {
var result:Boolean;
for (var y:int = 0; y < TET_HEIGHT; y++) {//上から
for (var x:int = TET_WIDTH - 1; x >= 0; x--) {//右から
if (currentTetromino[y][x]) {
result = adjacentCheck(x, y, Keyboard.RIGHT);//テトリミノがあればチェック
break;
}
}
if (result) //結果が正ならばループを抜ける
break;
}
return result;
} // getRightHit() close
//既存のテトリミノを消去
private function tetrominoClear():void {
for (var y:int = location.y; y < location.y + TET_HEIGHT; y++) {
var py:int = y - location.y;
for (var x:int = location.x; x < location.x + TET_WIDTH; x++) {
var px:int = x - location.x;
if (currentTetromino[py][px]) {
fieldMap[y][x] = EMPTY;
fieldMapColor[y][x] = EMPTY;
}
}
}
} // tetrominoClear() close
//再描画
private function fullDrawing():void {
colorMapping();
drawField();
} // fullDrawing() close
//ゲームフィールドを描画するためのカラーマッピングデータを作成する
public function colorMapping():void {
for (var y:int = 0; y < FIELD_HEIGHT; y++) {//行の移動
for (var x:int = 0; x < FIELD_WIDTH; x++) {//列の移動
//壁のマッピング
if (fieldMap[y][x] == WALL) fieldMapColor[y][x] = WALL_COLOR;//行列[y][x]のカラーマッピング設定
//テトリミノのマッピング
if (y >= location.y && y < location.y + TET_HEIGHT &&//行列が指定描画領域内にいる場合
x >= location.x && x < location.x + TET_WIDTH) {
var px:int = x - location.x;
var py:int = y - location.y;
if (currentTetromino[py][px] && fieldMap[y][x] == EMPTY) {//描画領域が空の場合
fieldMap[y][x] = currentTetromino[py][px];
fieldMapColor[y][x] = TET_COLORS[currentIndex];
}
}
}
}
} // colorMapping() close
//ゲームフィールド描画
public function drawField():void {
var py:Number = 0;//一番上の行を指定
gameField.graphics.clear();//描画されているものを消去
gameField.graphics.lineStyle(1, GRID_COLOR);//線の設定-lineStyle(thickness,color,alpha,pixelHinting)ここではalphaとpixelHintingが省略されています
for (var y:int = 0; y < fieldMap.length; y++) { //設定したフィールドの長さまで繰り返す
var px:Number = 0;//一番左の列を指定
for (var x:int = 0; x < fieldMap[y].length; x++) {
if (fieldMap[y][x] > EMPTY) {//セルの設定が空でない場合
gameField.graphics.beginFill(fieldMapColor[y][x]);//色を塗りこむ
gameField.graphics.drawRect(px, py, CELL_WIDTH, CELL_HEIGHT);//ブロックの描画
}
px += CELL_WIDTH;//列の移動
}
py += CELL_HEIGHT;//行の移動
}
gameField.graphics.endFill();//endFillが指定された時点で全ての描画が行われる
} // drawField() close
}
