<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FlashFuck.it &#187; contest</title>
	<atom:link href="http://www.flashfuck.it/tag/contest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flashfuck.it</link>
	<description>flash platform, gaming and 3D</description>
	<lastBuildDate>Mon, 23 Jan 2012 18:11:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>My entry to Bit-101s 25 Lines competition</title>
		<link>http://www.flashfuck.it/2008/11/30/my-entry-to-bit-101s-25-lines-competition/</link>
		<comments>http://www.flashfuck.it/2008/11/30/my-entry-to-bit-101s-25-lines-competition/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 13:45:08 +0000</pubDate>
		<dc:creator>pigiuz</dc:creator>
				<category><![CDATA[3D]]></category>
		<category><![CDATA[ActionScript 3]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player 10]]></category>
		<category><![CDATA[25lines]]></category>
		<category><![CDATA[contest]]></category>

		<guid isPermaLink="false">http://www.flashfuck.it/?p=101</guid>
		<description><![CDATA[Yep, i made my submission to 25lines contest just few days ago (right in time ), so (as Sakri did some days before me) I&#8217;m publishing my code. It&#8217;s an easy terrain generator&#8230; Actually, I think it can be somehow improved both in lines of code and actual performances, so feel free to edit or [...]]]></description>
			<content:encoded><![CDATA[<p>Yep, i made my submission to <a href="http://www.25lines.com/" target="_blank">25lines contest</a> just few days ago (right in time <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ), so (as <a href="http://www.sakri.net/blog/2008/11/19/my-entry-to-bit-101s-25-lines-competition/" target="_blank">Sakri did some days before me</a>) I&#8217;m publishing my code. It&#8217;s an easy terrain generator&#8230;</p>
<p><a href="http://www.flashfuck.it/wp-content/uploads/2008/11/25lines.jpg"></a></p>
<p style="text-align: center;"><a href="http://www.flashfuck.it/wp-content/uploads/2008/11/25linesbmpoptimized.swf" target="_blank"><img class="alignnone size-medium wp-image-102 aligncenter" title="25lines" src="http://www.flashfuck.it/wp-content/uploads/2008/11/25lines-300x300.jpg" alt="" width="300" height="300" /></a></p>
<p>Actually, I think it can be somehow improved both in lines of code and actual performances, so feel free to edit or tell me &#8220;you&#8217;d better to do that this other way&#8230;&#8221; <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>What&#8217;s going on is:</p>
<ul>
<li>generate a shape filled with a gradient to create a reference color for differents &#8220;height&#8221;</li>
<li>generate a perlinNoise everyframe for dataprovider use</li>
<li>detect each perlinNoise pixel depth according with its main channel value (blue in this case..)</li>
<li>generating a vector of Bitmaps to be employed in the view</li>
</ul>
<pre lang="actionscript">/**
 * 25-Line ActionScript Contest Entry
 *
 * Project: Random Terrain 3D Generator
 * Author:  Piergiorgio Niero (aka pigiuz) piergiorgio.niero[at]gmail.com
 * Date:    11/24/08
 *
 * 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=800, backgroundColor=0xffffff, frameRate=24)]
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
// 25 lines begins here!
var _bd:BitmapData = new BitmapData(50,50,false,0x0000FF);
var _points:Array = new Array(new Point());
var _vxCont:Sprite = Sprite(addChild(new Sprite));
_vxCont.x = _vxCont.y = 400;
var _vexels:Vector. = new Vector.((2500),true);
var _hMap:BitmapData = new BitmapData(255,1,false);
var _gradient:Shape = new Shape();
_gradient.graphics.beginGradientFill( GradientType.LINEAR,new Array( 0x4267F9, 0xF9EAB0, 0x9EF07D, 0x8DF273, 0x9D5E1E, 0xFFFFFF ),new Array( 1, 1, 1, 1, 1, 1 ),new Array( 90, 105, 110, 120, 145, 185 ),new Matrix(0.2456396484375,0,0,0.0006103524625,127.5,.5));
_gradient.graphics.drawRect(0,0,255,1);
_hMap.draw(_gradient);
addEventListener(Event.ENTER_FRAME,generatePerlinNoise);
function generatePerlinNoise(e:Event=null):void{
	_bd.perlinNoise(25,25,1,0,false,true,4,false,_points);
	Point(_points[0]).y+=1;
	for(var v:uint=0;v&amp;lt;(2500);v++){
		_vexels[v] = (_vexels[v]==null)?generateVoxel(v):_vexels[v];
		_vexels[v].y = Math.pow((_bd.getPixel(v%50,Math.floor((v/50))) &amp; 0xFF)/255*6,3)*24*.24;
		_vxCont.rotationX = mouseY*.1;
		_vxCont.rotationY = (_vxCont.rotationY-(90/stage.stageWidth*(mouseX-stage.stageWidth)+45))*.5;
		_vexels[v].bitmapData.floodFill(0,0,_hMap.getPixel(255-(_bd.getPixel(v%50,Math.floor((v/50))) &amp; 0xFF),0));}}
function generateVoxel(v:uint):Bitmap{
	var b:Bitmap = new Bitmap(new BitmapData(24*.5,24*.5,false,0x000000),"auto",false);
	b.x = v%50*24-(_bd.width*24*.5);
	b.z = Math.floor((v/50))*24-(_bd.height*24*.5);
	return Bitmap(_vxCont.addChild(b));}
// 25 lines ends here!

enjoy <img src='http://www.flashfuck.it/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.flashfuck.it/2008/11/30/my-entry-to-bit-101s-25-lines-competition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

