In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: forked from: forked from: One-key Game

cara main: TAHAN tombol kibod biar ITUnya naik
LEPAS tombol biar ITUnya turun
how to play: HOLD keyboard key to make IT ascend
RELEASE the key to make IT descend
遊び方: どれかのキーを押したままで ソレを上げる
そのキーをはずすと ソレを下げる
idea from somewhere i forgot
credits to original inventor
-- yuku 2009-02-05
Get Adobe Flash player
by vasari 23 Jan 2010
    Embed
// forked from slonski's forked from: forked from: One-key Game
// forked from hacker_4zrkqbpm's forked from: One-key Game
// forked from yuku's One-key Game
package {
// cara main: TAHAN tombol kibod biar ITUnya naik
// LEPAS tombol biar ITUnya turun

// how to play: HOLD keyboard key to make IT ascend
// RELEASE the key to make IT descend

// 遊び方: どれかのキーを押したままで ソレを上げる
// そのキーをはずすと ソレを下げる

// idea from somewhere i forgot
// credits to original inventor
// -- yuku 2009-02-05

	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.display.StageQuality;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	[SWF(width=384, height=384, backgroundColor="#000000", frameRate=100)]

	public class entah1 extends Sprite
	{
		public function entah1()
		{
			addEventListener(Event.ENTER_FRAME, enterFrame);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, function() {du=-0.32});
			stage.addEventListener(KeyboardEvent.KEY_UP, function() {du=0.32});
			
			var a = new Bitmap();
			a.bitmapData = bmp;
			a.scaleX = a.scaleY=3
			addChild(a);
			
			stage.quality = StageQuality.BEST;

			t.defaultTextFormat = new TextFormat(null, 36, 0x8888dd);
			t.autoSize = TextFieldAutoSize.LEFT;
			t.text = 'any\nkey';
			addChild(t);
		}
		
		var score=0
		var bmp: BitmapData = new BitmapData(128, 128, false, 0);
		var di: Number = 128;
		var lebar: Number = 128;
		var gdi: Number = 0;
		var glebar: Number = 65;
		var t:TextField = new TextField();
		var mati=1
		var bangun=0
		
		function enterFrame(event) {
			if (!mati) {
				utik();
				jalan1();
				kapal();
				score += 1/lebar*10;
				t.autoSize = TextFieldAutoSize.LEFT;
				t.scaleX = t.scaleY = 1
				t.x=0
				t.filters=[]
				t.text = score.toFixed(0)
			} else {
				t.autoSize = TextFieldAutoSize.CENTER;
				t.x = 64*3-t.width/2
				t.scaleX = t.scaleY = 3
				t.filters=[new GlowFilter()];
				bangun--
				stage.addEventListener(KeyboardEvent.KEY_DOWN, unmati);
			}
		}

		function unmati(event) {
			if(bangun>0)return
			mati=0
			score=0
			di=64
			lebar=64
			u=64
			bmp.fillRect(bmp.rect,0)
			stage.removeEventListener(KeyboardEvent.KEY_DOWN, unmati);
		}
		
		function utik() {
			gdi += Math.random() / 2 - 1/4;
			if (gdi > 1 || gdi < -1) {
				gdi *= -0.7;
			}
			di<50? gdi=0.5:0;
			di>98? gdi=-0.5:0;
			
			glebar += Math.random() / 4 - 1/8;
			if (glebar > 3 || glebar < -3) {
				glebar *= -0.7;
			}
			if(lebar<9)glebar=0.3;
			if(lebar>40)glebar=-0.5;
			
			di += gdi;
			lebar += glebar;
		}
		
		function jalan1() {
			var atas: int = di - lebar;
			var bawah: int = di + lebar;
			//trace(di,gdi,lebar,glebar)
			
			for (var i = 0; i<127; i++) {
				bmp.copyPixels(bmp, new Rectangle(i+1, 0, 1, 128), new Point(i, 0));
			}
			
			// item
			bmp.fillRect(new Rectangle(127, 0, 1, 128), 0xff000000);
			
			// puti
			bmp.fillRect(new Rectangle(127, 0, 1, atas), 0xffffffff);
			bmp.fillRect(new Rectangle(127, bawah, 1, 128-bawah), 0xffffffff);
		}
		
		var p:Number=20;
		var u: Number = 64;
		var du: Number = 0.3;
		function kapal() {
			u+=du
			if (bmp.getPixel(p,u) == 0xffffff ||u<32||u>127) {
				mati=1 
				bangun=100
			}
			bmp.fillRect(new Rectangle(p-2, u-1,3,3), 0xffcc88);
			bmp.setPixel(p-2, u-1, 0xaaaa00);
			bmp.setPixel(p-2, u, 0xffff00);
			bmp.setPixel(p-2, u+1, 0xaaaa00);
			
		}
	}
}