WEB开发网
开发学院图形图像Flash 25行代码构造的AS3游戏 阅读

25行代码构造的AS3游戏

 2008-12-28 19:17:47 来源:WEB开发网   
核心提示:叫做Marius Heil的AS开发者使用AS3构造了一个25行代码的AS3游戏,并且获得了25行AS3代码编程大赛的第一名!/** * 25-Line ActionScript Contest Entry * * PRoject: SmilieBounce 25 * Author: Marius Heil * D

叫做Marius Heil的AS开发者使用AS3构造了一个25行代码的AS3游戏,并且获得了25行AS3代码编程大赛的第一名!

/**
 * 25-Line ActionScript Contest Entry
 * 
 * PRoject: SmilieBounce 25
 * Author: Marius Heil 
 * Date: 26.11.2008
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
 
// 3 free lines! Alter the parameters of the following lines or remove them.
// Do not substitute other code for the three lines in this section
[SWF(width=800, height=650, backgroundColor=0xffffff, frameRate=12)]
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// 25 lines begins here!
stage.addEventListener(KeyboardEvent.KEY_DOWN, function(e:KeyboardEvent){ root["key"+e.keyCode] = true;});
stage.addEventListener(KeyboardEvent.KEY_UP, function(e:KeyboardEvent){ root["key"+e.keyCode] = false; });
(this.field = addChild(new TextField())).text = this.backup = (this.field.type=(this.field.autoSize="left").substring(0, 0)+"input").substring(0, 0)+"鈥?=============================================================================================================================================鈥糪n鈥?                                                                                                                                             鈥糪n鈥?                                                                                                                                             鈥糪n鈥?                                                                                                   鈾櫕                                        鈥糪n鈥尖櫕鈾櫕鈾櫕鈾?                                                                                            鈻愨杸鈻?   楼     鈻  鈽?        鈻     鈭?         鈥糪n鈻鈻鈻鈻鈻鈻鈻鈻    鈭?                                                                                      鈻? 鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻            鈾櫕鈾櫕鈥糪n鈥?                                                                                                  鈻?                                    鈻鈻鈻鈻鈻鈥糪n鈥?                                                              鈻鈾櫕鈾櫕鈾櫕鈾櫕鈾櫕鈾櫕鈾櫕       鈭?      鈭?    鈻?                                         鈥糪n鈥?                 鈭?                                           鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻                     鈻?         鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻?       鈭?       鈥糪n鈥?                                                                                                  鈻?   鈻 鈽?  鈻?            鈻?                鈥糪n鈥?                                                                                                  鈻?   鈻鈻鈻鈻鈻鈻鈻             鈻愨杸鈻鈻鈻             鈥糪n鈥?             鈭?                                                                                   鈻?                       鈻?                鈥糪n鈥?                                                                鈾櫕鈾櫕 ^/\\^                         鈻? 鈽?           鈻        鈻?                鈥糪n鈥?      鈭?                                                        鈻鈻鈻鈻鈻鈻鈻鈻鈻                         鈻愨杸鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻        鈻?                鈥糪n鈥?                                     鈾櫕鈾櫕鈾? 鈾櫕鈾櫕鈾?                                                鈻?                       鈻?                鈥糪n鈥?                                     鈻鈻鈻鈻鈻  鈻鈻鈻鈻鈻                          鈻愨櫕鈻? /\\^/\\      ^/\\    鈻?            鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻?         鈭?     鈥糪n鈥尖櫕鈾櫕鈾?                                                                       鈻愨櫕鈻?/  \\  \\^^/\\//  \\^/\\鈻?                       鈻?                鈥糪n鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻                                                                   鈻愨櫕鈻?鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻        鈻?  鈭?        鈾櫕  鈥糪n鈥?       鈻                                                                   鈻愨櫕鈻?                   鈻?              鈻?       鈻?            鈾櫕  鈥糪n鈥?       鈻  楼   鈻 鈽?   鈻                                                     鈻愨櫕鈻?                   鈻?   鈻鈻鈻鈻鈻?     鈻?       鈻?            鈻鈻  鈥糪n鈥?       鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻                                                     鈻愨櫕鈻?                   鈻?鈾櫕鈾櫕鈾櫕鈾枑      鈻愨杸       鈻?                鈥糪n鈥?鈽?                        鈻鈻鈻鈻鈻鈻             鈾?                                                    鈻鈻鈻鈻鈻鈻鈻鈻鈻?     鈻?       鈻?                鈥糪n鈥?                                             螢螢                                                            鈻?     鈻?      鈻鈻?                鈥糪n鈥?                                                                鈾?                              /\\^         鈻鈻鈻   鈻?       鈻?                鈥糪n鈥?                                                   鈾櫕鈾?        螢螢螢螢                        鈻/\\^/  \\\\ 鈻    楼       鈻?       鈻?  鈼樷棙            鈥糪n鈥?                          鈻鈻鈻鈻鈻鈻鈻?     螢螢          ===                     鈻?              鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻        鈻?鈻鈻鈻鈻鈻鈻          鈥糪n鈥?        鈥尖紐~~~~~~鈥尖?            鈻?                                         鈻?                                             鈻鈻?        鈻       鈥糪n鈻鈻鈻鈻鈻鈻    鈥尖尖枒鈻戔枒鈻戔枒鈻戔枒鈥尖尖柆鈻柆鈻柆        鈻?/\\ /\\      ^/\\   /\\^ /\\ /\\       /\\^  /\\^鈻?                                              鈻?/\\ /\\   /\\ 鈾櫕   鈥糪n鈥尖櫕鈾?      鈥尖尖枒鈻戔枒鈻戔枒鈻戔枒鈥尖嘉炍炍炍炍?       鈻?  \\  \\^^/\\//  \\^/  \\^  \\  \\^^/\\^/  \\\\/  \\鈻?            鈽?            鈻                   鈻恀  \\  \\^/  \\鈾櫕/\\^鈥糪n鈥?========鈥尖尖尖尖尖尖尖尖尖尖?=========================================================================================================================鈥糪nSmilieBounce 25 with built in copy&replace editor ;-)\n\n[.:control:.]   [.:enemies:.]   [.:goal:.]   [.:have fun:.]\n     鈫憉p\n   鈫?  鈫?      鈻 楼鈻鈽?鈻~~鈻/\\鈻    鈼樷棙 & 鈾櫕      & do not cheat ;-)\n left  right    鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻鈻\n\n[.:score:.] ";
addEventListener(Event.ENTER_FRAME, function(){ replace("鈽?, "鈽?, true, Math.round(Math.random())*2-1, 0,    "楼", "楼", true, Math.round(Math.random())*2-1, 0,       "鈽?, "鈽?, root["key"+39], 1, 0,    "鈽?, "鈽?, root["key"+37], -1, 0,     "鈽?, "鈽?, true, 0, 1) });
function replace(...args) {
	var pos=this.field.text.indexOf("鈽?);
	if (this.jCount>0 && "鈾櫔鈽紐^\\/ ".indexOf(this.field.text.substring( (pos%145)+(Math.floor(pos/145)-1)*145 ,  (pos%145)+(Math.floor(pos/145)-1)*145 +1)) > -1) this.field.text = (((this.jCount = this.jCount -1)-this.jCount)+"").substring(0,0)+(this.field.text.substring(0,pos)+" "+this.field.text.substring(pos+1,this.field.text.length)).substring(0 ,聽(pos%145)+(Math.floor(pos/145)-1)*145)  +  "鈽?  +  (this.field.text.substring(0,pos)+" "+this.field.text.substring(pos+1,this.field.text.length)).substring((pos%145)+(Math.floor(pos/145)-1)*145 +1 , this.field.text.length聽 );// Neue x, y position berechnen
		else if ("鈾櫔鈽紐^\\/ ".indexOf(this.field.text.substring( (pos%145)+(Math.floor(pos/145)-1)*145 ,  (pos%145)+(Math.floor(pos/145)-1)*145 +1)) < 0) this.jCount=0;
	if (    ((this.field.x+(pos%145)*12) > 500 || (this.field.x+(pos%145)*12) < 300) && (this.field.x < 0 || ((this.field.x+(pos%145)*12)-400)*0.03 > 0) && (this.field.x > -930 || ((this.field.x+(pos%145)*12)-400)*0.03 < 0)   ) this.field.x -= ((this.field.x+(pos%145)*12)-400)*0.03;
	if(root["key"+16]) this.field.text = tempField = this.backup;
	var tempField:String=this.field.text;
	for (var j:int=0; j<args.length; j+=(this.pos=0)+5) {
		while( (this.pos = this.field.text.indexOf(args[j+0], this.pos+1)) > -1){
			var futChar = this.field.text.substring( (this.pos%145)+args[j+3]+(Math.floor(this.pos/145)+args[j+4])*145 ,  (this.pos%145)+args[j+3]+(Math.floor(this.pos/145)+args[j+4])*145 +1);
			if (   "鈾櫔鈽紐^ \\/".indexOf(this.field.text.substring( (pos%145)+(Math.floor(pos/145)+1)*145 ,  (pos%145)+(Math.floor(pos/145)+1)*145 +1)) < 0  &&  root["key"+38] && this.field.text.substring(this.pos,this.pos+1) == "鈽? ) this.jCount=5;
			if (  (args[j+2])  &&   "螄鈽悸モ樅~^ 鈾櫔/\\鈼?.indexOf(futChar) > -1  && (!this.jCount || args[j+4] != 1)) {
				tempField = (tempField.substring(0, this.pos) + " " + tempField.substring(this.pos+1, tempField.length));
				tempField = tempField.substring(0 ,聽(this.pos%145)+args[j+3]+(Math.floor(this.pos/145)+args[j+4])*145)  +  args[j+1]  +  tempField.substring((this.pos%145)+args[j+3]+(Math.floor(this.pos/145)+args[j+4])*145 +1 , tempField.length聽 );
				if ((this.field.text.substring(this.pos,this.pos+1) == "鈽? && "~楼鈽糬/\\".indexOf(futChar) > -1) || (futChar == "鈽? && "鈽悸^^/\\".indexOf(this.field.text.substring(this.pos,this.pos+1)) > -1)) this.field.text=tempField="\n            ______    __    __    ______  __    __   __\n           /  __  \\  |  |  |  |  /      ||  |  |  | |  |\n          |  |  |  | |  |  |  | |  ,----'|  |__|  | |  |\n          |  |  |  | |  |  |  | |  |     |   __   | |  |\n          |  `--'  | |  `--'  | |  `----.|  |  |  | |__|\n           \\______/   \\______/   \\______||__|  |__| (__)\n\n\n\n              +++++                               +++++\n            +#### ++                            +#### ++\n            +#     鈥?   You killed a lovely     +#     鈥糪n            |      鈥?   Smilie :-(              |      鈥糪n            | RIP  鈥?                           | RIP  鈥糪n            |      鈥?                           |      鈥糪n            |     #鈥?   Better Luck next Time   |     #鈥糪n            |    ##鈥?                           |    ##鈥糪n          +++######-++                        +++######-++\n         //.   **. //                        //. ,  .  //\n        //  掳 ****//                        //  掳   掳 //\n       // **   )(//                        /**. **   //\n      // ****   //   Smile again:         /******** //\n     //掳 .)( 掳 //                        // )( .)( //\n    /+________+/  Hit SHIFT for rebirth /+________+/\n   +----------+                        +----------+";
				if (this.field.text.substring(this.pos,this.pos+1)=="鈽?&&"鈾櫔".indexOf(futChar)>-1) tempField+="I";
				if (this.field.text.substring(this.pos,this.pos+1)=="鈽? && futChar == "鈼?) this.field.text=tempField ="                               .-.\n                              /.  \\\n                             (..   )\n                              \\   /\n               /\\              `-麓              /\\\n               \\/     ()      /掳麓掳\\      ()     \\/\n     (麓)  ()   /\\     /\\     / 麓掳掳掳\\     /\\     /\\   ()  (麓)\n      |\\  /\\  /掳掳\\   /麓麓\\   / 麓  掳掳掳\\   / 麓\\   /掳掳\\  /\\  /|\n      |麓\\/ 麓\\/掳麓掳麓\\ /麓 麓麓\\ /  麓 掳掳掳掳掳\\ /  麓麓\\ /掳掳+掳\\/ 麓\\/+|\n      |麓麓\\麓麓/掳掳麓掳掳掳\\麓 麓麓麓麓/  掳 麓掳掳掳掳掳掳\\麓 麓 麓麓/掳.掳...\\麓麓/##|\n      |麓 麓\\/掳掳 麓 掳掳掳\\麓麓麓麓/ 麓  掳麓麓麓掳掳掳掳掳\\ 麓麓麓/掳掳.+...#\\/+##|\n      |麓  掳掳掳  掳掳掳掳掳掳\\麓麓/   掳#######掳掳掳掳\\麓麓/掳掳......#.掳+#+|\n      |麓  麓麓 麓 掳掳 掳掳掳掳\\/掳掳##        ##掳掳掳\\/掳掳..掳.++.#.###.|\n      |麓  麓麓麓 掳掳掳掳掳掳掳掳掳掳#              #掳掳掳...掳掳掳掳掳....+++|\n      |  麓  麓麓 掳掳掳掳掳掳掳掳#    漏漏    漏漏    #掳掳.掳.掳掳掳.掳掳+#..++|\n      |   麓麓麓掳 掳掳掳掳+++#    漏漏漏漏  漏漏漏漏    #+++掳掳掳掳...+..掳.+|\n      |麓麓 麓麓麓掳掳掳掳+    #     漏漏    漏漏     #    +掳掳.掳掳掳+.#.+|\n      | 麓 麓麓掳掳掳掳+  漏 漏#                  #漏 漏  +掳掳掳掳掳.#掳#+|\n      | 麓 麓麓 掳掳+      #   **        **   #      +掳掳.+..掳#+|\n      |麓麓麓麓  掳掳掳+ *    #   **      **   #    * +掳掳掳.+#+.#+|\n      | 麓麓  掳掳掳掳掳+ *** +#    ******    #+ *** +掳掳掳掳#+掳##.+|\n      |麓 掳掳掳 掳掳掳掳掳掳+++掳掳掳掳##        ##掳掳掳掳+++掳掳掳掳掳+掳掳+掳掳#+|\n      |  CONGRATULATIONS!掳掳掳掳######掳掳掳YOU JUST FINISHED掳#.|\n     (+---------------------------------------------------+)\n    /掳麓 掳掳掳**_____*__**__*_____*_*掳**掳*_____*______** 麓  麓麓\\\n   /掳麓麓 *掳 */ ____|  \\/  |_   _| |*掳掳*|_   _|  ____|**麓麓*麓掳麓)\n  (*掳掳 掳 掳*| (___*| \\  / |*| |*| |*掳掳***| |*| |__ *掳掳 麓 麓掳麓掳 )\n   \\*麓***_**\\___ \\| |\\/| |*| |*| |******| |*|  __|*掳*掳掳掳**麓麓麓\\\n   (\\__ | |*____) | |**| |_| |_| |____*_| |_| |____ ***掳**掳掳 *)\n  /**麓**| ||_____/|_|_*|_|_____|______|_____|______|_____* 掳*/\n  (*麓麓掳*| '_ \\*/ _ \\| |*| |  _ \\*/ __/ _ \\***/ _  \\| ____| _/\n   |** *| |_) | (_) | |_| | |*| | (_|  __/*掳*|/*) /| |__** *掳)\n   (**麓*|_.__/*\\___/*\\__,_|_|*|_|\\___\\___|*掳掳**/ /*|___ \\* * |\n    \\** *麓麓*麓*掳***掳*掳掳掳**掳掳******掳掳掳掳掳****掳***/ /_**___) | **)\n     ( ***Wanna play again? Just Hit SHIFT***/_____|____/* */\n      \\____________________________________________________/\n\n           Final score (if you didn't cheat:D): "+(this.field.text.length-4581); }}
	this.field.text=tempField;}
	this.field.setTextFormat(new TextFormat("Lucida Console", 20, null, null, null, null, null, null, null, null, null, null, -3)); }
// 25 lines ends here!

Tags:代码 构造 AS

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接