donkey??
ゲームウォッチの思い出に浸りながら作り始めたゲーム。まだ作りかけです。
梯子はぜひとも実装したい。。。
現状での操作は、←→で移動、Spaceでジャンプ。
参考文献:ActionScript 3.0 アニメーション
Keith Peters (著)
/**
* Copyright goodbyegirl1974 ( http://wonderfl.net/user/goodbyegirl1974 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/hkhl
*/
package {
import flash.utils.ByteArray;
import flash.geom.Rectangle;
import flash.display.BitmapData;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.Bitmap;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.Event;
import flash.display.Sprite;
public class Donkey extends Sprite {
private const SELF_INIT_X_NUM:Number = 50.0;
private const SELF_INIT_Y_NUM:Number = 410.0;
private const SELF_CHARA_ANIME_TIME:int = 500;
private var _selfCharaBounceNum:Number = -0.2;
private var _selfCharaJumpVyNum:Number = 35;
private var _lineSprite:Sprite;
private var _lineArray:Array = [];
private var _selfChara:GameObjectSelf;
private var _gravity:Number = 0.8;
private var _bounce:Number = -0.6;
private var _logField:TextField;
private var _keyPressArray:Array;
private var _accelNum:Number = 0.5;
private var _gameObjArray:Array;
private var _score:int;
private var _friction:Number = 0.9;
private var _goalSprite:Sprite;
private var _enemyArray:Array;
private var _selfCharaBitmapArray:Array = [];
private var _nowSelfCharaBmpIndex:int = 0;
private var _selfCharaAnimeTimer:Timer;
public function Donkey() {
// write as3 code here..
init();
}
private function init():void
{
//変数のリセット
_gameObjArray = [];
_score = 0;
_keyPressArray = [0 , 0 , 0];
_lineArray = [];
//まず基本となるラインを一本引く
//メインキャラの生成。
_selfChara = new GameObjectSelf(_selfCharaBounceNum);
addChild(_selfChara);
_selfChara.x = this.SELF_INIT_X_NUM;
_selfChara.y = this.SELF_INIT_Y_NUM;
this._gameObjArray.push(_selfChara);
this._goalSprite = makeBoxObject(50, 50, 350, 20, 1, 0x333333, 0xffffff);
var miuraSprite:Sprite = makeBoxObject(70, 30, 5, 5, 1, 0x333333, 0xffffff);
makeLineSprite(400, -3, 0, 420, 5);
makeLineSprite(370, 5, 0, 340);
makeLineSprite(370, -5, 30, 310);
makeLineSprite(370, 5, 0, 215);
makeLineSprite(370, -5, 30, 185);
makeLineSprite(370, 5, 0, 90);
makeLineSprite(330, 0, 70, 70, 5);
stage.addEventListener(KeyboardEvent.KEY_DOWN , keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP , keyUpHandler);
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
var createEnemyTimer:Timer = new Timer(8000);
createEnemyTimer.addEventListener(TimerEvent.TIMER, createEnemyTimerHandler);
createEnemyTimer.start();
createEnemy();
_logField = new TextField();
addChild(_logField);
_logField.autoSize = TextFieldAutoSize.LEFT;
_logField.x = 300;
_logField.y = 420;
_logField.border = true;
var miuraField:TextField = new TextField();
miuraField.text = "史";
miuraSprite.addChild(miuraField);
miuraField.x = 40;
miuraField.x = 35;
var goalField:TextField = new TextField();
goalField.text = "出口";
_goalSprite.addChild(goalField);
//Bitmapの生成。
var bmp:Bitmap;
/*
bmp = this.setBmpData(this._selfCharaBitmapArray01);
this._selfCharaBitmapArray.push(bmp);
bmp = this.setBmpData(this._selfCharaBitmapArray02);
this._selfCharaBitmapArray.push(bmp);
bmp = this.setBmpData(this._selfCharaBitmapArray03);
this._selfCharaBitmapArray.push(bmp);
this._selfCharaAnimeTimer = new Timer(this.SELF_CHARA_ANIME_TIME);
this._selfCharaAnimeTimer.addEventListener(TimerEvent.TIMER, selfCharaAnimeTimerHandler);
_selfCharaAnimeTimer.start();
selfCharaAnimeTimerHandler();*/
}
private function makeLineSprite(widthNum:Number, rotationNum:Number, xNum:Number, yNum:Number, lineWidth:Number = 1, lineColor:uint = 0x333333):void
{
var lineSprite:Sprite = new Sprite();
lineSprite.graphics.lineStyle(lineWidth, lineColor);
lineSprite.graphics.moveTo(0, 0);
lineSprite.graphics.lineTo(widthNum, 0);
addChild(lineSprite);
lineSprite.x = xNum;
lineSprite.y = yNum;
lineSprite.rotation = rotationNum;
_lineArray.push(lineSprite);
}
private function makeBoxObject(widthNum:Number, heightNum:Number, xNum:Number, yNum:Number,
lineWidth:Number = 1, lineColor:uint = 0x333333, fillColor:uint = 0x333333):Sprite
{
var boxSprite:Sprite = new Sprite();
boxSprite.graphics.lineStyle(lineWidth, lineColor);
boxSprite.graphics.beginFill(fillColor);
boxSprite.graphics.moveTo(0, 0);
boxSprite.graphics.lineTo(widthNum, 0);
boxSprite.graphics.lineTo(widthNum, heightNum);
boxSprite.graphics.lineTo(0, heightNum);
addChild(boxSprite);
boxSprite.x = xNum;
boxSprite.y = yNum;
return boxSprite;
}
private function selfCharaAnimeTimerHandler(event:TimerEvent = null):void
{
var targetBitmap:Bitmap = this._selfCharaBitmapArray[_nowSelfCharaBmpIndex];
_nowSelfCharaBmpIndex++;
if(_nowSelfCharaBmpIndex >= _selfCharaBitmapArray.length)
_nowSelfCharaBmpIndex = 0;
while(this._selfChara.numChildren > 0)
{
this._selfChara.removeChildAt(0);
}
this._selfChara.addChild(targetBitmap);
targetBitmap.x = -targetBitmap.width / 2;
targetBitmap.y = -targetBitmap.height / 2;
}
private function createEnemyTimerHandler(event:TimerEvent):void
{
createEnemy();
}
private function createEnemy(type:String = "test"):void
{
var enemy:GameObjSprite;
switch(type)
{
case "test":
enemy = new GameObjectEnemy(-0.3, 5, 0.9) as GameObjSprite;
addChild(enemy);
enemy.x = 5;
enemy.y = 40;
break;
}
_gameObjArray.push(enemy);
}
/**
/* キーが押された際に実行されるファンクション
**/
private function keyDownHandler(event:KeyboardEvent):void
{
var keyCode:uint = event.keyCode;
switch(keyCode)
{
case Keyboard.RIGHT:
_keyPressArray[0] = 1;
break;
case Keyboard.LEFT:
_keyPressArray[0] = -1;
break;
case Keyboard.UP:
_keyPressArray[1] = -1;
break;
case Keyboard.DOWN:
_keyPressArray[1] = 1;
break;
case Keyboard.SPACE:
if(this._selfChara.vy <= 0 && _keyPressArray[2] != 1)
this._selfChara.vy += _selfCharaJumpVyNum;
_keyPressArray[2] = 1;
//ジャンプのファンクションをここに入れる?
break;
}
}
/**
/* キーが離された際に実行されるファンクション
**/
private function keyUpHandler(event:KeyboardEvent):void
{
var keyCode:uint = event.keyCode;
switch(keyCode)
{
case Keyboard.RIGHT:
if(_keyPressArray[0] == 1)
_keyPressArray[0] = 0;
break;
case Keyboard.LEFT:
if(_keyPressArray[0] == -1)
_keyPressArray[0] = 0;
break;
case Keyboard.UP:
if(_keyPressArray[1] == -1)
_keyPressArray[1] = 0;
break;
case Keyboard.DOWN:
if(_keyPressArray[1] == 1)
_keyPressArray[1] = 0;
break;
case Keyboard.SPACE:
_keyPressArray[2] = 0;
break;
}
}
/**
* 毎フレーム実行されるファンクション。
**/
private function enterFrameHandler(event:Event):void
{
var line:Sprite;
var angle:Number;
var cos:Number;
var sin:Number;
var x1:Number;
var y1:Number;
var x2:Number;
var y2:Number;
var gameObj:GameObjSprite;
var oldX:Number;
var oldY:Number;
var oldY2:Number;
var vy1:Number;
for each (gameObj in this._gameObjArray)
{
//gameObj = this._selfChara;
gameObj.vy += this._gravity;
gameObj.x += gameObj.vx;
gameObj.y += gameObj.vy;
for each(line in this._lineArray)
{
//line = this._lineArray[1];
angle = line.rotation * Math.PI / 180;
cos = Math.cos(angle);
sin = Math.sin(angle);
//line を基準とした、_selfChara の相対座標を求める。
x1 = gameObj.x - line.x;
y1 = gameObj.y - line.y;
//今は垂直方向の当たり判定のみでOKなので、y座標のみ、line の回転分だけ回転させる。
//この作業により、line が水平な場合の _selfChara の相対座標が求められる。
y2 = cos * y1 - sin * x1;
//oldY2 = cos * oldY - sin * oldX;
//x2 = cos * x1 + sin * y1;
vy1 = cos * gameObj.vy - sin * gameObj.vx;
if (y2 > gameObj.height / 2 * ( -1) && y2 < vy1)
{
if(gameObj.x > line.x && gameObj.x < line.x + line.width)
{
x2 = cos * x1 + sin * y1;
var vx1:Number = cos * gameObj.vx + sin * gameObj.vy;
y2 = gameObj.height / 2 * ( -1);
vy1 *= gameObj.bounce;
x1 = cos * x2 - sin * y2;
y1 = cos * y2 + sin * x2;
gameObj.vx = cos * vx1 - sin * vy1;
gameObj.vy = cos * vy1 + sin * vx1;
gameObj.x = line.x + x1;
gameObj.y = line.y + y1;
//摩擦の反映
gameObj.vx *= gameObj.friction;
//gameObj.vy *= gameObj.friction;
break;
}
}
}
if(gameObj.y > 500)
{
if(gameObj == this._selfChara)
{
//自機喪失ファンクション
_selfChara.x = this.SELF_INIT_X_NUM;
_selfChara.y = this.SELF_INIT_Y_NUM;
_selfChara.vx = _selfChara.vy = 0
}
else
{
gameObj.finalize();
removeChild(gameObj);
var indexNum:int = this._gameObjArray.indexOf(gameObj);
if(indexNum != -1)
this._gameObjArray.splice(indexNum, 1);
}
}
//自機との衝突判定。
if(gameObj != this._selfChara)
{
var hitFlg:Boolean = this._selfChara.hitTestPoint(gameObj.x, gameObj.y, false);
if(hitFlg)
{
//自機喪失処理
_selfChara.x = this.SELF_INIT_X_NUM;
_selfChara.y = this.SELF_INIT_Y_NUM;
_selfChara.vx = _selfChara.vy = 0;
}
}
else
{
this._logField.text = String(_selfChara.vy);
}
//this.removeEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
}
//ゴール判定
var goalFlg:Boolean = this._goalSprite.hitTestPoint(this._selfChara.x, this._selfChara.y);
if(goalFlg)
{
//ゴール処理
this._logField.text = "ゴール";
}
//ここからは、押されたキーに関連しての処理。
var vxPlusNum:Number = this._accelNum * this._keyPressArray[0];
//this._logField.text = String(this._keyPressArray[0]) + " , " + String(vxPlusNum) + "\n";
if(Math.abs(this._selfChara.vx) < 3)
{
this._selfChara.vx += vxPlusNum;
}
else if(this._selfChara.vx < -3)
{
this._selfChara.vx = -3;
}
else if(this._selfChara.vx > 3)
{
this._selfChara.vx = 3;
}
if(Math.abs(this._selfChara.vy) < 0.05)
this._selfChara.vy = 0;
}
/**
* ゲーム内のオブジェクトを生成するファンクション。
**/
private function makeGameObject(bounceNum:Number = 0.6, bmp:Bitmap = null):void
{
var gameObj:GameObjSprite = new GameObjSprite(bounceNum);
if(bmp != null)
{
gameObj.addChild(bmp);
bmp.x = -bmp.width / 2;
bmp.y = -bmp.height / 2
}
this._gameObjArray.push(gameObj);
}
/**
* 出力結果をビットマップに反映させるファンクション。
**/
private function setBmpData(outPutArray:Array, pixWidth:uint = 1, pixHeight:uint = 1):Bitmap
{
var horizonalPixelNum:uint = outPutArray[0].length;
var verticalPixelNum:uint = outPutArray.length;
var bmd:BitmapData = new BitmapData(pixWidth * horizonalPixelNum, pixHeight * verticalPixelNum, true, 0x00ffffff);
var colorBmd:BitmapData = new BitmapData(pixWidth, pixHeight, true, 0xff000000);
var emptyBmd:BitmapData = new BitmapData(pixWidth, pixHeight, true, 0x00ffffff);
var bmp:Bitmap = new Bitmap(bmd);
var i:int = 0;
for(i; i < outPutArray.length; i++)
{
var targetArray:Array = outPutArray[i];
var j:int = 0;
for(j; j < targetArray.length; j++)
{
//0か1かの結果を取得する。
var colorNum:int = targetArray[j];
var rect:Rectangle = new Rectangle(j * pixWidth, i * pixHeight, pixWidth, pixHeight);
var bytes:ByteArray;
if(colorNum == 1)
bytes = colorBmd.getPixels(new Rectangle(0, 0, pixWidth, pixHeight));
else if(colorNum == 0)
bytes = emptyBmd.getPixels(new Rectangle(0, 0, pixWidth, pixHeight));
bytes.position = 0;
bmd.setPixels(rect, bytes);
}
}
return bmp;
}
private var _selfCharaBitmapArray01:Array = [[0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0],
[0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,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,0,0,0,0,0,0,1,1,1,1],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
}
}
import flash.events.Event;
import flash.display.Sprite;
class GameObjSprite extends Sprite
{
private var _vx:Number = 0.0;
private var _vy:Number = 0.0;
private var _mass:Number = 1.0;
private var _bounce:Number = -0.6;
private var _friction:Number = 0.9;
/**
* コンストラクタ
**/
public function GameObjSprite(bounceNum:Number = -0.6)
{
_bounce = bounceNum;
}
private function init():void
{
}
public function finalize():void
{
}
public function get vx():Number { return _vx; }
public function set vx(value:Number):void
{
_vx = value;
}
public function get vy():Number { return _vy; }
public function set vy(value:Number):void
{
_vy = value;
}
public function get mass():Number { return _mass; }
public function set mass(value:Number):void
{
_mass = value;
}
public function get bounce():Number { return _bounce; }
public function set bounce(value:Number):void
{
_bounce = value;
}
public function get friction():Number { return _friction; }
public function set friction(value:Number):void
{
_friction = value;
}
}
class GameObjectSelf extends GameObjSprite
{
private var _radius:Number = 10;
private var _color:uint = 0xff0000;
public function GameObjectSelf(bounceNum:Number)
{
super(bounceNum);
init();
}
private function init():void
{
graphics.beginFill(_color);
graphics.drawCircle(0, 0, _radius);
graphics.endFill();
}
public function get radius():Number { return _radius; }
public function set radius(value:Number):void
{
_radius = value;
}
public function get color():uint { return _color; }
public function set color(value:uint):void
{
_color = value;
}
}
class GameObjectEnemy extends GameObjSprite
{
private var _rotationNum:Number;
private var _width:Number = 10.0;
public function GameObjectEnemy(bounceNum:Number, rotationNum:Number = 0, frictionNum:Number = 0.9)
{
super(bounceNum);
_rotationNum = rotationNum;
friction = frictionNum;
init();
if(_rotationNum != 0)
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function init():void
{
var boxSprite:Sprite = new Sprite();
boxSprite.graphics.lineStyle(1, 0x666666);
boxSprite.graphics.beginFill(0xaaaaaa);
boxSprite.graphics.moveTo(0, 0);
boxSprite.graphics.lineTo(_width, 0);
boxSprite.graphics.lineTo(_width, _width);
boxSprite.graphics.lineTo(0, _width);
addChild(boxSprite);
boxSprite.x = -_width / 2;
boxSprite.y = -_width / 2;
addChild(boxSprite);
}
private function enterFrameHandler(event:Event):void
{
if(this.vx > 0)
rotation += this._rotationNum;
else
rotation -= this._rotationNum;
}
public override function finalize():void
{
if(this.hasEventListener(Event.ENTER_FRAME))
removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
}