forked from: moja race
ドット絵がどんな感じでスケーリングされているのかの実験。
ドット絵、かわいいのー。
/**
* Copyright fumix ( http://wonderfl.net/user/fumix )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8oto
*/
// forked from tencho's moja race
/**
* コースは毎回微妙に変わります
* ちょっとだけバランス調整しました
*
* [arrow key] : car control
* [Z] : break
*/
package {
import Box2D.Common.Math.*;
import com.actionsnippet.qbox.*;
import com.bit101.components.*;
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.ui.*;
import flash.utils.*;
import flash.display.BitmapData;
public class Race extends Sprite {
private var hSlider:HUISlider;
private var space:int = 5;
private var scale:Number = 10.0;
private var tree:Bitmap;
private var drum:Bitmap;
private var cone:Bitmap;
private var ps:Bitmap;
private var fl:Bitmap;
private var car:Bitmap;
public function Race() {
hSlider = new HUISlider(this, 0, 0,'scale',onChange);
hSlider.maximum = 50;
tree = new Bitmap(Dot.tree);
tree.scaleX = tree.scaleY = scale;
drum = new Bitmap(Dot.drum);
drum.x = tree.width + space;
drum.scaleX = drum.scaleY = scale;
cone = new Bitmap(Dot.cone);
cone.x = drum.width + drum.x +space;
cone.scaleX = cone.scaleY = scale;
ps = new Bitmap(Dot.ps);
ps.x = cone.width + cone.x +space;
ps.scaleX = ps.scaleY = scale;
fl = new Bitmap(Dot.fl);
fl.x = ps.width + ps.x +space;
fl.scaleX = fl.scaleY = scale;
car = new Bitmap(Dot.car1);
car.x = fl.width + fl.x +space;
car.scaleX = car.scaleY = scale;
tree.y = drum.y = cone.y = ps.y = fl.y = car.y = 20;
addChild(tree);
addChild(drum);
addChild(cone);
addChild(ps);
addChild(fl);
addChild(car);
}
private function onChange(e:Event):void{
scale = e.currentTarget.value;
tree.scaleX = tree.scaleY = scale;
drum.x = tree.width + space;
drum.scaleX = drum.scaleY = scale;
cone.x = drum.width + drum.x +space;
cone.scaleX = cone.scaleY = scale;
ps.x = cone.width + cone.x +space;
ps.scaleX = ps.scaleY = scale;
fl.x = ps.width + ps.x +space;
fl.scaleX = fl.scaleY = scale;
car.x = fl.width + fl.x +space;
car.scaleX = car.scaleY = scale;
}
}
}
import flash.display.BitmapData;
class Dot {
static public var tree:BitmapData = image([5, 9, "01110,11222,12233,22332,23434,04440,00500,00500,00500", [0x70E000, 0x40B913, 0x009933, 0x506418, 0xCC6600]]);
static public var car1:BitmapData = image([6, 9, "011110,332233,321123,021120,023320,021120,331133,332233,022220", [0xFF9900, 0xFFFF00, 0x333333]]);
static public var car2:BitmapData = image([6, 9, "011110,332233,321123,021120,023320,021120,331133,332233,022220", [0x0052EA, 0x00B0EA, 0x333333]]);
static public var car3:BitmapData = image([6, 9, "011110,332233,321123,021120,023320,021120,331133,332233,022220", [0x6D0402, 0xED0B0B, 0x333333]]);
static public var car4:BitmapData = image([6, 9, "011110,332233,321123,021120,023320,021120,331133,332233,022220", [0xCFDDEC, 0xECF1F7, 0x333333]]);
static public var drum:BitmapData = image([6, 8, "011110,211112,322221,334111,134112,344221,334111,034110", [0x5A7A85, 0x415C5D, 0x91B7CC, 0x7497A6]]);
static public var cone:BitmapData = image([5, 7, "00300,00100,03340,01120,03440,31224,33444", [0xFFFF00, 0xCC9900, 0xFF3333, 0x990000]]);
static public var startingLine:BitmapData = image([14, 4, "11111111111111,01010101010101,10101010101010,11111111111111", [0xFFFFFF]]);
static public var ps:BitmapData = image([8, 8, "3111111032222222321112233212121332111133321233133213313302333333", [0x6DC8F0, 0x2075B9, 0x054680]]);
static public var fl:BitmapData = image([8, 8, "41111110,42222222,42111213,42122213,42111313,42123313,42133313,02333333", [0xF59234, 0xD42F40, 0x9E222D, 0x801220]]);
static public function image(data:Array):BitmapData {
var bmd:BitmapData = new BitmapData(data[0], data[1], true, 0);
var list:Array = String(data[2]).replace(/,/g, "").split("");
for (var i:int = 0; i < list.length; i++) bmd.setPixel32(i % bmd.width, int(i / bmd.width), (list[i]=="0")? 0 : 0xFF << 24 | data[3][int(list[i]) - 1]);
return bmd;
}
}