<?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>Minalien.com &#187; Web</title>
	<atom:link href="http://minalien.com/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://minalien.com</link>
	<description>Game Programming Weblog &#38; Portfolio</description>
	<lastBuildDate>Sat, 21 Jan 2012 23:05:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>HTML5 Jumper Game Conversion</title>
		<link>http://minalien.com/2011/05/html5-jumper-game-conversion/</link>
		<comments>http://minalien.com/2011/05/html5-jumper-game-conversion/#comments</comments>
		<pubDate>Sat, 14 May 2011 22:55:01 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[CoffeeScript]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://minalien.com/?p=56</guid>
		<description><![CDATA[I&#8217;ve just finished porting the code from an HTML5 tame tutorial (built in the style of Doodle Jump) to CoffeeScript out of a combination of boredom and an interest in getting used to CoffeeScript.
The tutorial can be found at  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just finished porting the code from an HTML5 tame tutorial (built in the style of Doodle Jump) to CoffeeScript out of a combination of boredom and an interest in getting used to CoffeeScript.</p>
<p>The tutorial can be found at <a href="http://michalbe.blogspot.com/2010/09/simple-game-with-html5-canvas-part-1.html">http://michalbe.blogspot.com/2010/09/simple-game-with-html5-canvas-part-1.html</a>. I&#8217;ve made only one real major change: Rather than using the mouse input (in his tutorial, onMouseMove), I&#8217;ve set it up to use keyboard events.</p>
<p>Play the final product: <a href="http://minalien.com/html5_jumper/">http://minalien.com/html5_jumper/</a><br />
Compiled JavaScript/HTML/CoffeeScript Source: <a href='http://minalien.com/wp-content/uploads/2011/05/Archive.zip'>CoffeeScript Jumper Game</a></p>
<p><em>(Read On to get CoffeeScript Source)</em><br />
<span id="more-56"></span></p>
<pre class="brush: coffee; title: CoffeeScript Source - game.coffee; notranslate">
state = true

# Player Class
class Player
	constructor: () -&gt;
		@image = new Image()
		@image.src = &quot;img/angel.png&quot;
		@width = 65
		@height = 95
		@X = 0
		@Y = 0
		@frames = 1
		@curFrame = 0
		@interval = 0
		@jumping = false
		@falling = false
		@jumpSpeed = 0
		@fallSpeed = 0

	setPosition: (x, y) -&gt;
		@X = x
		@Y = y

	draw: () -&gt;
		try
			context.drawImage @image, 0, @height * @curFrame, @width, @height, @X, @Y, @width, @height
		catch e

		if @interval == 4
			if @curFrame == @frames
				@curFrame = 0
			else
				@curFrame++

			@interval = 0

		@interval++

	jump: () -&gt;
		if !@jumping &amp;&amp; !@falling
			@fallSpeed = 0
			@jumping = true
			@jumpSpeed = 17

	checkJump: () -&gt;
		if @Y &gt; height * 0.4
			@setPosition @X, @Y - @jumpSpeed
		else
			points++ if @jumpSpeed &gt; 10

			MoveCircles @jumpSpeed * 0.5

			for platform, i in platforms
				do(platform, i) =&gt;
					platform.Y += @jumpSpeed

					if(platform.Y &gt; height)
						type = ~~(Math.random() * 5)
						if type is 0
							type = 1
						else
							type = 0

						platforms[i] = new Platform Math.random() * (width - platformWidth), platform.Y - height, type

		@jumpSpeed--;
		if @jumpSpeed == 0
			@jumping = false
			@falling = true
			@fallSpeed = 1

	checkFall: () -&gt;
		if @Y &lt; height - @height
			@setPosition @X, @Y + @fallSpeed
			@fallSpeed++
		else
			if points is 0
				@fallStop()
			else
				GameOver()

	fallStop: () -&gt;
		@falling = false
		@fallSpeed = 0
		@jump()

	moveLeft: () -&gt;
		if @X &gt; 0
			@setPosition @X - 5, @Y

	moveRight: () -&gt;
		if @X &lt; (width - @width)
			@setPosition @X + 5, @Y

	update: () -&gt;
		if @movingLeft
			@moveLeft()
		else if @movingRight
			@moveRight()

# Player Platform
class Platform
	constructor: (@X, @Y, @type) -&gt;
		@X = ~~@X
		@moving = ~~(Math.random() * 2)
		@direction = if ~~(Math.random() * 2) then -1 else 1

		if @type is 1
			@firstColor = '#AADD00'
			@secondColor = '#698B22'
		else
			@firstColor = '#FF8C00'
			@secondColor = '#EEEE00'

	onCollide: () -&gt;
		player.fallStop()

		if @type == 1
			player.jumpSpeed = 50

	draw: () -&gt;
		context.fillStyle = 'rgba(255, 255, 255, 1)'
		gradient = context.createRadialGradient @X + (platformWidth / 2), @Y + (platformHeight / 2), 5, @X + (platformWidth / 2), @Y + (platformHeight / 2), 45
		gradient.addColorStop 0, @firstColor
		gradient.addColorStop 1, @secondColor
		context.fillStyle = gradient
		context.fillRect @X, @Y, platformWidth, platformHeight

# Keyboard Input
OnKeyDown = (evt) -&gt;
	switch evt.keyCode
		# Left Arrow
		when 37 then player.movingLeft = true
		# Right Arrow
		when 39 then player.movingRight = true
		else break

OnKeyUp = (evt) -&gt;
	switch evt.keyCode
		# Left Arrow
		when 37 then player.movingLeft = false
		# Right Arrow
		when 39 then player.movingRight = false
		else break

# Move the Player
window.addEventListener 'keydown', OnKeyDown, true
window.addEventListener 'keyup', OnKeyUp, true

# Generate Platforms
GeneratePlatforms = () -&gt;
	pos = 0

	for zelda in [1..7]
		type = ~~(Math.random() * 5)

		if type is 0
			type = 1
		else
			type = 0

		platforms.push new Platform Math.random() * (width - platformWidth), pos, type

		if pos &lt; height - platformHeight
			pos += ~~(height / numPlatforms)

# Clear the Canvas
Clear = () -&gt;
	context.fillStyle = '#d0e7f9'
	context.beginPath()
	context.rect 0, 0, width, height
	context.closePath()
	context.fill()

# Draw &quot;Clouds&quot;
DrawCircles = () -&gt;
	for circle in circles
		do(circle) =&gt;
			context.fillStyle = 'rgba(255, 255, 255, ' + circle[3] + ')'
			context.beginPath()
			context.arc circle[0], circle[1], circle[2], 0, Math.PI * 2, true
			context.closePath()
			context.fill()

# Move &quot;Clouds&quot;
MoveCircles = (deltaY) -&gt;
	for circle in circles
		do(circle) =&gt;
			if circle[1] - circle[2] &gt; height
				circle[0] = Math.random() * width
				circle[2] = Math.random() * 100
				circle[1] = -circle[2]
				circle[3] = Math.random() / 2
			else
				circle[1] += deltaY

# Check Collisions
CheckCollision = () -&gt;
	for platform in platforms
		do(platform) =&gt;
			if player.falling and (player.X &lt; platform.X + platformWidth) and (player.X + player.width &gt; platform.X) and (player.Y + player.height &gt; platform.Y) and (player.Y + player.height &lt; platform.Y + platformHeight)
				platform.onCollide()

# Game Over
GameOver = () -&gt;
	state = false

	clearTimeout gLoop

	setTimeout GameOverLoop, 100

# Game Over Loop
GameOverLoop = () -&gt;
	Clear()
	context.fillStyle = &quot;Black&quot;
	context.font = &quot;10pt Arial&quot;
	context.fillText &quot;GAME OVER&quot;, width / 2 - 60, height / 2 - 50
	context.fillText &quot;YOUR RESULT: &quot; + points, width / 2 - 60, height / 2 - 30

# Game Loop
GameLoop = () -&gt;
	Clear()
	DrawCircles()

	player.checkJump() if player.jumping
	player.checkFall() if player.falling

	for platform, i in platforms
		do(platform, i) =&gt;
			if platform.moving
				if platform.X &lt; 0
					platform.direction = 1
				else if platform.X &gt; width - platformWidth
					platform.direction = -1

				platform.X += platform.direction * (i / 2) * ~~(points / 100)

		platform.draw()

	CheckCollision()

	player.update()
	player.draw()

	context.fillStyle = &quot;Black&quot;;
	context.fillText &quot;POINTS: &quot; + points, 10, height - 10

	if state is true
		gLoop = setTimeout GameLoop, 1000 / 50

## Game Code
# Game Canvas Setup
width = 320
height = 500
canvas = document.getElementById 'gameCanvas'
context = canvas.getContext '2d'

canvas.width = width
canvas.height = height

# Game Setup
gLoop = 0
points = 0

howManyCircles = 10
circles = []

circles.push([Math.random() * width, Math.random() * height, Math.random() * 100, Math.random() / 2]) for i in [1..howManyCircles]

numPlatforms = 7
platforms = []
platformWidth = 70
platformHeight = 20

player = new Player()
player.setPosition ~~((width - player.width) / 2), ~~((height - player.height) / 2)
player.jump()

GeneratePlatforms()

# Begin
GameLoop()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://minalien.com/2011/05/html5-jumper-game-conversion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight Password Generator</title>
		<link>http://minalien.com/2011/05/silverlight-password-generator/</link>
		<comments>http://minalien.com/2011/05/silverlight-password-generator/#comments</comments>
		<pubDate>Mon, 09 May 2011 03:18:45 +0000</pubDate>
		<dc:creator>Ken</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://minalien.com/?p=13</guid>
		<description><![CDATA[Well, since I wiped my site to get everything built back up (because my Linode was getting all finicky with me), I figured I should put some content back on the blog while I&#8217;m in the process of designing the layout pages for my portfolio and the rest of the content to be added to the site. And so  [...]]]></description>
			<content:encoded><![CDATA[<p>Well, since I wiped my site to get everything built back up (because my Linode was getting all finicky with me), I figured I should put some content back on the blog while I&#8217;m in the process of designing the layout pages for my portfolio and the rest of the content to be added to the site. And so here we have a password generator, written in C# for Silverlight 4. Enjoy &#8211; VS2010 Solution &amp; Source code available at <a title="http://files.minalien.com/PassGen.zip" href="http://files.minalien.com/PassGen.zip">http://files.minalien.com/PassGen.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://minalien.com/2011/05/silverlight-password-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

