<?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>devmag.org.za</title>
	<atom:link href="http://devmag.org.za/feed/" rel="self" type="application/rss+xml" />
	<link>http://devmag.org.za</link>
	<description>A game development magazine</description>
	<lastBuildDate>Tue, 21 Feb 2012 18:13:41 +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>So You Want to Crowd-Source Your Funding?</title>
		<link>http://devmag.org.za/2012/02/20/so-you-want-to-crowd-source-your-funding/</link>
		<comments>http://devmag.org.za/2012/02/20/so-you-want-to-crowd-source-your-funding/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:17:56 +0000</pubDate>
		<dc:creator>Dev.Mag</dc:creator>
				<category><![CDATA[Funding]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[business]]></category>
		<category><![CDATA[funding]]></category>
		<category><![CDATA[marketing]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4391</guid>
		<description><![CDATA[<br/>With Double Fine adventures just hitting the $2,000,000 when I started writing this article; I seem to notice that the Internet, or at least the parts I pay attention to, is abuzz with ‘Kickstarter fever.’ Now I am extremely happy about this since: I love Double Fine, don’t like publishers, and feel this can be <a href='http://devmag.org.za/2012/02/20/so-you-want-to-crowd-source-your-funding/'>[...]</a><h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2009/04/27/funding-for-start-ups-evaporating/' rel='bookmark' title='Funding for start-ups evaporating'>Funding for start-ups evaporating</a> <small>The recent economic recession, having mostly had little effect on...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<br/><div>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="platfrom_banner" src="http://devmag.org.za/blog/wp-content/uploads/2012/02/crowdfunding.png" alt="platfrom_banner" width="680" height="341" border="0" /></p>
<p>With Double Fine adventures just hitting the $2,000,000 when I started writing this article; I seem to notice that the Internet, or at least the parts I pay attention to, is abuzz with ‘Kickstarter fever.’ Now I am extremely happy about this since: I love Double Fine, don’t like publishers, and feel this can be the start of something great.</p>
<p><span id="more-4391"></span>But, I must caution people against thinking that they can crowd source millions of dollars. The reason I say this is because <a href="http://en.wikipedia.org/wiki/Double_Fine_Productions">Double Fine</a> has something unique. They have been around for 12 years, created one of the most celebrated cult hits, are making a game for a genre that is almost forgotten, and have two of the most famous people of that genre working on the game. Now that is a tall order to top!</p>
<h2 dir="ltr">What do you need to crowd-source a million dollars?</h2>
<p>This is a question I don’t have an exact answer to, nor does anyone I would imagine. But we can take a good look at the man who has done it. <a href="http://en.wikipedia.org/wiki/Tim_Schafer">Tim Schafer</a> has worked on adventure games since 1990 where he was a co-writer on <em>The Secret of Monkey Island</em>. Since then he has been the lead of <em>Full Throttle</em>, and <em>Grim Fandango</em>. And these days he is the founder/owner of Double Fine. In terms of social media he has: 5,400 likes on <a href="http://www.facebook.com/TimOfLegend">facebook</a>, has been circled 6,392 on <a href="https://plus.google.com/117564870844254304139/posts">Google+</a>, and finally 68,218 followers on <a href="http://twitter.com/TimOfLegend">twitter</a>. So if video games have celebrities I’m sure Tim is one of them.</p>
<p>The next is Double Fine; I have already stated the companies record. But they have one person I haven’t talked about yet. <a href="http://en.wikipedia.org/wiki/Ron_Gilbert">Ron Gilbert</a> is the creator of the point and click adventure game. Which is the genre of game that DF are crowd-sourcing the funds for. So think about this: they have two of the most celebrated developers of the genre, talk to the community with the same sincerity as an indie developer, did not ask, or expect a million dollars in funding, but now they have two.</p>
<h2 dir="ltr">The Kickstarter Fever</h2>
<p>The current developer that I am paying attention to with regards to crowd sourcing is <a href="http://en.wikipedia.org/wiki/Brian_Fargo">Brian Fargo</a>. Who by the <a href="http://www.rockpapershotgun.com/2012/02/16/brian-fargo-turning-to-kickstarter-for-wasteland-2">news</a> wants to make a sequel to <em><a href="http://en.wikipedia.org/wiki/Wasteland_(video_game)">Wasteland</a></em>. <em>Wasteland</em> came out in 1988 and may be viewed as the progenitor of the <em>Fallout</em> series. The reason why I am paying attention to Fargo is that he is say he needs exactly a million dollars; he also is somewhat of a prolific developer.</p>
<p>So why the attention to Fargo? That is simple; with all the Kickstarter fever in the air we need some judge of the make or break conditions it take to make a game using crowd funding. Fargo, I believe, is at the right point to see what those conditions are.</p>
<p>Since he is working on an old franchise with fans, which is one of those things that the fans would like to see again. So when it comes to reaching the million dollar mark I believe that this will be the test.</p>
<h2 dir="ltr">Learn from the indies</h2>
<p>Indie developers make some of the most awesome games, and on some of the tightest budgets. For example <em>World of Goo</em> was made on a budget of just <a href="http://venturebeat.com/2009/01/02/the-world-of-goo-became-one-of-the-indie-hits-of-2008/">$10,000</a>, and it was a phenomenal game. On the other hand Braid cost <a href="http://kotaku.com/5037392/jonathan-blow-says-he-spent-180000-on-braid">$180,000</a>. So indies have quite a diverse range of costs.</p>
<p>Recently I have seen almost unknown indies turn to Kickstarter for funding. Then there are indie developers asking just as little as a <a href="http://indiegames.com/2012/02/kinect_and_ipad_kickstarter_do.htm">$1,500</a> to get there game out. I will however point out that such Kickstarters are, mostly, funded by indie developers.</p>
<p>The moral behind the indies is that you need to have a small game that you can make, and that you don’t need a massive budget to do it. Well this may sound like advise in the opposite direction of this article it is in fact at the core of this article. Since developers want to make awesome games, and fans want to play them.</p>
<h2 dir="ltr">It’s a trap!</h2>
<p>The video game industry goes through ‘fads’. I clearly remember when everything was a: FPS, MMO, Social game, make for mobile devices. Now there might be the fad of we made a game using kickstarter. While it was stated earlier that there was a hope that this could be a viable future. There is still the caution of whether this is the correct choice for people to follow.</p>
<p><a href="http://devmag.org.za/blog/wp-content/uploads/2012/02/DFbudget.png"><img class="aligncenter size-full wp-image-4394" title="DFbudget" src="http://devmag.org.za/blog/wp-content/uploads/2012/02/DFbudget.png" alt="" width="518" height="395" /></a><br />
The reason I bring thing up is that Double Fine’s XBLA type games were each made using about $2,000,000 and they had received traditional publishing on those. And they have been great success. Taking <a href="http://www.gamasutra.com/view/news/39712/InDepth_Xbox_Live_Arcade_sales_analysis_December_2011.php?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+GamasutraNews+%28Gamasutra+News%29">some statistic</a> <em>Iron Brigade</em> (nee <em>Trenched</em> in the stats) sold 120,126 units. Which at about $15, variance given to the MSpoint costs, the game so far made $1,800,000.</p>
<p>So you don’t always have to go with crowd-funding. But publishers are publishers. And they don’t like taking big risks. So seek funding in the right way sometimes that might be a publisher</p>
<p>Developers as with almost every choice they make need to be careful not to fall into a trap. Whether that is using a publisher, crowd-funding, or using your savings. So if you decide that a crowd-funded project is the way to go. Be aware of the terms of the platform, and what <a href="http://www.gamasutra.com/view/news/40291/Equitybased_crowdfunding_platform_Gambitious_launching_next_month.php">new</a> ones there are.</p>
<h2 dir="ltr">Make a Game</h2>
<p>As a developer and designer I would advocate a model similar to what Double Fine has done. Say the minimum you need to get the project done; then apply a modular design of expansion. So say your core is a: “City management game” which you think will cost $100,000. Call it $150,000 on your initial funding to be safe. But you want it to have cities in the same world that can trade and so on. That feature requires you to have raised $300,000.</p>
<p>The reason I say this is that when people fund a game in this manner they know it might not get done. But you really want to get it done, and they really want to play it. Look at Minecraft how it has grown with its community and how integral that community has been to the development of the game.</p>
<p>So if you only get enough funding to make the first part of the game. Make that first part! Get people playing it tell them if more people buy it then you can continue development and you will implement that feature that they really want.</p>
<p>A Kickstarter is a great way to get a start, and then a closed beta for people who paid, and will pay, is a great way to make a game. Just remember to never close the doors for people who want to pay and be a part of your game!</p>
</div>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2009/04/27/funding-for-start-ups-evaporating/' rel='bookmark' title='Funding for start-ups evaporating'>Funding for start-ups evaporating</a> <small>The recent economic recession, having mostly had little effect on...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2012/02/20/so-you-want-to-crowd-source-your-funding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A guide for prospective game programmers</title>
		<link>http://devmag.org.za/2012/02/16/a-guide-for-prospective-game-programmers-bobby-anguelov/</link>
		<comments>http://devmag.org.za/2012/02/16/a-guide-for-prospective-game-programmers-bobby-anguelov/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 14:00:27 +0000</pubDate>
		<dc:creator>Dev.Mag</dc:creator>
				<category><![CDATA[Education]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[skills]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4359</guid>
		<description><![CDATA[<br/>While I was still deciding on a topic for this article, huge discussions (read arguments) started popping up in various game dev communities I followed, all based around the same theme: education http://altdevblogaday.com/2011/07/14/an-ai-curriculum/ http://altdevblogaday.com/2011/07/04/the-importance-of-a-balanced-gamedev-curriculum/ http://altdevblogaday.com/2011/05/09/thoughts-on-university-education/ There seems to be quite a lot of debate on what prospective game programmers should study as well as what <a href='http://devmag.org.za/2012/02/16/a-guide-for-prospective-game-programmers-bobby-anguelov/'>[...]</a><h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2009/08/12/latest-game-career-guide-challenge-results/' rel='bookmark' title='Latest Game Career Guide challenge results'>Latest Game Career Guide challenge results</a> <small>I&#8217;m going to assume you know about Game Career Guide...</small></li>
<li><a href='http://devmag.org.za/2011/01/29/top-skills-to-become-a-game-developer-what-south-african-developers-say/' rel='bookmark' title='Top skills to become a game developer: what South African developers say'>Top skills to become a game developer: what South African developers say</a> <small>South African game developers share what skills they think are...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="platfrom_banner" src="http://devmag.org.za/blog/wp-content/uploads/2012/02/header.png" alt="platfrom_banner" width="680" height="341" border="0" /></p>
<div>
<p>While I was still deciding on a topic for this article, huge discussions (read arguments) started popping up in various game dev communities I followed, all based around the same theme: education<span id="more-4359"></span></p>
<ul>
<li><a href="http://altdevblogaday.com/2011/07/14/an-ai-curriculum/">http://altdevblogaday.com/2011/07/14/an-ai-curriculum/</a></li>
<li><a href="http://altdevblogaday.com/2011/07/04/the-importance-of-a-balanced-gamedev-curriculum/">http://altdevblogaday.com/2011/07/04/the-importance-of-a-balanced-gamedev-curriculum/</a></li>
<li><a href="http://altdevblogaday.com/2011/05/09/thoughts-on-university-education/">http://altdevblogaday.com/2011/05/09/thoughts-on-university-education/</a></li>
</ul>
<div>There seems to be quite a lot of debate on what prospective game programmers should study as well as what current curricula should include. The most common questions still being asked by prospective game programmers are: “What do I need to study to become a game programmer?” and “What do I need to do to help me land a game industry job as a programmer?” It is these questions that I wish to address in this article.</div>
<div>I’m lucky enough to have been exposed to the enterprise software industry, the game industry as well as academia. Which I think gives me a broad perspective on what is required of potential game programmers as well as programmers in general. I do need to stress that this is just my own personal opinion and that this topic is quite a hotly debated one.</p>
<h2 dir="ltr">Game Programming is Hard!</h2>
<p>The first thing that I need to say is about game programming is that it is hard! It is by far one of the most challenging software development fields. As such, game programmers, and game developers in general, are a separate breed.</p>
<p>Game programmers are not in the industry for the money; game programmer salaries are usually quite a bit lower than those found in the enterprise space.</p>
<p>Nor do people become game programmers for the comfortable work environments; crunch time is an unfortunate fact of life in the game industry. During periods of crunch you are expected to work 60 to 80 hours a week for several weeks at a time.</p>
<p>Furthermore, the game industry can be rather unstable, layoffs and project cancellations are common as are employee burnouts. At GDC 2011, I was told the average lifetime of a game programmer in the industry is around 7 years. I don’t know how true that is, but it’s something that I can believe.</p>
<p>In addition to all this, the game industry is also notoriously difficult to get into, especially for fresh graduates.</p>
<p>Now I’m not trying to scare anyone away, but this is the truth of the industry. So why the hell would any sane person want to work as a game programmer? Well, the first and most important reason is simply passion.</p>
<p>Game programmers love what they do and would not want to do anything else. So far I’ve only mentioned the negatives of the industry, but game development is one of the most exciting, innovative, and personally rewarding industries in the software development field. Unlike the majority of enterprise development which is repetitive and mundane; there are always new challenges with each new project. Game programmers are by their nature problem solvers and thrive on the constant challenges that they are presented with. Personally, I cannot see myself ever working in enterprise software again.</p>
<p>From a technical perspective, game programming is extremely challenging. Game programmers are often tasked with the impossible; creating a high fidelity 3D virtual world with sounds and eveything else in 33 milliseconds or less. As such, game programming, particularly in the AAA space, tends to be extremely low level work. It requires that programmers be comfortable with concepts such as advanced mathematics, data structures, memory management, optimization techniques and a basic understanding of hardware and operating system architectures.</p>
<p>Programming isn’t something that can really be taught. Just like everything else in the world, programming requires a fair amount of natural talent and a brain that works well with concepts like math and logic. If you struggle with math, that’s probably a good sign that programming is probably not a good career choice for you. If that’s the case then don’t despair; there are numerous other non-programming positions in the game industry like game design, art, or production that may be more suited for your talents.</p>
<p>Now before I carry on with study options, let’s briefly discuss the various positions available within the game programming field. While generalist programming positions do exist, they are few and far between. The large majority of game programming positions are specialized within a single area of expertise such as: graphics, physics, AI, sound, tools, networking, etc.</p>
<p>So how are you, with no experience in any of these fields, supposed to choose one and specialize in it? How do you know that you will enjoy it or that you will be good at it? Well, I feel that you really shouldn’t make that choice without actually trying each of these sub-fields first.</p>
<h2 dir="ltr">What should I Study?</h2>
<p>The central point of this article is the “What should I study?” question.</p>
<p>Simply put, the answer is computer science. As with any other programming field, game programmers are expected to have completed at least a bachelor’s degree in computer science. Luckily computer science (CS) is a rather standard course which most universities will offer a degree in.</p>
<p>So why a CS degree? Because it will give you a great foundation in mathematics, programming and computer systems. As with any tertiary degree program; CS degrees will vary across universities and in most cases offer some degree of flexibility with regards to subject choices or specializations. At the very least a good computer science degree should cover the following fundamental subjects:</p>
<ul>
<li>Calculus</li>
<li>Linear Algebra</li>
<li>Discrete Mathematics</li>
<li>A C/C++ programming course</li>
<li>Data Structures</li>
<li>Design Patterns</li>
<li>Operating Systems</li>
<li>Software Engineering</li>
<li>Concurrency / Parallel Programming</li>
</ul>
<p>In addition to these fundamentals you will usually have a choice between specialization electives such as the following:</p>
<ul>
<li>Computer Graphics</li>
<li>Artificial Intelligence</li>
<li>Compiler Construction</li>
<li>Network Programming</li>
<li>Databases</li>
<li>Computer Security</li>
<li>Microprocessors</li>
</ul>
<p>In some cases, as in the US colleges, students will be presented with a single course called something along the lines of Computer Science 1, or Fundamentals of Computer Science, etc. These kinds of courses are usually a single semester or a year course that will act as an umbrella for several of the above courses. For example, the University of Cape Town (UCT) has such courses e.g. <a href="http://www.cs.uct.ac.za/teaching/undergraduate-courses">CSC1015</a> (Problem solving and algorithm development; object orientated program design using Java; number systems) whereas the University of Pretoria (TUKS) has separate modules for each topic (<a href="http://www.cs.up.ac.za/courses/list">http://www.cs.up.ac.za/courses/list</a>).</p>
<p>With so many options and varying degree programs; how should you choose what program to take? Well, my first piece of advice is to choose the computer science degree program which allows you to take the most math modules. This is good metric of the quality of the degree program. CS degrees that are light on math are usually of a low quality. So to reiterate, try to take as many math electives as you can, as they will be essential later on, especially for game programming.</p>
<p>Game programming is pretty much one large math problem. For example: computer graphics is heavily reliant on a good understanding of calculus and linear algebra; Artificial intelligence (AI) concepts are based on the first order logic covered in discrete math courses; other key computer science concepts like data structures, graph theory, combinatorics and sets are also covered in discrete math courses. Other math subjects like numerical methods, mathematical modeling and statistic will also be useful in your future career as a game programmer. If you have the choice and think you may be interested in physics programming; take a physics module or two as well. In addition to the standard course load, most colleges will let you take additional non degree subjects as well and you are also able to simply attend the lectures for other subjects without actually enrolling in them.</p>
<p>Now what about electives? Well, I’d advise taking all the C++ modules available and the compiler construction module. Furthermore choose a degree program which offers courses in computer graphics, AI, and networks. This may prove a bit tricky since, for example, computer graphics courses are not taught in a lot of computer science degrees in South Africa. Try to take electives that have similar fields in the game industry. They don’t have to be identical just similar enough. For example, network programming might not focus on creating game server but you will definitely learn about client/server architecture and much, much more. Past that, it’s your own choice to take what subjects seem interesting to you.</p>
<p>You need to think of college as an opportunity to be exposed to and experience as many different sub-fields as possible. Don’t think of college as place to specialize; especially not in an undergraduate degree. Think of that degree as an opportunity to learn more about yourself, your talents and your potential interests. Especially ones that you never knew you had! The only way to find out if you will enjoy something or have a knack for it is to try it so be smart and make full use of the opportunity college provides you.</p>
<p>In South Africa (and as far as I know the UK, Australia and Canada), we have a postgraduate honors degree, which is similar to a US master’s degree, in that it consists of multiple specialization modules (graphics, AI, etc.) as well as a mini-thesis. It is only a one year degree unlike the US masters which is two year but content wise, the degrees are quite similar. It is advisable that you do your honors as well if it is an option, once more giving you an opportunity to explore various fields.</p>
<p>Having a master’s degree or higher is not essential for the game industry, in fact I don’t think it really matters. I’m sure it helps but there are way more important things which I will discuss later on. Personally, I completed my master’s degree because it allowed me to spend two or more years researching a game oriented topic while also leaving me a lot of free time in which I could improve my skills, and do research on various other game programming topics I was interested in (animation, engine architectures, AI,) and most importantly learn more about the industry. This is a personal choice, and as I mentioned not really essential.</p>
<p>Once you’ve graduated with a CS degree and have hopefully had exposure to most of the various sub-fields present in the industry. You should also know more about your personal skill-set as well as which of those sub-fields you really enjoy working in. For example, early on in my degree I found out that I really hated things like networking and computer security but I really enjoyed AI and graphics. Conversely a friend of mine went in with a game dev, in his case graphics,  interest; did the security module and got hooked. He now works for one of the leading computer security firms in the world. That for me is the greatest selling point of doing a general computer science degree. The fact that in exploring various fields it might spark a passion for something that you never knew you had. Furthermore, a CS degree will quickly show you whether you are cut out to be a programmer or not.</p>
<h2 dir="ltr">Beware of the easy method</h2>
<p>Sometimes people say: “So yeah, computer science…  But wait, I just saw that ‘University XYZ’ is offering a course in ‘uber game programming’, wouldn’t that be a better option since it like says game programming and stuff?”<br />
In general, I’m skeptical of specialized degree programs, but they aren’t all bad. You just have to be careful and do your research before enrolling in such programs. Compare these programs with a standard computer science degree. If you notice a large discrepancy between the two programs (especially when it comes to math or C++ modules), be wary of those specialized degrees.</p>
<p>Recently, a local university, the University of the Witwatersrand (WITS), announced that they will be starting a <a href="http://www.wits.ac.za/academic/humanities/wsoa/digitalart/8828/undergraduate_courses.html">degree program in game design</a> (they state they have a game design and a game programming degree as well). This is in addition to another local university, the University of Cape Town (UCT), already having a <a href="http://www.cs.uct.ac.za/about-us/gamesFlyer%20-%202010.pdf">game programming /design degree program</a> as well. In the US there has been an explosion of colleges that are now offering specialized game development oriented programs, most notably: <a href="https://www.digipen.edu/">The Digipen Institute of Technology</a>, <a href="http://www.fullsail.edu/">Full Sail University</a> and <a href="http://www.scad.edu/">Savannah College of Art and Design</a>. It is important to note, that all of the above options are accredited universities and you will graduate with a bachelor’s degree.</p>
<p>On the other hand, there are also numerous “fly-by-night” online courses/college on game development available, such as <a href="http://www.gameversity.com/">viCampus</a>, <a href="http://www.gameinstitute.com/">GameInstitute</a> and <a href="http://www.train2game.com/">Train2Game</a>. There are some local options as well:  <a href="http://www.adcourses.co.za/">AD Courses</a>. My advice with this whole group of “colleges” and I use this word loosely, is to avoid them like the plague. You will often walk out of these “colleges”, after wasting a ton of money and time, with a diploma that isn’t worth the paper it’s printed on.</p>
<p>If you are serious about studying a specialized game development course, do so at an accredited university.</p>
<p>If you are still unsure about your choice, try to get hold of a game developer either via twitter or email and see if they are willing to give you some advice. In my experience, game devs are quite a friendly bunch and are more than willing to answer a few questions.</p>
</div>
<h2 dir="ltr">Portfolios and Side Projects</h2>
<p>Now to blow your mind! At the end of the day, what you studied is pretty irrelevant when it comes to getting a job in the game industry. Having a Ph.D. in ‘UBERGameProgamming’ is not going to make you a better candidate than some other guy with a high-school diploma that wrote a real-time ray tracer in his garage. The game industry is all about skills and being able to demonstrate those skills.</p>
<p>A degree is a great way to filter applicants but it is your portfolio that will get you an interview. If you have an outstanding academic record and nothing to show at the end of your studies apart from a degree, don’t expect a call back. Being a programmer; means it’s a lot harder to create an impressive portfolio than let’s say if you were an artist. So try to play around with things that interested you in your college class at home. If something in class caught your attention, go home and try it. First, it’s a great way to build up a portfolio of demos. Second, it’s the best way to actually understand a technique. I started a tiny tech blog to just keep track of all the things I’ve been mucking around with in my spare time and you know what, that tech blog has actually become my portfolio.</p>
<p>Remember that there are hundreds of other guys just like you that are applying for the same job, some of which probably have more impressive academic records than you or went to better schools than you. On paper these candidates look better so you need to make yourself stand out from the crowd and say: “screw my resume! This is who I am as an engineer!” Do something weird or unusual; show the company that you can think out of the box.  Don’t just fire up UDK and slap together another shooter mod and send that in.</p>
<p>It’s also not a good idea to hand in group projects or class assignments as portfolio pieces. Companies want to see what you can do and they want to see stuff that’s slightly more advanced than something that was made so that entire class was expected to be able to complete. College assignments are usually set so that the weaker students can still complete them to some degree and therefore make very bad benchmarks of your individual skills. Group assignments also allow you to claim greater credit than is actually due to you and so are usually disregarded.</p>
<p>Another problem, at least for me, was that I hadn’t specialized when I was looking for a job. I was doing my masters in AI yet I was teaching graphics. My blog is more graphics oriented than game AI and yet I was applying for AI positions. This was a point of confusion for most of the callbacks I got, and I got asked numerous times which field I preferred and why. If you know what you want to do, focus on that and tailor your portfolio with that in mind. So obviously, don’t do send in a ray tracer project for a networking position.</p>
<p>In the game industry, so far my experience is that talent is king. There are lots of amazingly talented game programmers that are self-taught and don’t have any college education (for various reasons). They didn’t get their jobs because of their education rather despite it. They got their jobs because of their skills, but I think if you asked them, the consensus would be that getting a college education is a good idea.</p>
<p>So now, taking all this into account, why did I spend such a long time discussing education if it’s not that relevant? Well, as I said your education won’t train you but what it will give you is a set of tools which you can then use to learn and improve.</p>
<p>The worst thing for me was seeing programmers spend a day trying to solve what is essentially an already solved problem. These programmers are so proud of their solution and are oblivious to the fact they’ve simply re-invented the wheel (usually their reinvented wheel is kind of squarish) and have wasted a massive amount of time doing so because they had gaps in their fundamental education and didn’t know a solution existed.</p>
<p>I often identify areas in my own background that are rather “swiss-cheesy” and so I try to fill them whenever I get a chance. For example, I never took a compiler construction course during my degree (I took microprocessors instead) and now that’s starting to bug me, so my next step is going to be reading up on compiler construction.</p>
<p>As a programmer your education will never end, there will always be things that you may not know and have yet to learn, new technologies to master and so on but it is essential that you know the fundamentals. Just like building a house, you need to ensure that the foundations are strong before you start building upon them. Just like a bad foundation will make a bad house, bad fundamentals will make a bad programmer.</p>
<p><em><br />
</em></p>
</div>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2009/08/12/latest-game-career-guide-challenge-results/' rel='bookmark' title='Latest Game Career Guide challenge results'>Latest Game Career Guide challenge results</a> <small>I&#8217;m going to assume you know about Game Career Guide...</small></li>
<li><a href='http://devmag.org.za/2011/01/29/top-skills-to-become-a-game-developer-what-south-african-developers-say/' rel='bookmark' title='Top skills to become a game developer: what South African developers say'>Top skills to become a game developer: what South African developers say</a> <small>South African game developers share what skills they think are...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2012/02/16/a-guide-for-prospective-game-programmers-bobby-anguelov/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Game Design: On Ideas</title>
		<link>http://devmag.org.za/2012/02/13/game-design-on-ideas/</link>
		<comments>http://devmag.org.za/2012/02/13/game-design-on-ideas/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 14:38:35 +0000</pubDate>
		<dc:creator>Dev.Mag</dc:creator>
				<category><![CDATA[Game Design]]></category>
		<category><![CDATA[game design]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4336</guid>
		<description><![CDATA[<br/>Often enough I have talked to people wanting to start making video games. And often enough they talk about making the next big game. I have to admire their enthusiasm, as it reminds me of a much younger me. But most often they say one thing which I can’t forgive. “I have this great idea.” <a href='http://devmag.org.za/2012/02/13/game-design-on-ideas/'>[...]</a><h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2009/08/31/minimised-game-design-for-indies/' rel='bookmark' title='Minimised game design for indies'>Minimised game design for indies</a> <small>When you sit down to write a book, one of...</small></li>
<li><a href='http://devmag.org.za/2009/08/20/your-ideas-dont-matter-much/' rel='bookmark' title='Your ideas don&#8217;t matter &#8230; much'>Your ideas don&#8217;t matter &#8230; much</a> <small>...</small></li>
<li><a href='http://devmag.org.za/2011/02/16/board-silly-tabletop-game-design/' rel='bookmark' title='Board Silly (Tabletop Game Design)'>Board Silly (Tabletop Game Design)</a> <small>Two Dev.Mag writers share their board game design experiences: conception,...</small></li>
<li><a href='http://devmag.org.za/2011/02/02/video-game-user-interface-design-diegesis-theory/' rel='bookmark' title='Video game user interface design: Diegesis theory'>Video game user interface design: Diegesis theory</a> <small>In this article, the Dave Russell introduces the basic concepts...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="platfrom_banner" src="http://devmag.org.za/blog/wp-content/uploads/2012/02/ideas.png" alt="platfrom_banner" width="680" height="341" border="0" /></p>
<div>Often enough I have talked to people wanting to start making video games. And often enough they talk about making the next big game. I have to admire their enthusiasm, as it reminds me of a much younger me. But most often they say one thing which I can’t forgive.</p>
<p>“I have this great idea.”</p>
<p>The number of times anyone in the industry has heard that must be innumerable. And I can understand why. There is vision and drive to make something awesome. The belief that this idea can be the next half-diablo-doom-craft. And wanting to be at the front of seeing that idea come to life is admirable.</p>
<p>Unfortunately, when you just start out trying to make video games, that great idea is worthless. Not necessarily because it is a bad idea, but because you lack the experience to take that idea from the vision in your head, to the reality that the fanboys drool over. This is because a great game comes down to how the ideas are executed in the game.</p></div>
<div>
<p><span id="more-4336"></span></p>
<div>
<p>To illustrate the difference between idea and execution: Take your favourite FPS, and the one that you hate. Play them. All FPSes have a similar base. A weapon to shoot with, movement, and enemies to shoot at. They have a whole bunch of ideas in common. What separates the two games you picked? Many things: the studio, publisher, budget, platform, and even era. They may some ideas that they share, but what separates them is how they were made.To push the idea point: Every person working on those games most likely had hundreds of ideas. People who play video games have ideas. After all isn’t that where you started? Wanting to work in video games after you played wonderful games and had your own ideas. Even the people who play only FIFA and Pro Evolution Soccer have ideas. Ideas are cheap.</p>
<p>But making something with ideas is not cheap. A game designer could make a great game and never have an original idea to add. This is because the best resource a game designer has is the passionate team they work with. The artists have an understanding of visual aesthetics that you do not. The programmers have an understanding of the computing limitations, and the feasibility to implement features that you do not. People who make games, play games. They also have ideas, and very often good ones, so as a designer it’s your job to listen to them and create the best game you can with the budget you have.</p>
<p>If you are just getting into game development (especially if you enter as a designer), then I doubt your first stop is making some big game. So start small. Take your idea. Examine it; dissect it and see what it is about at its core. I find the best way to do this is to describe your game in a single sentence.</p>
<p>As an exercise, let’s say you want to make a game about a unicorn that jumps on clouds of dreams, and it can shoot rainbows from its hooves to run faster, and shoot lightning from its horn to kill enemies for extra score. In a single sentence that would be “An action platformer”. You can elaborate and say “An action platformer with a unicorn as the main character”. In this case, the unicorn is a defining aspect of the game; it makes it different from Mario.</p>
<p>What does all this mean?</p>
<p>If you want to make games, start now, and start small. Focus on small manageable pieces that you can make. Make the platformer, then add the speed boost, then the attack. Build the game up in stages.</p>
<p>Keep your expectations realistic. Statistically games don’t make it big—failure is common. So if your game doesn’t make you the next <a href="http://en.wikipedia.org/wiki/Gabe_Newell">Gabe Newell</a>, don’t worry—even some of the greatest game studios release flops. You have just started on a road of learning how to make games.</p>
<p>In fact, I would recommend that you don’t release your first games for money, since you want as much  feedback to learn from. And the best way to do that is to make your game free, post it on forums and see what people think. Look chances are it wont be the best thing ever. It will have a mixture of good points and bad points. You should learn from those.</p>
<p>When starting out, your aim should be to make great stuff. But you should realise that you have to learn how to make the great stuff. So make games and see what happens. Some might be great, and some might be flops. In the end you learn from both, and often enough you can learn more from what went wrong than from what went right.</p>
</div>
</div>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2009/08/31/minimised-game-design-for-indies/' rel='bookmark' title='Minimised game design for indies'>Minimised game design for indies</a> <small>When you sit down to write a book, one of...</small></li>
<li><a href='http://devmag.org.za/2009/08/20/your-ideas-dont-matter-much/' rel='bookmark' title='Your ideas don&#8217;t matter &#8230; much'>Your ideas don&#8217;t matter &#8230; much</a> <small>...</small></li>
<li><a href='http://devmag.org.za/2011/02/16/board-silly-tabletop-game-design/' rel='bookmark' title='Board Silly (Tabletop Game Design)'>Board Silly (Tabletop Game Design)</a> <small>Two Dev.Mag writers share their board game design experiences: conception,...</small></li>
<li><a href='http://devmag.org.za/2011/02/02/video-game-user-interface-design-diegesis-theory/' rel='bookmark' title='Video game user interface design: Diegesis theory'>Video game user interface design: Diegesis theory</a> <small>In this article, the Dave Russell introduces the basic concepts...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2012/02/13/game-design-on-ideas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to design levels for a platformer</title>
		<link>http://devmag.org.za/2011/07/04/how-to-design-levels-for-a-platformer/</link>
		<comments>http://devmag.org.za/2011/07/04/how-to-design-levels-for-a-platformer/#comments</comments>
		<pubDate>Mon, 04 Jul 2011 21:16:41 +0000</pubDate>
		<dc:creator>Diorgo Jonkers</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Platform Game Design]]></category>
		<category><![CDATA[deisgm process]]></category>
		<category><![CDATA[level game design]]></category>
		<category><![CDATA[platform game design]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4310</guid>
		<description><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/>This article looks at the process of designing levels for a platformer: from the initial idea to the final playable level.<h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/01/18/11-tips-for-making-a-fun-platformer/' rel='bookmark' title='11 Tips for making a fun platformer'>11 Tips for making a fun platformer</a> <small>This article gives handy tips for designing and building a...</small></li>
<li><a href='http://devmag.org.za/2011/03/03/desktop-dungeons-design-analysis-part-1/' rel='bookmark' title='Desktop Dungeons: Design Analysis (Part 1)'>Desktop Dungeons: Design Analysis (Part 1)</a> <small>This is the first part of an in-depth look at...</small></li>
<li><a href='http://devmag.org.za/2011/03/23/desktop-dungeons-design-analysis-part-2/' rel='bookmark' title='Desktop Dungeons: Design Analysis (Part 2)'>Desktop Dungeons: Design Analysis (Part 2)</a> <small>In this second part of analyzing Desktop Dungeons, we look...</small></li>
<li><a href='http://devmag.org.za/2011/02/02/video-game-user-interface-design-diegesis-theory/' rel='bookmark' title='Video game user interface design: Diegesis theory'>Video game user interface design: Diegesis theory</a> <small>In this article, the Dave Russell introduces the basic concepts...</small></li>
<li><a href='http://devmag.org.za/2011/02/16/board-silly-tabletop-game-design/' rel='bookmark' title='Board Silly (Tabletop Game Design)'>Board Silly (Tabletop Game Design)</a> <small>Two Dev.Mag writers share their board game design experiences: conception,...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="platfrom_banner" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/platfrom_banner.png" border="0" alt="platfrom_banner" width="680" height="341" /></p>
<p>In a previous article, I gave you <em><a href="http://devmag.org.za/2011/01/18/11-tips-for-making-a-fun-platformer/">11 Tips for making a fun platformer</a></em>. That article had general tips that covered a wide range of game design tasks. This article looks specifically at the process of designing levels for a platformer. The process is a guideline and covers the steps from the initial idea to the final playable level.</p>
<p><span id="more-4310"></span>The article does not focus on scheduling. However, you do need to keep scheduling in mind when designing levels. The size of a level and the amount of resources it contains depend on the number of people working on it, and the time available to complete it.</p>
<h2>1. Choose a visual theme</h2>
<p>Choose a visual theme for the level. You can go with a predetermined, game-wide theme, such as ‘Forest’, ‘Ice’, ‘Lava’, or ‘Castle’. Or go for something more creative, such as ‘Steampunk Cloning Facility’, ‘Psychologist&#8217;s Nightmare’, or ‘Cupid&#8217;s Ice cream Parlour’. Ask everyone in the team for theme ideas.</p>
<h2>2. Make a list</h2>
<p>Make a list of everything you want the player to experience in the level. This includes what the player does, sees, learns, hears, and encounters. The list should include <em>specific items</em> and <em>general items</em>.</p>
<ul>
<li><strong>Specific items</strong> usually occur once in a level.</li>
<li><strong>General items</strong> occur more than once in a level.</li>
</ul>
<p>Throughout the article the term ‘item’ is used to refer to the items of a list. These items not only include game items (power-ups, keys, and doors), but also events (finding the first locked door), enemies, and game mechanics (double-jumping).</p>
<p>Write down how many times each general item occurs (for example, there could be 50 coins to collect in the level, or the player might need to defeat 10 swordsmen). These numbers are estimates, and they help you to determine the level&#8217;s difficulty. For example, there could be two Tough Trolls in level 1, but four Tough Trolls in level 2. Let everyone in the team contribute to the list.</p>
<p>The following examples are also used in the images later in this article:</p>
<p>Specific items:</p>
<ol>
<li>Meet first enemy.</li>
<li>Find first power-up.</li>
<li>Learn about double-jumping.</li>
<li>Learn about destructible environments.</li>
<li>Find first locked door.</li>
<li>Find first key to open the locked door.</li>
<li>Pull lever to activate the moving platform.</li>
</ol>
<p>General items:</p>
<ol>
<li>Foot soldier enemies (x30)</li>
<li>Gun turret enemies (x10)</li>
<li>Power-ups (x30)</li>
<li>Moving platforms (x3)</li>
<li>Locked doors (x2)</li>
<li>Keys (x2)</li>
</ol>
<h2>3. Make a rough layout</h2>
<p>Draw a very rough layout of the entire level. This layout should show the path that the player will take through the level. Think of it as designing the street layout of a city, but ignoring the buildings.</p>
<p>You may end up doing several layouts before you have one that you’re happy with. Usually, the reason for changing the layout is one or more of these:</p>
<ul>
<li>Some areas are too big or small.</li>
<li>Some lines are too straight and too long (i.e. boring).</li>
<li>The overall layout is too simple or too complex.</li>
<li>The overall layout looks uninteresting.</li>
</ul>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="3_rough_layout" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/3_rough_layout.png" border="0" alt="3_rough_layout" width="372" height="270" /></p>
<p style="text-align: center;"><em>An example of the rough layout of an entire level.</em></p>
<h2>4. Make rough sketches for the specific items</h2>
<p>Players will need to find each item in the list that you created in step 2 somewhere in the level. They might also find some items in the same area. Make rough sketches of each area in which the player will find the <strong>specific items</strong> in the list.</p>
<p>Use symbols to identify the various objects in the level, for example, <em>E</em> for ‘Enemy’, <em>P</em> for `Power-up’, and <em>K</em> for ‘Key’. Also make notes on the sketches.</p>
<p>Distinguish clearly between negative and positive space when you do the sketches. The negative spaces (white in the sketches) are the areas where the player can move, and the positive spaces (diagonal lines in the sketches) are things like floors, walls and platforms where the player cannot move.</p>
<p>These sketches help you focus on the layout of each small area, without having to worry about where they fit in the overall layout of the level. Think of it as focusing on designing a building and ignoring its location in the city.</p>
<p>You may make sketches for some or all of the general items, but it is not necessary. The general items are usually moved around when you design the detailed layout or play test the level, so they may end up in completely different areas than you originally planned.</p>
<p><strong>Examples of rough sketches</strong></p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item1" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item1.png" border="0" alt="4_item1" width="340" height="194" /></td>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item2" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item2.png" border="0" alt="4_item2" width="328" height="234" /></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 1: Meet first enemy.</em></td>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 2: Find first power-up.</em></td>
</tr>
<tr>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item3" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item3.png" border="0" alt="4_item3" width="340" height="264" /></td>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item4" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item4.png" border="0" alt="4_item4" width="340" height="226" /></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 3: Learn about double-jumping.</em></td>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 4: Learn about destructible environments.</em></td>
</tr>
<tr>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item5" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item5.png" border="0" alt="4_item5" width="337" height="229" /></td>
<td width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item6" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item6.png" border="0" alt="4_item6" width="357" height="243" /></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 5: Find first locked door.</em></td>
<td style="text-align: center;" width="340" valign="top"><em>Specific item 6: Find first key to open the locked door.</em></td>
</tr>
</tbody>
</table>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="4_item7" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/4_item7.png" border="0" alt="4_item7" width="265" height="260" /></p>
<p style="text-align: center;"><em>Specific item 7: Pull lever to activate the moving platform.</em></p>
<h2>5. Make a detailed layout</h2>
<p>Draw a detailed layout of the level. The detailed layout uses the rough layout (from step 3) as a guideline. It includes all the specific items (copying the rough sketches from the previous step) and the general items. When you copy the rough sketches of the specific items, you may need to change them slightly (for example, change the size, flip it horizontally).</p>
<p>Place as many of the general items in the detailed layout as you can. You can add the remaining general items when you build the level using a level editor.</p>
<p>When you place the items, keep in mind the path that the player will take through the level. Certain items may need to be placed in a specific order, such as a weapon being placed somewhere before the player encounters the first enemy.</p>
<p><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="5_layout_big" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/5_layout_big.png" border="0" alt="5_layout_big" width="600" height="484" /></p>
<p style="text-align: center;"><em>An example of a detailed layout.</em></p>
<p><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="5_layout_items_big" src="http://devmag.org.za/blog/wp-content/uploads/2011/07/5_layout_items_big.png" border="0" alt="5_layout_items_big" width="600" height="484" /></p>
<p style="text-align: center;"><em>The locations of the specific items on the detailed layout. </em></p>
<h2>6. Build the initial layout</h2>
<p>Use a level editor to build the level&#8217;s initial layout, using the detailed layout (from the previous step) as a blueprint. You may need to change the sizes of some areas when you build the level. This happens because the layout sketch is usually not drawn exactly to scale. Also use the editor to add all the outstanding general items to the level. For example, your list might contain 20 enemies, but the detailed layout has only 15 enemies. Add the remaining 5 at this stage.</p>
<p>First build the initial layout before you add the visual details. In other words, use limited graphics for the initial layout, to make it easy to change things if you need to. For example, if you have five grass images, use only one for the initial layout. You can add the other four in step 8 when you decorate the level.</p>
<p>At this point the final graphics for the level may be incomplete, in which case you can use placeholder graphics. It is a good idea if the placeholder graphics have similar colours to those of the final graphics, because the colours affect the feel of the level.</p>
<h2>7. Play the level</h2>
<p>The initial layout is for playing the level, so that you can determine if it is fun and how long it will take to play through the level. Play the level and change the layout until is it fun and balanced. Let other people play it as well.</p>
<p>Changing the layout may include the following:</p>
<ol>
<li>Move, add. or delete platforms to make jumps easier or more challenging.</li>
<li>Move, add, or delete power-ups to balance the amount available.</li>
<li>Move, add, or delete enemies to make the level easier or more challenging.</li>
</ol>
<p><strong>Important note:</strong> By the time you design and build your first level, you should already have prototyped and finalized the gameplay mechanics using temporary test levels. If your gameplay has not been finalised by this time, then you risk having to change your levels when the gameplay changes. For example, if you decide to make the player jump higher, then you will have to move many platforms to accommodate the new jump height. Changing fundamental gameplay usually has a ripple effect.</p>
<h2>8. Decorate the level</h2>
<p>Once you’re happy with the level&#8217;s layout and once it’s fun to play, then add the details. This includes adding all the final graphics and audio. Play the level again to make sure that it still feels the same – or better – after all the graphics have been added. There’s a good chance that the level will feel different. It should feel better with the final graphics, but sometimes it may feel worse. For example, the placeholder background might have been a single colour, but the final background might be a detailed image that makes it difficult to see the enemies, in which case you will have to tone down the background or change the enemies, whichever will be quicker.</p>
<h2>Further Reading</h2>
<p><em>Super Mario Brothers 3 &#8211; Level Design Lessons</em> (Radek Koncewicz)</p>
<ul>
<li><a href="http://www.significant-bits.com/super-mario-bros-3-level-design-lessons" target="_blank">http://www.significant-bits.com/super-mario-bros-3-level-design-lessons</a></li>
<li><a href="http://www.significant-bits.com/super-mario-bros-3-level-design-lessons-part-2" target="_blank">http://www.significant-bits.com/super-mario-bros-3-level-design-lessons-part-2</a></li>
</ul>
<p><em>Level Design Lessons</em> (Anna Anthropy)</p>
<ul>
<li><a href="http://www.auntiepixelante.com/?p=1022" target="_blank">Low Overhead</a></li>
<li><a href="http://www.auntiepixelante.com/?p=465" target="_blank">To the Right, Hold on Tight</a></li>
<li><a href="http://www.auntiepixelante.com/?p=459" target="_blank">In the Pyramid</a></li>
</ul>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/01/18/11-tips-for-making-a-fun-platformer/' rel='bookmark' title='11 Tips for making a fun platformer'>11 Tips for making a fun platformer</a> <small>This article gives handy tips for designing and building a...</small></li>
<li><a href='http://devmag.org.za/2011/03/03/desktop-dungeons-design-analysis-part-1/' rel='bookmark' title='Desktop Dungeons: Design Analysis (Part 1)'>Desktop Dungeons: Design Analysis (Part 1)</a> <small>This is the first part of an in-depth look at...</small></li>
<li><a href='http://devmag.org.za/2011/03/23/desktop-dungeons-design-analysis-part-2/' rel='bookmark' title='Desktop Dungeons: Design Analysis (Part 2)'>Desktop Dungeons: Design Analysis (Part 2)</a> <small>In this second part of analyzing Desktop Dungeons, we look...</small></li>
<li><a href='http://devmag.org.za/2011/02/02/video-game-user-interface-design-diegesis-theory/' rel='bookmark' title='Video game user interface design: Diegesis theory'>Video game user interface design: Diegesis theory</a> <small>In this article, the Dave Russell introduces the basic concepts...</small></li>
<li><a href='http://devmag.org.za/2011/02/16/board-silly-tabletop-game-design/' rel='bookmark' title='Board Silly (Tabletop Game Design)'>Board Silly (Tabletop Game Design)</a> <small>Two Dev.Mag writers share their board game design experiences: conception,...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/07/04/how-to-design-levels-for-a-platformer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Implementing and Debugging the Perlin Noise Algorithm</title>
		<link>http://devmag.org.za/2011/06/25/implementing-and-debugging-the-perlin-noise-algorithm/</link>
		<comments>http://devmag.org.za/2011/06/25/implementing-and-debugging-the-perlin-noise-algorithm/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 21:00:32 +0000</pubDate>
		<dc:creator>Herman Tulleken</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[implementation]]></category>
		<category><![CDATA[perlin noise]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4239</guid>
		<description><![CDATA[<br/>One of the most visited articles on our site – How to Use Perlin Noise in Your Games – also caused the most problems. The pseudo-code contained an alarming number of bugs (one of the nastier ones is depicted above), which made it difficult to implement. Readers pointed out these in the comments, and so <a href='http://devmag.org.za/2011/06/25/implementing-and-debugging-the-perlin-noise-algorithm/'>[...]</a><h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2009/04/25/perlin-noise/' rel='bookmark' title='How to Use Perlin Noise in Your Games'>How to Use Perlin Noise in Your Games</a> <small>(Originally appeared in Dev.Mag Issue 20, released in February 2008.)...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_header2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_header2.png" border="0" alt="perlin_header2" width="680" height="340" /> One of the most visited articles on our site – <em><a href="http://devmag.org.za/2009/04/25/perlin-noise/">How to Use Perlin Noise in Your Games</a></em> – also caused the most problems. The pseudo-code contained an alarming number of bugs (one of the nastier ones is depicted above), which made it difficult to implement. Readers pointed out these in the comments, and so helped to make the pseudo-code progressively more correct. But even so, some operations remained unclear, so that I finally decided to replace the pseudo-code with real and tested code. I really hope that all bugs have now been squashed!</p>
<p>In the spirit of this extermination effort, this article gives some pointers to get a version of the algorithm up and running as quickly as possible. It is an extension of the original Perlin noise article, and refers to the code now presented there.</p>
<p><span id="more-4239"></span><span style="font-size: 20px; font-weight: bold;">Common Errors</span></p>
<p>Some mistakes that are easy to make:</p>
<ul>
<li>Swapping rows and columns, and widths and heights.</li>
<li>Confusing floating point values (in the range 0 to 1) with byte values (in the range 0 to 255). One symptom of this is black images.</li>
<li>An error in the interpolation.</li>
<li>Sampling the wrong points.</li>
<li>Inverting octaves (highest for lowest, and so on).</li>
</ul>
<p>The following tips will help you avoid these errors, and help track them down faster when they occur.</p>
<h2>Implementation Tips</h2>
<h3>1. Use a non-square image to test</h3>
<p>One of the easiest mistakes to make is to swap around widths and heights, or x and y coordinates. Using non-square images will help you detect these errors faster.</p>
<h3>2. Implement linear interpolation first</h3>
<p>Only once you have this working, you can try other interpolation schemes (such as cosine interpolation). This way there is less risk that the interpolation algorithm is wrong and throws you off the track.</p>
<h3>3. Save interim images to file</h3>
<p>The smooth noise images are a valuable aid in finding bugs. If they don’t look the way they are supposed to, you know something is wrong. (Below I give some typical examples).</p>
<h2>When Things Go Wrong</h2>
<p>If you get different results from what you expect, here are some things you can try to help you find the error faster:</p>
<h3>1. Check your smooth noise images</h3>
<p>Here is how they are supposed to look for different octaves and <strong>linear interpolation</strong>:</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise0" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise0.png" border="0" alt="smoothNoise0" width="256" height="128" /><em>Octave 0</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise1" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise1.png" border="0" alt="smoothNoise1" width="256" height="128" /><em>Octave 1</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise2.png" border="0" alt="smoothNoise2" width="256" height="128" /><em>Octave 2</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise3" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise3.png" border="0" alt="smoothNoise3" width="256" height="128" /><em>Octave 3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise4" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise4.png" border="0" alt="smoothNoise4" width="256" height="128" /><em>Octave 4</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise5" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise5.png" border="0" alt="smoothNoise5" width="256" height="128" /> <em>Octave 5</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise6" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise6.png" border="0" alt="smoothNoise6" width="256" height="128" /> <em>Octave 6</em></td>
<td width="340" valign="top"></td>
</tr>
</tbody>
</table>
<p>Here is how they are supposed to look for different octaves and <strong>cosine interpolation</strong>:</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise0" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise01.png" border="0" alt="smoothNoise0" width="256" height="128" /> <em>Octave 0</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise1" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise11.png" border="0" alt="smoothNoise1" width="256" height="128" /> <em>Octave 1</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise21.png" border="0" alt="smoothNoise2" width="256" height="128" /> <em>Octave 2</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise3" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise31.png" border="0" alt="smoothNoise3" width="256" height="128" /> <em>Octave 3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise4" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise41.png" border="0" alt="smoothNoise4" width="256" height="128" /> <em>Octave 4</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise5" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise51.png" border="0" alt="smoothNoise5" width="256" height="128" /> <em>Octave 5</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="smoothNoise6" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/smoothNoise61.png" border="0" alt="smoothNoise6" width="256" height="128" /><em>Octave 6</em></td>
<td width="340" valign="top"></td>
</tr>
</tbody>
</table>
<h3>2. Check other variables of the smooth noise function by writing them into images</h3>
<h4>a. Check the blend factors</h4>
<p>Modify the smooth noise algorithm to save the vertical and horizontal blend factors to an image, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">float</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> GenerateSmoothNoise<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">float</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> baseNoise, <span style="color: #6666cc; font-weight: bold;">int</span> octave<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
   <span style="color: #008000;">...</span>
&nbsp;
   <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> width<span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
   <span style="color: #008000;">&#123;</span>
      <span style="color: #008000;">...</span>
&nbsp;
      <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> height<span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
      <span style="color: #008000;">&#123;</span>
         <span style="color: #008000;">...</span>
&nbsp;
         <span style="color: #008080; font-style: italic;">////////////////////  Changed for debugging</span>
         <span style="color: #008080; font-style: italic;">//smoothNoise[i][j] = Interpolate(top, bottom, vertical_blend);</span>
         smoothNoise<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> horizontal_blend<span style="color: #008000;">;</span>
      <span style="color: #008000;">&#125;</span>
   <span style="color: #008000;">&#125;</span>
&nbsp;
   <span style="color: #008080; font-style: italic;">////////////////////  Added for debugging</span>
   SaveImage<span style="color: #008000;">&#40;</span>smoothNoise, <span style="color: #666666;">&quot;horizontal_blend&quot;</span> <span style="color: #008000;">+</span> octave <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;.png&quot;</span><span style="color: #008000;">&#41;</span>
&nbsp;
   <span style="color: #0600FF; font-weight: bold;">return</span> smoothNoise<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>For different octaves, you should get a series of ramps from black to white.</p>
<p>For vertical_blend:</p>
<table border="0" cellspacing="0" width="677">
<tbody>
<tr>
<td style="text-align: center;" width="356" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend0" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend0.png" border="0" alt="vertical_blend0" width="256" height="128" /> <em>Octave 0</em></td>
<td style="text-align: center;" width="346" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend2.png" border="0" alt="vertical_blend2" width="256" height="128" /> <em>Octave 1</em></td>
</tr>
<tr>
<td style="text-align: center;" width="356" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend21.png" border="0" alt="vertical_blend2" width="256" height="128" /> <em>Octave 2</em></td>
<td style="text-align: center;" width="346" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend3" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend3.png" border="0" alt="vertical_blend3" width="256" height="128" /> <em>Octave 3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="356" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend4" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend4.png" border="0" alt="vertical_blend4" width="256" height="128" /> <em>Octave 4</em></td>
<td style="text-align: center;" width="346" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend5" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend5.png" border="0" alt="vertical_blend5" width="256" height="128" /> <em>Octave 5</em></td>
</tr>
<tr>
<td style="text-align: center;" width="356" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="vertical_blend6" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/vertical_blend6.png" border="0" alt="vertical_blend6" width="256" height="128" /> <em>Octave 6</em></td>
<td width="346" valign="top"></td>
</tr>
</tbody>
</table>
<p>For horizontal_blend:</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend0" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend0.png" border="0" alt="horizontal_blend0" width="256" height="128" /> <em>Octave 0</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend1" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend1.png" border="0" alt="horizontal_blend1" width="256" height="128" /> <em>Octave 1</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend2.png" border="0" alt="horizontal_blend2" width="256" height="128" /> <em>Octave 2</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend3" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend3.png" border="0" alt="horizontal_blend3" width="256" height="128" /> <em>Octave 3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend4" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend4.png" border="0" alt="horizontal_blend4" width="256" height="128" /> <em>Octave 4</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend5" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend5.png" border="0" alt="horizontal_blend5" width="256" height="128" /> <em>Octave 5</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="horizontal_blend6" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/horizontal_blend6.png" border="0" alt="horizontal_blend6" width="256" height="128" /> <em>Octave 6</em></td>
<td width="340" valign="top"></td>
</tr>
</tbody>
</table>
<h4><span style="font-weight: bold;">b. Check your sample points</span></h4>
<p>Save sample points in an image, by modifying the same line as above to this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">////////////////////  Changed for debugging</span>
<span style="color: #008080; font-style: italic;">//smoothNoise[i][j] = Interpolate(top, bottom, vertical_blend);</span>
smoothNoise<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> baseNoise<span style="color: #008000;">&#91;</span>sample_i0<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#91;</span>sample_j0<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span></pre></div></div>

<p>Do the same for <code>baseNoise[sample_i1][sample_j0]</code> and <code>baseNoise[sample_i0][sample_j1]</code>, then compare them (it is only necessary to compare one octave – choose one that is easy to see). They should all be the same, except that they are translated by the sample period, as shown below:</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="samplei0j05" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/samplei0j05.png" border="0" alt="samplei0j05" width="256" height="128" /> <em>i0 j0</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="samplei1j05" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/samplei1j05.png" border="0" alt="samplei1j05" width="256" height="128" /> <em>i1 j0 (The same as i0 j0, but translated to the left)</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="samplei0j15" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/samplei0j15.png" border="0" alt="samplei0j15" width="256" height="128" /> <em>i0 j1 (The same as i0 j0, but translated to the top)</em></td>
<td width="340" valign="top"></td>
</tr>
</tbody>
</table>
<h3>3. Check that your smooth noise is blended correctly</h3>
<ul>
<li>Change your base noise to pure white. The resulting image should also be pure white.</li>
<li>Change your base noise to pure black. The resulting image should also be pure black.</li>
<li>Check your resulting Perlin noise for different persistence values.</li>
</ul>
<p>Here is how the images look for different persistent values and <strong>linear interpolation</strong>.</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.1</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise1.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise2.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.5</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise3.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.7</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise4.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.9</em></td>
<td width="340" valign="top"></td>
</tr>
</tbody>
</table>
<p>Here is how the images look for different persistent values and <strong>cosine interpolation</strong>.</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise5.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.1</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise6.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.3</em></td>
</tr>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise7.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.5</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise8.png" border="0" alt="perlin_noise" width="256" height="128" /> <em>Persistence = 0.7</em></td>
</tr>
<tr>
<td width="340" valign="top">
<p style="text-align: center;"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="perlin_noise" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/perlin_noise9.png" border="0" alt="perlin_noise" width="256" height="128" /><em>Persistence = 0.9</em></p>
</td>
<td width="340" valign="top">&nbsp;</p>
<p>&nbsp;</td>
</tr>
</tbody>
</table>
<h2><span style="font-size: 13px; font-weight: normal;">If you have any more implementation or debugging tips to share, please let us know in the comments!</span></h2>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2009/04/25/perlin-noise/' rel='bookmark' title='How to Use Perlin Noise in Your Games'>How to Use Perlin Noise in Your Games</a> <small>(Originally appeared in Dev.Mag Issue 20, released in February 2008.)...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/06/25/implementing-and-debugging-the-perlin-noise-algorithm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>B&#233;zier Path Algorithms</title>
		<link>http://devmag.org.za/2011/06/23/bzier-path-algorithms/</link>
		<comments>http://devmag.org.za/2011/06/23/bzier-path-algorithms/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 19:56:41 +0000</pubDate>
		<dc:creator>Herman Tulleken</dc:creator>
				<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[bezier curve]]></category>
		<category><![CDATA[bezier path]]></category>
		<category><![CDATA[curve length]]></category>
		<category><![CDATA[interpolation]]></category>
		<category><![CDATA[sampling]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4247</guid>
		<description><![CDATA[<br/>This tutorial provides some algorithms useful for working with Bézier curves: determining the length of a piece of curve; interpolating a set of points with a Bézier path; and reducing a large point set to a smooth Bézier curve.<h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/' rel='bookmark' title='B&eacute;zier Curves for your Games: A Tutorial'>B&eacute;zier Curves for your Games: A Tutorial</a> <small>A Bézier curve is a type of curve that is...</small></li>
<li><a href='http://devmag.org.za/2009/06/07/the-path-demo-is-out/' rel='bookmark' title='The Path demo is out!'>The Path demo is out!</a> <small>The Path is one of those videogames that just keeps...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<br/><p><img class="aligncenter size-full wp-image-4248" title="bezier" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/bezier.png" alt="" width="680" height="340" /></p>
<p>In the article <em><a href="http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/">Bézier Curves for your Games: A Tutorial</a>,</em> I introduced Bézier curves and Bézier paths. In this tutorial I provide some algorithms useful for working with Bézier curves: determining the length of a piece of curve; interpolating a set of points with a Bézier path; and reducing a large point set to a smooth Bézier curve. (Image by <a href="http://www.flickr.com/photos/snuffythebear/">snuffyTHEbear</a>).</p>
<h2><span id="more-4247"></span>Calculating curve length</h2>
<p>Assuming that the line segments we use for drawing are a reasonable representation of our curve, we can estimate the curve length by summing the lengths of the segments. These can be added together to get the length of a Bézier path.</p>
<p>A more complicated strategy is necessary when we need the length of only a part of the curve, and not the complete curve.</p>
<p>First, we must cache the <em>accumulative</em> length of segments when we update the drawing points. For example, if the lengths of the first three segments of a curve are 2, 3 and 1, the accumulative lengths are 2, 5, and 6.</p>
<p>Then, we can use a simple subtraction to find the length of the piece of the curve (assuming, for a moment, that we need it only between points that coincide with the drawing points). For example, to find the length of curve between drawing points 5 and 8, we do the following calculation:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">accumulativeLength<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">8</span><span style="color: #008000;">&#93;</span> – accumulativeLength<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">5</span> – <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #008080; font-style: italic;">//wrong</span></pre></div></div>

<p>Note that we subtract 1 from the smaller index. To prevent us from having to handle a special case, we can start the accumulative lengths with 0. The accumulativeLengths array is then one larger than the drawingPoints array. With this scheme, we calculate the length between drawing points 5 and 8 as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">accumulativeLength<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">8</span> <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span> – accumulativeLength<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">5</span><span style="color: #008000;">&#93;</span> <span style="color: #008080; font-style: italic;">//correct</span></pre></div></div>

<p>If we need to calculate the length between arbitrary points (not just drawing points), then we need a slightly more complicated scheme, as in the following function:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">//Calculates the length of curve between two points on the curve</span>
CalculateLenth<span style="color: #008000;">&#40;</span>segmentIndex0, t0, segmentIndex1, t1<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//assert(segmentIndex0 &lt;= segmentIndex1)</span>
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>segmentIndex0 <span style="color: #008000;">==</span> segmentIndex1<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        assert<span style="color: #008000;">&#40;</span>t1 <span style="color: #008000;">&gt;=</span> t0<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    p0 <span style="color: #008000;">=</span> getPoint<span style="color: #008000;">&#40;</span>curveIndex0, t0<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    beginningLength <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>drawingPoints<span style="color: #008000;">&#91;</span>segmentIndex0 <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span> – p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
    p1 <span style="color: #008000;">=</span> getPoint<span style="color: #008000;">&#40;</span>curveIndex1, t1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    endLength <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>drawingPoints<span style="color: #008000;">&#91;</span>segmentIndex1<span style="color: #008000;">&#93;</span> – p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
    length <span style="color: #008000;">=</span> beginningLength <span style="color: #008000;">+</span> endLength<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>segmentIndex0 <span style="color: #008000;">!=</span> segmentIndex1<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        midLength <span style="color: #008000;">=</span> accumulativeLength<span style="color: #008000;">&#91;</span>segmentIndex0 <span style="color: #008000;">+</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#93;</span> –
          accumulativeLength<span style="color: #008000;">&#91;</span>segmentIndex1<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
        length <span style="color: #008000;">+=</span> midLength<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> length<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The code in red above samples the curve directly to calculate the two points. However, this will give results inconsistent with our approximation using line segments of the midLength. It is often not a problem, since the difference might be small. If it <em>is</em> a problem, you can use points on the line segments instead of points on the curve to calculate the approximation.</p>
<p>This technique is consistent with the approximation of the interior segment, and is somewhat faster. All you have to do is use the following method to calculate p0 and p1, instead of using the getPoint method as above.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">GetPointOnSegment<span style="color: #008000;">&#40;</span>curveIndex, t<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>t – <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">*</span> points<span style="color: #008000;">&#91;</span>curveIndex<span style="color: #008000;">&#93;</span> <span style="color: #008000;">+</span> t <span style="color: #008000;">*</span>  points<span style="color: #008000;">&#91;</span>curveIndex <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<h2>Constructing a smooth Bézier path from a set of points</h2>
<p>Two related problems arise frequently when working with paths. Both problems require us to find an aesthetic, smooth curve for a set of points.</p>
<p>The first problem occurs when only a few points of the curve are given, and we have to find a smooth curve that passes through all the points. One example of this is the paths given to AI agents. A walking character looks very funny when abruptly turning to follow the path laid out by the AI designer or algorithm. Using a bit of smoothing greatly enhances the believability of the character’s movements. This is <strong>interpolation</strong>.</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="interpolation" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/interpolation.png" border="0" alt="interpolation" width="681" height="145" /></p>
<p><em>An example of Bézier interpolation.</em></p>
<p>The second problem occurs when a vast number of points are given, and we need to simplify the curve without distorting the overall shape. This, for example, is useful to make a curve in a line drawing game more pleasing to the eye, and easier for the AI to follow. This is <strong>simplification</strong>.</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="reduction" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/reduction.png" border="0" alt="reduction" width="681" height="190" /></p>
<p><em>An example of Bézier simplification.</em></p>
<h3>Bézier interpolation</h3>
<p>The challenge is to find a nice, smooth curve passing through all the points given in order. We can think of this as smoothing a curve made out of line segments. A Bézier path is smooth if each endpoint and its two surrounding control points lie in a straight line. In other words, the two tangents at each Bézier endpoint are parallel.</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="tangents" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/tangents.png" border="0" alt="tangents" width="679" height="185" /></p>
<p><em>These figures show two Bézier paths, each made out of two Bézier curves. The yellow line segments are tangents to the left and right of the orange Bézier endpoint. When the tangents are parallel, as on the left, the connection between the two Bézier curves is smooth. If they are not parallel, as on the right, there is a cusp where the curves connect.</em></p>
<p>For now, let us assume the segments are roughly of the same length.</p>
<p>The basic idea is to calculate control points around each endpoint so that they lie in a straight line with the endpoint. We make this line parallel to the line formed with the neighbouring Bézier endpoints, and we make the control points the same distance from the endpoint that they surround (for now). We use a scaling parameter to control curvature of the curve at the Bézier endpoint. Curves for different scale values are shown below.</p>
<p><em><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="g5680" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/g5680.png" border="0" alt="g5680" width="207" height="323" /> </em></p>
<p><em>We are given the orange points. The algorithm calculates the yellow points, which in this case are the control points around the Bézier endpoint in the middle. We do it so that the yellow points that surround a Bézier endpoint lie in a straight line. We can tweak the distance of the control points from this Bézier endpoint with a parameter. The larger this parameter, the smaller the curvature at that Bézier endpoint. In these images, each of the three Bézier paths has two Bézier curves.</em></p>
<p>The basic steps to calculate the two control points around a point p1, are the following, where p0 and p2 are the endpoints around p1:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p2 – p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">normalized</span><span style="color: #008000;">;</span>
q0 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">-</span> scale <span style="color: #008000;">*</span> tangent<span style="color: #008000;">;</span>
q1 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">+</span> scale <span style="color: #008000;">*</span> tangent<span style="color: #008000;">;</span></pre></div></div>

<p>The tricky bit is handling the first and last control points of the path. These are calculated as before, except that we use the two first or two last endpoints to do the tangent calculation.</p>
<p>We can now iterate through all the segment points, and calculate control points depending on the correct case.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">List<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span> Interpolate<span style="color: #008000;">&#40;</span>List<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span> segmentPoints, <span style="color: #6666cc; font-weight: bold;">float</span> scale<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    controlPoints <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> List<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>segmentPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> segmentPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008080; font-style: italic;">// is first</span>
        <span style="color: #008000;">&#123;</span>
            Vector3 p1 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 p2 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>                
&nbsp;
            Vector3 tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p2 <span style="color: #008000;">-</span> p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Vector3 q1 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">+</span> scale <span style="color: #008000;">*</span> tangent<span style="color: #008000;">;</span>
&nbsp;
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>q1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>i <span style="color: #008000;">==</span> segmentPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008080; font-style: italic;">//last</span>
        <span style="color: #008000;">&#123;</span>
            Vector3 p0 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 p1 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p1 <span style="color: #008000;">-</span> p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Vector3 q0 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">-</span> scale <span style="color: #008000;">*</span> tangent<span style="color: #008000;">;</span>
&nbsp;
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>q0<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            Vector3 p0 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 p1 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 p2 <span style="color: #008000;">=</span> segmentPoints<span style="color: #008000;">&#91;</span>i <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            Vector3 tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p2 <span style="color: #008000;">-</span> p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">normalized</span><span style="color: #008000;">;</span>
            Vector3 q0 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">-</span> scale <span style="color: #008000;">*</span> tangent <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span>p1 <span style="color: #008000;">-</span> p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
            Vector3 q1 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">+</span> scale <span style="color: #008000;">*</span> tangent <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span>p2 <span style="color: #008000;">-</span> p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
&nbsp;
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>q0<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            controlPoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Add</span><span style="color: #008000;">&#40;</span>q1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> controlPoints<span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<h3>Bézier simplification (Quick and Dirty Method)</h3>
<p>If we would also like to reduce the number of points in our curve, it is much harder to construct a suitable Bézier curve, especially if we want the best possible fit given constraints on the number of control points and degree of the curve. There is a quick and dirty method that works well in many cases. Here is the broad outline:</p>
<ol>
<li>Add points to a list so that successive points are as far apart as possible, within a specified minimum.</li>
<li>Use Bézier interpolation discussed above.</li>
</ol>
<p>The algorithm to perform step 1 works as follows:</p>
<ol>
<li>We add the first point from our list of source points to the list sample points.</li>
<li>We set the next potential sample point as the second point in the list of source points.</li>
<li>We then iterate through the remaining source points (starting at the third point). For each point, we check whether the last sample point added is outside a minimum square distance of that point. If it is, we add the potential sample point to the list of sample points. The current point becomes the new potential sample point (regardless of whether the last test failed).</li>
</ol>
<p>Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>sourcePoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
Vector3 potentialSamplePoint <span style="color: #008000;">=</span> sourcePoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span>i <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> sourcePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>potentialSamplePoint <span style="color: #008000;">-</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sqrMagnitude</span> <span style="color: #008000;">&gt;</span> minSqrDistance<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span>
       <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Peek</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">-</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sqrMagnitude</span> <span style="color: #008000;">&gt;</span> maxSqrDistance<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>potentialSamplePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    potentialSamplePoint <span style="color: #008000;">=</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>The last bit of the curve is a bit messy to handle. We can either throw the last point away, and lose a small piece of the curve; or add the last point as a control point, and keep the full curve.</p>
<p>If we decide to add the last point, the last two points in samplePoints may lie very close to each other. If this is the case, you might either discard the <em>second</em> last point, or move it a bit further from the last point, closer to the third last point. The exact best new location for this point is a bit tricky to calculate. The following is an approximation scheme:</p>
<p>Let p0, p1 be the last two sample points, and p2 be the last potentialSamplePoint (which is also the last point from samplePoints). We want to calculate a new position for p1.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p0 – p2<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">normalized</span><span style="color: #008000;">;</span>
d2 <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p2 – p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
d1 <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p1 – p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
p1 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">+</span> tangent <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>d1 <span style="color: #008000;">-</span> d2<span style="color: #008000;">&#41;</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>I based the approximation above on the following reasoning:</p>
<p><img style="display: inline; margin: 5px 10px 0px 0px; border-width: 0px;" title="last_point" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/last_point.png" border="0" alt="last_point" width="340" height="180" align="left" /> The vector t is an approximate tangent vector for the curve at p1. This is the same tangent as would be calculated by our smoothing algorithm. We then want to move p1 so that it lies on this tangent, (passing through the original p1), and lies roughly the same distance from p0 and p1. Instead of calculating exact intersections, we approximate the desired distance as half the sum of the original distances, that is, the new distance from p1 to p0 (and p2) is given by (d1 + d2) / 2. Now p1 is already d2 from p2, so we subtract that from (d1 + d2) / 2 to obtain (d1 &#8211; d2) / 2. This is exact only when all three points lie in a straight line, but it is close enough in other cases.</p>
<p>The final algorithm is this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> List<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span> SamplePoints<span style="color: #008000;">&#40;</span>List<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span> sourcePoints,
        <span style="color: #6666cc; font-weight: bold;">float</span> minSqrDistance, <span style="color: #6666cc; font-weight: bold;">float</span> maxSqrDistance, <span style="color: #6666cc; font-weight: bold;">float</span> scale<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>sourcePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    Stack<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span> samplePoints <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Stack<span style="color: #008000;">&lt;</span>Vector3<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>sourcePoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Vector3 potentialSamplePoint <span style="color: #008000;">=</span> sourcePoints<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span>i <span style="color: #008000;">=</span> <span style="color: #FF0000;">2</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> sourcePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span> <span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>potentialSamplePoint <span style="color: #008000;">-</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sqrMagnitude</span> <span style="color: #008000;">&gt;</span> minSqrDistance<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span>
           <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Peek</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">-</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sqrMagnitude</span> <span style="color: #008000;">&gt;</span> maxSqrDistance<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>potentialSamplePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        potentialSamplePoint <span style="color: #008000;">=</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">//now handle last bit of curve</span>
    Vector3 p1 <span style="color: #008000;">=</span> samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Pop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//last sample point</span>
    Vector3 p0 <span style="color: #008000;">=</span> samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Peek</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008080; font-style: italic;">//second last sample point</span>
    Vector3 tangent <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p0 <span style="color: #008000;">-</span> potentialSamplePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">normalized</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">float</span> d2 <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>potentialSamplePoint <span style="color: #008000;">-</span> p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">float</span> d1 <span style="color: #008000;">=</span> <span style="color: #008000;">&#40;</span>p1 <span style="color: #008000;">-</span> p0<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">magnitude</span><span style="color: #008000;">;</span>
    p1 <span style="color: #008000;">=</span> p1 <span style="color: #008000;">+</span> tangent <span style="color: #008000;">*</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>d1 <span style="color: #008000;">-</span> d2<span style="color: #008000;">&#41;</span><span style="color: #008000;">/</span><span style="color: #FF0000;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>p1<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>potentialSamplePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">return</span> Interpolate<span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">ToArray</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, scale<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<p>Once we have reduced the points, the final step is to make the curve smooth, by using Bézier interpolation. We simply pass the list returned by SamplePoints to the Interpolate function.</p>
<p>The algorithm is easily converted to an online algorithm. If the curve is drawn while the sampling is being done, the potential point should be included for drawing to make the curve building smooth. If it is not, the curve end will jump as the curve is extended. The end of the curve will also adjust itself as the curve is extended; unfortunately, there is not much that can be done about this.</p>
<p>If the last samples being too close present a problem, we can perform the end-of-curve calculations where the curve is drawn. We also need to do the calculations once the last sourcePoint has been given.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">void</span> SamplePointsOnline<span style="color: #008000;">&#40;</span>Vector3 newSourcePoint, <span style="color: #6666cc; font-weight: bold;">float</span> minSqrDistance<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">//samplePoints and potentialSamplePoint are now fields</span>
&nbsp;
    <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>newSourcePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Count</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        potentialSamplePoint <span style="color: #008000;">=</span> newSourcePoint<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;">else</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#40;</span>samplePoints<span style="color: #008000;">.</span><span style="color: #0000FF;">Back</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> – newSourcePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">sqrMagnitude</span> <span style="color: #008000;">&gt;=</span> minSqrDistance<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            segmentPoint<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>potentialSamplePoint<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        potentialSamplePoint <span style="color: #008000;">=</span> sourcePoints<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">;;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

<h2>Downloads</h2>
<p>(WARNING: The code fairy stole all the comments in these files!)</p>
<ul>
<li><a href="http://www.devmag.org.za/downloads/bezier_curves/Curve.zip">Bezier Curves</a> (64 KB, Unity 3D Project, zipped)</li>
<li><a href="http://www.devmag.org.za/downloads/bezier_curves/BezierPath.cs">BezierPath.cs</a> (C# source code file)</li>
</ul>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/' rel='bookmark' title='B&eacute;zier Curves for your Games: A Tutorial'>B&eacute;zier Curves for your Games: A Tutorial</a> <small>A Bézier curve is a type of curve that is...</small></li>
<li><a href='http://devmag.org.za/2009/06/07/the-path-demo-is-out/' rel='bookmark' title='The Path demo is out!'>The Path demo is out!</a> <small>The Path is one of those videogames that just keeps...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/06/23/bzier-path-algorithms/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Are Puzzle Games Designed? (Conclusion)</title>
		<link>http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/</link>
		<comments>http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 07:44:38 +0000</pubDate>
		<dc:creator>Herman Tulleken</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Puzzle Game Design]]></category>
		<category><![CDATA[difficulty]]></category>
		<category><![CDATA[level design]]></category>
		<category><![CDATA[playtesting]]></category>
		<category><![CDATA[progression]]></category>
		<category><![CDATA[puzzle game design]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4166</guid>
		<description><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/>A distillation of the five puzzle game design interviews, taking together advice from Rob Jagnow, Guy Lima, Ted Lauterbach, Teddy Lee, Dave Hall and Teddy Lee. <h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/' rel='bookmark' title='How are puzzle games designed? Teddy Lee'>How are puzzle games designed? Teddy Lee</a> <small>Teddy Lee (maker of My First First Quantum Translocater and...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
<li><a href='http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/' rel='bookmark' title='How are puzzle games designed? Dave Hall'>How are puzzle games designed? Dave Hall</a> <small>In this puzzle game design interview, Dave Hall from Toxic...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="RIDDLERS_2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/RIDDLERS_2.png" border="0" alt="RIDDLERS_2" width="680" height="320" /> Over the last month or so, Dev.Mag has published five interviews with indie developers discussing puzzle game design. In case you have missed the series, here are links to the articles:</p>
<ul>
<li><a href="http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/">Introduction </a></li>
<li><a href="http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/">Rob Jagnow</a> (<em>Cogs</em>)</li>
<li><a href="http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/">Guy Lima</a> (<em>Continuity</em>)</li>
<li><a href="http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/">Ted Lauterbach</a> (<em>suteF</em>)</li>
<li><a href="http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/">Dave Hall</a> (<em>Q.U.B.E</em>)</li>
<li><a href="http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/">Teddy Lee</a> (<em>My First Quantum Translocator</em>)</li>
</ul>
<p>In this article, I give you my take on the info we gathered in our five puzzle design interviews; a kind of distillation of the various ideas the designers presented. The discussion below is terse with almost no examples; to see how these ideas play out in the design of actual games, you will find the original interviews more helpful.</p>
<p><span id="more-4166"></span>I chose the games for our series to be what I called “combinatorial puzzles” (an ugly term, a colleague informed me in a friendly email. I agree – if you have a better word, please share!). Puzzle games that make it easy to see how the designer takes core mechanics and put them together into a cohesive, compelling playing experience.</p>
<p>In the introduction article I have said that some principles of puzzle game design apply to all games. Replace “puzzle” with “level” (or other suitable game-playing unit), and the advice offered on selecting mechanics, training the player, handling difficulty and progressions, and playtesting can also be used for more general game design.</p>
<h2>What is a good puzzle?</h2>
<p style="text-align: right;"><em>“I feel like when we design something clever,<br />
players enjoy it just as much as we do.” – Teddy Lee </em></p>
<p>Minimally, a good puzzle:</p>
<ul>
<li>has clear rules;</li>
<li>has a clear objective;</li>
<li>finds the balance between too easy and frustrating, to make an interesting challenge.</li>
</ul>
<p>On top of this, an interesting puzzle can be a puzzle that:</p>
<ul>
<li>stumps the player for a long time, but whose solution looks obvious once found;</li>
<li>uses the mechanics in unexpected ways;</li>
<li>has multiple solutions;</li>
<li>allows a tiered system so that beginners and novices can play at different difficulty levels.</li>
</ul>
<p>In puzzle games, puzzles can’t be judged in isolation. Each puzzle should be judged taking into account its role in the <em>sequence</em> of puzzles in the game. For example, a training puzzle will only be good if it occurs in the right place in the game. See <em>difficulty and Progression</em> below for more on this aspect.</p>
<h2>Process</h2>
<p style="text-align: right;"><em>“I’ll tweak and tweak until it feels… right.” – Ted Lauterbach </em></p>
<p>Different designers follow different (although similar) processes to design their games. Here are a few general notes about the design process:</p>
<ul>
<li>Design lots of puzzles, and don’t be afraid to throw some away.</li>
<li>Focus on gameplay, not engine design.</li>
<li>Designing puzzles before building them (using paper, Excel, or Photoshop) can help to make levels tight and focussed. Designing on paper might not work for all games, in which case prototyping in the engine is a better strategy.</li>
</ul>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="226" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="prototyping" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/prototyping.png" border="0" alt="prototyping" width="200" height="200" /> <em>Design using a prototype.</em></td>
<td style="text-align: center;" width="226" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="excel" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/excel.png" border="0" alt="excel" width="200" height="200" /> <em>Design using Excel.</em></td>
<td style="text-align: center;" width="226" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="design" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/design.png" border="0" alt="design" width="200" height="200" /> <em>Design using Photoshop.</em></td>
</tr>
</tbody>
</table>
<ul>
<li>It’s a good idea to start with the goal, and then insert the elements the player will need to get to the goal, and obstacles that will make it more difficult.</li>
<li>Consider whether you should add decoys in your game. Decoys can make puzzles more challenging, but can also become unnecessary filler.</li>
<li>Remove misleading paths (such as the impossible jump that looks possible).</li>
<li>Test and iterate (see below for notes on playtesting).</li>
<li>Polish and refine your gameplay.</li>
</ul>
<h2>Mechanics</h2>
<p>At the heart of a puzzle game (any game) is the basic rules of the game, the basic actions a player can take.</p>
<ul>
<li>Limit the number of mechanics. This lets you focus on:
<ul>
<li>level design;</li>
<li>interesting uses for mechanics;</li>
<li>polishing mechanics to extract the maximum amount of fun from them.</li>
</ul>
</li>
<li>Choose flexible mechanics. A handy rule of thumb of Teddy Lee: if you can initially think of five puzzles with a mechanic, chances are you will be able to think up a lot more later on. If you can’t, it probably means the mechanic is too brittle for making many interesting puzzles.</li>
<li>Use them in the maximum number of ways: explore all their aspects and consequences. You need to know your mechanics inside out.</li>
<li>Combine mechanics to get emergent gameplay (tricks).</li>
<li>Reuse mechanics and tricks, but don’t reuse puzzles, otherwise you risk boring the player.</li>
<li>Stagger themes and techniques to make the overall experience more interesting.</li>
</ul>
<h2>Training the Player</h2>
<p>To solve a puzzle, the game must teach the player the rules and the strategies available.</p>
<ul>
<li>No one reads, or wants to read, a tutorial.</li>
<li>Introduce core mechanics in isolation. Teach hard-to-see techniques by making it the only thing the player can do.</li>
<li>Anticipate misunderstandings and encourage the player to fail and so clear up these misunderstandings early in the game.</li>
</ul>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="sutef_learn_by_failure" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/sutef_learn_by_failure.png" border="0" alt="sutef_learn_by_failure" width="301" height="225" /> <em>The player is encouraged to jump of the ledge to discover the infinite loop that will require a level restart.</em></td>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="traning2" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/traning2.png" border="0" alt="traning2" width="300" height="225" /><em>The only thing the player can do is jump, and then freeze mid-jump while re-arranging the tiles.</em></td>
</tr>
</tbody>
</table>
<ul>
<li>Control difficulty (see below).</li>
<li>Ensure the things the player will use to solve the puzzle are easy to see – reduce visual clutter.</li>
<li>One technique that is especially helpful for illustrating manoeuvres in platform puzzlers is a helper character (perhaps a ghost) to illustrate the actions.</li>
<li>In cases where dexterity is required, provide visual markers to help the player take precise jumps and other actions.</li>
</ul>
<h2>Difficulty and Progression</h2>
<p>The theory of difficulty is straightforward:</p>
<ul>
<li>Start with simple puzzles, and make puzzles progressively more difficult and complex.</li>
<li>Use staggering difficulty or “breather” puzzles to help build confidence and keep the player motivated. After a difficult puzzle, give the player an easy puzzle or two to allow a mental break.</li>
<li>Let the player know when they are close to the end, especially when the entire playfield is not visible.</li>
</ul>
<p style="text-align: center;"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="difficulty" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/difficulty.png" border="0" alt="difficulty" width="680" height="143" /> <em>Examples of different difficulty profiles for a sequence of 12 puzzles.</em></p>
<p>The practice of difficulty design is harder.</p>
<ul>
<li>The only sure way to judge the difficulty of a puzzle is to playtest it.</li>
</ul>
<h2>Playtesting</h2>
<p style="text-align: right;"><em>“Sometimes players will not realise something that I thought was quite obvious.” – Dave Hall </em></p>
<p style="text-align: right;"><em>“You&#8217;d think after failing, people would try a different approach,<br />
but they often don&#8217;t.” – Guy Lima </em></p>
<p style="text-align: right;"><em>“It’s not because they’re stupid;<br />
it’s because you’ve lost perspective.” – Rob Jagnow </em></p>
<p>This is possibly the most important step in creating a good puzzle.</p>
<ul>
<li>Playtest early and often.</li>
<li>Playtest with people who have not played the game before.</li>
<li>Keep quiet, or you won’t find out whether a puzzle is really too difficult:
<ul>
<li>don’t offer hints;</li>
<li>don’t ask questions.</li>
</ul>
</li>
<li>When player behaviour makes you cringe, it means there is a design problem you need to fix. Here are some ways to fix a problem:
<ul>
<li>provide more cues in the level;</li>
<li>remove distractions that mislead;</li>
<li>insert more levels before that puzzle to illustrate concepts;</li>
<li>remove steps from problem to solution;</li>
<li>cut the puzzle.</li>
</ul>
</li>
<li>Ask players afterwards about the puzzle and their experience.</li>
<li>Gather statistics to help measure of difficulty.</li>
</ul>
<p><img class="aligncenter size-full wp-image-4170" title="stats" src="http://devmag.org.za/blog/wp-content/uploads/2011/06/stats.png" alt="" width="517" height="156" /></p>
<h2>What do you say?</h2>
<p>If you have additional puzzle game design tips, please share them in the comments!</p>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/' rel='bookmark' title='How are puzzle games designed? Teddy Lee'>How are puzzle games designed? Teddy Lee</a> <small>Teddy Lee (maker of My First First Quantum Translocater and...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
<li><a href='http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/' rel='bookmark' title='How are puzzle games designed? Dave Hall'>How are puzzle games designed? Dave Hall</a> <small>In this puzzle game design interview, Dave Hall from Toxic...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Box2DFlash Tutorial</title>
		<link>http://devmag.org.za/2011/05/27/box2dflash-tutorial/</link>
		<comments>http://devmag.org.za/2011/05/27/box2dflash-tutorial/#comments</comments>
		<pubDate>Thu, 26 May 2011 22:39:04 +0000</pubDate>
		<dc:creator>Ricky Abell</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[2d]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[box2d]]></category>
		<category><![CDATA[box2dflash]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[physics]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4132</guid>
		<description><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/>Hello Physics World! This is a Box2DFlash tutorial, showing the basics of using the popular Box2D port in Flash.<h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/' rel='bookmark' title='B&eacute;zier Curves for your Games: A Tutorial'>B&eacute;zier Curves for your Games: A Tutorial</a> <small>A Bézier curve is a type of curve that is...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/><p><img class="aligncenter size-full wp-image-4140" title="box2d_header" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/box2d_header1.png" alt="" width="680" height="340" /></p>
<p>More and more games are using dynamic physics to add to the gameplay or as a core element of the gameplay. Box2D is a popular and powerful physics library that is considered to be one of the best 2D physics libraries around. It is used by high profile games like Angry Birds and Crayon Physics Deluxe. This tutorial will focus on the Flash version of Box2D and assumes that you have basic experience with Flash and ActionScript 3. If you are new to Flash, check out Nandrew&#8217;s excellent <a href="http://devmag.org.za/2009/04/02/flash-for-free/">Flash tutorial</a>.</p>
<h2><span id="more-4132"></span>Getting Started</h2>
<p>Box2D has been ported to a number of languages, and to make things confusing, there are a number of different Flash ports available on the Web. In this tutorial we&#8217;ll be using version 2.1a of <a href="http://www.box2dflash.org/">Box2DFlash</a> which is considered the most official Flash port of Box2D. Download <a href="http://www.box2dflash.org/download">Box2DFlash </a>2.1a for Flash 10 from the Box2DFlash website.</p>
<p>Extract the download, and copy the Box2D folder into the src folder of your project, like this:</p>
<p><img class="aligncenter size-full wp-image-4151" title="box2d_project" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/box2d_project.png" alt="" width="303" height="234" /></p>
<h2>Box2D Overview</h2>
<p>There is a fair bit of terminology in Box2D that you need to know to understand how things work. The following diagram shows a top-down view of Box2D.</p>
<p><img class="aligncenter size-full wp-image-4153" title="box2d_object_diagram" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/box2d_object_diagram.png" alt="" width="138" height="433" /></p>
<p>At the core we have a world that holds our entities and manages the dynamic physics simulations. These entities in our world are known as bodies, and a world can have 0 or more bodies. Each body consists of 0 or more shapes. A shape, such as a rectangle or a circle, is used for collision detection. Each one of these shapes is connected to the body through a fixture definition and adds properties such as density and friction.</p>
<p><img class="aligncenter size-full wp-image-4155" title="box2d_diagram2" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/box2d_diagram2.png" alt="" width="494" height="281" /></p>
<p>Every body has a body definition to define properties such as position, type (dymanic, static or kinetic) and more. To create a body, you need the body definition and a reference to the world. The world has a convenient helper function to create bodies.</p>
<h2>Hello Physics World</h2>
<p>In this tutorial we are going to create this:</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="400" height="300">
      <param name="movie" value="http://devmag.org.za/blog/wp-content/uploads/2011/05/Box2DDevMagTutRelease.swf" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://devmag.org.za/blog/wp-content/uploads/2011/05/Box2DDevMagTutRelease.swf" width="400" height="300">
      <!--<![endif]-->
        
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>We will generate random shapes and let them free-fall. Some walls, a floor, and a few blocks will make up the environment. Let&#8217;s jump into the code.</p>
<pre>package
{
  import flash.display.Sprite;
  import flash.events.Event;
  import Box2D.Common.Math.*;
  import flash.events.TimerEvent;
  import flash.utils.Timer;
  import Box2D.Dynamics.*;
  import Box2D.Collision.Shapes.*;

  public class Main extends Sprite
  {
    private var world:b2World;
    private var timestep:Number;
    private var iterations:uint;
    private var pixelsPerMeter:Number = 30;
    private var genBodyTimer:Timer;
    private var sideWallWidth:int = 20;
    private var bottomWallHeight:int = 25;

    public function Main():void
    {
      this.initWorld();
      this.createWalls();
      this.createStaticBodies();
      this.setupDebugDraw();

      this.genBodyTimer = new Timer(500);
      this.genBodyTimer.addEventListener(TimerEvent.TIMER, this.genRandomBody);

      if (stage) init();
      else addEventListener(Event.ADDED_TO_STAGE, init);
    }

  //...function definitions will go here

  }
}</pre>
<p>To make things simple we&#8217;ll keep all our work in the Main class.</p>
<p>Our program will flow as follows: We initialize our Box2D world, we create some walls and a few static blocks with which our objects can interact, then we set up the debug drawing mode, and we add a timer for generating random bodies. Finally we initialize our game loop after the Box2D world has been added to the stage.</p>
<pre>private function initWorld():void
{
  var gravity:b2Vec2 = new b2Vec2(0.0, 9.8);
  var doSleep:Boolean = true;

  // Construct world
  this.world = new b2World(gravity, doSleep);
  this.world.SetWarmStarting(true);
  this.timestep = 1.0 / 30.0;
  this.velocityIterations = 6;
  this.positionIterations = 4;
}</pre>
<p>The world is the core of our Box2D environment. It holds all of our bodies and manages the physics simulations. We set the gravity, and we state that the world can stop calculating physics for bodies that have come to rest. A &#8216;warm starting&#8217; tells the world that bodies must start off active. If this was false, the bodies would have stayed put until they were woken up or until something collided with them. The timestep variable specifies how often the world should calculate the physics (in this case, every 1/30 seconds, or 30 Hz – thirty times a second). The iterations determine how many times per time step to calculate the position and the velocity of a body before moving on to the next one in the queue, the trade-off being performance versus accuracy.</p>
<pre>private function createWalls():void
{
  var wallShape:b2PolygonShape = new b2PolygonShape();
  var wallBd:b2BodyDef = new b2BodyDef();
  var wallB:b2Body;

  wallShape.SetAsBox(
    sideWallWidth / pixelsPerMeter / 2,
    this.stage.stageHeight / pixelsPerMeter / 2);

  //Left wall
  wallBd.position.Set(
    (sideWallWidth / 2) / pixelsPerMeter,
    this.stage.stageHeight / 2 / pixelsPerMeter);
  wallB = world.CreateBody(wallBd);
  wallB.CreateFixture2(wallShape);

  //Right wall
  wallBd.position.Set(
    (this.stage.stageWidth - (sideWallWidth / 2)) / pixelsPerMeter,
    this.stage.stageHeight / 2 / pixelsPerMeter);
  wallB = world.CreateBody(wallBd);
  wallB.CreateFixture2(wallShape);

  //Bottom wall
  wallShape.SetAsBox(
    this.stage.stageWidth / pixelsPerMeter / 2,
    bottomWallHeight / pixelsPerMeter / 2);
  wallBd.position.Set(
    this.stage.stageWidth / 2 / pixelsPerMeter,
    (this.stage.stageHeight - (bottomWallHeight / 2)) / pixelsPerMeter);
  wallB = world.CreateBody(wallBd);
  wallB.CreateFixture2(wallShape);
}</pre>
<p>Now we create walls, so that our objects stay within the desired area. If you remember the diagrams above, we need to follow a number of steps to create a body.</p>
<p>The values and calculations in the code sample may look a bit verbose, but I designed it that way to show you how things work.</p>
<p>To use distance units in Box2D, you need to understand these key points:</p>
<p>Measurements are in metres. However, beware: a 1 pixel : 1 metre ratio will be very computationally intensive, and there will be no way to represent the distance from one pixel to the next on screen, since pixels are directly next to each other. It&#8217;s best to use the following equations:</p>
<pre>box2DMeters = pixels / pixelsPerMeter
pixels = box2DMeters * pixelsPerMeter</pre>
<p>The origins of Box2D bodies are in their centres. This means that the distance between one body and another is actually the distance between their centres. This also means that we need to pass half of the width and half of the height as the dimensions of the shape, because the shape is created from its centre outwards.</p>
<p>Now that that&#8217;s cleared up, let&#8217;s break down the creation of the left wall.</p>
<pre>wallShape.SetAsBox(
  sideWallWidth / pixelsPerMeter / 2,
  this.stage.stageHeight / pixelsPerMeter / 2);</pre>
<p>To set the dimensions of the wall shape, we divide the desired width of the wall by pixelsPerMeter to convert it into metres, and then we divide that by 2 to get half of the width. We use the same idea for the height.</p>
<pre>wallBd.position.Set(
  (sideWallWidth / 2) / pixelsPerMeter,
  this.stage.stageHeight / 2 / pixelsPerMeter);</pre>
<p>The next step is to set the position of the body. The wall is on the left, so the base x co-ordinate will be 0. We then add half the width of the wall – remember that the origin is in the centre – and then we convert the coordinate into metres. We want the y co-ordinate of the wall to be in the centre of the world, so we halve the height of the stage and then convert to metres.</p>
<pre>wallB = world.CreateBody(wallBd);
wallB.CreateFixture2(wallShape);</pre>
<p>The body is created and added to the world. We then attach the shape to the body using a fixture.</p>
<pre>private function createStaticBodies():void
{
  var blockBody:b2Body;
  var blockBd:b2BodyDef = new b2BodyDef();
  var blockShape:b2PolygonShape = new b2PolygonShape();
  var rectHeight:int = 30;  

  //Create a stack of static rectangular bodies for our randomly
  //generated bodies to interact with.

  blockBd.position.Set(
    this.stage.stageWidth / 2 / pixelsPerMeter,
    (this.stage.stageHeight - this.bottomWallHeight - (rectHeight / 2))
          / pixelsPerMeter);
  blockShape.SetAsBox(320 / pixelsPerMeter / 2, rectHeight / pixelsPerMeter / 2);
  blockBody = world.CreateBody(blockBd);
  blockBody.CreateFixture2(blockShape);  

  blockBd.position.Set(
    this.stage.stageWidth / 2 / pixelsPerMeter,
    (this.stage.stageHeight - (this.bottomWallHeight + rectHeight)
          - (rectHeight / 2)) / pixelsPerMeter);
  blockShape.SetAsBox(240 / pixelsPerMeter / 2, rectHeight / pixelsPerMeter / 2);
  blockBody = world.CreateBody(blockBd);
  blockBody.CreateFixture2(blockShape); 

  blockBd.position.Set(
    this.stage.stageWidth / 2 / pixelsPerMeter,
    (this.stage.stageHeight - (this.bottomWallHeight + 2 * rectHeight)
          - (rectHeight / 2)) / pixelsPerMeter);
  blockShape.SetAsBox(140 / pixelsPerMeter / 2, rectHeight / pixelsPerMeter / 2);
  blockBody = world.CreateBody(blockBd);
  blockBody.CreateFixture2(blockShape);
}</pre>
<p>The function above creates a few static rectangles that the randomly generated bodies can bounce off of. Again, the equations are verbose to help you remember that that a shape&#8217;s origin is in the centre. We use half the width and half the height, and we need to pass the values through in metres.</p>
<pre>private function setupDebugDraw():void
{
  var debugDraw:b2DebugDraw = new b2DebugDraw();
  var debugSprite:Sprite = new Sprite();

  addChild(debugSprite);
  debugDraw.SetSprite(debugSprite);
  debugDraw.SetDrawScale(30.0);
  debugDraw.SetFillAlpha(0.3);
  debugDraw.SetLineThickness(1.0);
  debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit);
  world.SetDebugDraw(debugDraw);
}</pre>
<p>This tells our Box2D world to draw debug information on the bodies. This allows us to see the joints and shapes of the bodies. It also shows us when a body goes to sleep by changing its colour; the colour changes back again when it wakes up.</p>
<pre>private function init(e:Event = null):void
{
  this.removeEventListener(Event.ADDED_TO_STAGE, init);
  this.addEventListener(Event.ENTER_FRAME, update);
  this.genBodyTimer.start();
}</pre>
<p>Our setup is almost complete! We start the game loop and start a timer to generate random bodies.</p>
<pre>private function genCircle():void
{
  var body:b2Body;
  var fd:b2FixtureDef;
  var bodyDefC:b2BodyDef = new b2BodyDef();
  bodyDefC.type = b2Body.b2_dynamicBody; 

  var circShape:b2CircleShape
     = new b2CircleShape((Math.random() * 7 + 10) / pixelsPerMeter);

  fd = new b2FixtureDef();
  fd.shape = circShape;
  fd.density = 1.0;
  fd.friction = 0.3;
  fd.restitution = 0.1;
  bodyDefC.position.Set(
    (Math.random() * (this.stage.stageWidth - sideWallWidth - 20)
         + sideWallWidth + 20) / pixelsPerMeter,
    (Math.random() * 80 + 40) / pixelsPerMeter);
  bodyDefC.angle = Math.random() * Math.PI;
  body = world.CreateBody(bodyDefC);
  body.CreateFixture(fd);
}

private function genRectangle():void
{
  var body:b2Body;
  var fd:b2FixtureDef = new b2FixtureDef();
  var rectDef:b2BodyDef = new b2BodyDef();

  rectDef.type = b2Body.b2_dynamicBody;

  var polyShape:b2PolygonShape = new b2PolygonShape();

  fd.shape = polyShape;
  fd.density = 1.0;
  fd.friction = 0.3;
  fd.restitution = 0.1;
  polyShape.SetAsBox(
    (Math.random() * 16 + 20) / pixelsPerMeter / 2,
    (Math.random() * 16 + 20) / pixelsPerMeter / 2);

  rectDef.position.Set(
    (Math.random() * (this.stage.stageWidth - 2 * (sideWallWidth + 20))
         + (sideWallWidth + 20)) / pixelsPerMeter,
    (Math.random() * 80 + 40) / pixelsPerMeter);

  rectDef.angle = Math.random() * Math.PI;
  body = world.CreateBody(rectDef);
  body.CreateFixture(fd);
}</pre>
<p>These functions create randomly sized and positioned circles and rectangles. All the bodies we created before (the walls, the floor, and the blocks) were static. This means that they have zero mass and zero velocity, and that we can move them only manually. For the rectangles and circles, we want dynamic behaviour. We want these bodies to bounce around and be all physics-like, so, we set the body type to dynamic, which means that it has a positive mass and that it has a non-zero velocity that is determined by forces in the world, such as gravity.</p>
<pre>private function genRandomBody(e:TimerEvent):void
{
  var bodyType:Number = Math.random();
  (bodyType &lt; 0.5) ? this.genCircle() : this.genRectangle();
}</pre>
<p>We randomly generate a circle or a rectangle in the air (see the code above) that will free-fall.</p>
<pre>private function update(e:Event = null):void
{
  world.Step(timestep, velocityIterations, positionIterations);
  world.ClearForces();
  world.DrawDebugData();
}</pre>
<p>And finally, we have the game loop. We tell the world to take a step, with values for the simulation frequency and the number of times per time step to calculate the velocity and the position of each body. Box2D requires us to clear the forces after every step so that things are cleaned up for the next step of the simulation. Then we draw the shapes and other debug information.</p>
<p>That&#8217;s it! We now have a world filled with bodies that exhibit dynamic, real-time physics. Now that we have all the basic pieces together, there are a number of things to try next. How about setting up a stack of dynamic blocks you can shoot balls at? Or how about creating a number of shapes and attaching them to the same body? Have fun experimenting, and share your ideas and thoughts in the comments.</p>
<h2>Download</h2>
<p>The source code for this project: <a href="http://www.devmag.org.za/downloads/box2dflash/Box2D_DevMag_Tut.zip">Box2D_DevMag_Tut.zip</a> (370 KB).</p>
<h2>Further reading</h2>
<ul>
<li>There are some useful nuggets in the <a href="http://www.box2dflash.org/faq">Box2DFlash FAQs</a>, and a heap of useful information can be found in the <a href="http://www.box2dflash.org/docs/2.1a/reference/">API Documentation.</a></li>
<li>Also read an interesting and in-depth tutorial on <a href="http://www.kerp.net/box2d/">how to create a Peggle clone in Box2D</a>.</li>
<li>The <a href="http://www.sideroller.com/wck/">World Construction Kit</a> is a powerful toolset for creating Box2D games in the Flash IDE.</li>
</ul>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/04/05/bzier-curves-a-tutorial/' rel='bookmark' title='B&eacute;zier Curves for your Games: A Tutorial'>B&eacute;zier Curves for your Games: A Tutorial</a> <small>A Bézier curve is a type of curve that is...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/05/27/box2dflash-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How are puzzle games designed? Teddy Lee</title>
		<link>http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/</link>
		<comments>http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/#comments</comments>
		<pubDate>Mon, 23 May 2011 17:11:34 +0000</pubDate>
		<dc:creator>Dev.Mag</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[Puzzle Game Design]]></category>
		<category><![CDATA[level design]]></category>
		<category><![CDATA[my first quantum translocator]]></category>
		<category><![CDATA[puzzle game design]]></category>
		<category><![CDATA[teddy lee]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4083</guid>
		<description><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/>Teddy Lee (maker of My First First Quantum Translocater and other popular Flash games) gives us his take on puzzle game design. <h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/' rel='bookmark' title='How are puzzle games designed? Dave Hall'>How are puzzle games designed? Dave Hall</a> <small>In this puzzle game design interview, Dave Hall from Toxic...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/' rel='bookmark' title='How Are Puzzle Games Designed? (Conclusion)'>How Are Puzzle Games Designed? (Conclusion)</a> <small>A distillation of the five puzzle game design interviews, taking...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="mfqt_banner" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/mfqt_banner.png" border="0" alt="mfqt_banner" width="680" height="340" /></p>
<p>Teddy Lee (from <em><a href="http://cellardoorgames.com/blog/">Cellar Door Games</a></em>) created several popular flash games, among them the platform puzzler <a href="http://www.newgrounds.com/portal/view/548371"><em>My First Quantum Translocator</em></a><em> (MFQT)</em>, the infamous adventure puzzle game <a href="http://www.kongregate.com/games/Rete/dont-shit-your-pants"><em>Don’t Shit Your Pants</em></a>, and recently <a href="http://www.newgrounds.com/portal/view/567595"><em>I Have 1 Day</em></a>, an adventure puzzle game with an interesting meta task-scheduling puzzle on top.</p>
<p><span id="more-4083"></span>In <em>My First Quantum Translocator </em>the player is trying to escape from a building, assisted by the mysterious <em>Steve</em> and of course a quantum translocator. The translocator can be used to teleport instantly from one position to another one previously set up, while maintaining momentum. Impassable, moving lasers and platforms that are too high to reach by jumping make up some of the difficulties the player has to overcome. In addition to brainpower, the game also requires some skill in performing the jumping and timing actions to execute solutions.</p>
<p><em>My First Quantum Translocator</em> was one of Indie Games’ selection of top 10 free puzzle games of 2010.</p>
<p>Below, Teddy Lee responds to our questions (part of our <a href="http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/">puzzle game design interview series</a>).</p>
<h3>Dev.Mag: What are the qualities of a good puzzle?</h3>
<p>A good puzzle to me is when the designer uses the core mechanic in ways players don’t expect. I feel like when we design something clever, players enjoy it just as much as we do.</p>
<h3>Dev.Mag: What process do you follow to design puzzles?</h3>
<p>When we made puzzles for My First Quantum Translocator (MFQT), we had a few guidelines which we tried our best to follow.</p>
<h4>1. Never re-use puzzles</h4>
<p>If two stages were too similar, we would can one of them. It makes things difficult since you’re always trying to do something new, but the end results are always worth it. We found that starting with the solution and then going backwards worked well for us.</p>
<p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="Excel Snapshot" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/ExcelSnapshot.png" border="0" alt="Excel Snapshot" width="680" height="427" /></p>
<p style="text-align: center;"><em>A lot of our stages were originally designed in an Excel doc before being put into the game.</em></p>
<h4>2. Each room highlighted one trick, or mechanic</h4>
<p>If you add too many steps to a puzzle you lose the player because you can’t always assume the player is following your train of thought.  We also removed any filler/time wasters/red herrings in order to keep this visual clutter to an absolute minimum (unless the puzzle itself was a red herring).</p>
<h4>3. Do not have any “Misleading Paths”</h4>
<p>This means that if our player is doing a puzzle incorrectly, they should immediately know they are doing it wrong.</p>
<p>For example, if you are playing a platformer, and the user is always just millimeters away from making a jump, then the user might keep trying to make that impossible jump. So we spent a lot of time trying to remove every possible instance of a “Misleading Path”.</p>
<h4>4. The joy in solving a puzzle games is in the success, not the attempts</h4>
<p>The core mechanics for MFQT required a certain amount of dexterity on the player’s behalf, but we tried our best to keep it to a minimum while still retaining the core feel of the stages.</p>
<p>For example, we added the “tele-jump” later in the game which automatically jumped and teleported the player. That way they no longer had to pull off that difficult maneuver.</p>
<p>In one of our more skill-based levels, we revamped the bottom right junction and stretched the upper platforms.</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td style="text-align: center;" width="340" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="Old Wall Ceiling Move Stage" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/OldWallCeilingMoveStage.png" border="0" alt="Old Wall Ceiling Move Stage" width="330" height="249" /><em>Old level.</em></td>
<td style="text-align: center;" width="340" valign="top"><img class="aligncenter size-full wp-image-4095" title="New Wall Ceiling Move Stage" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/New-Wall-Ceiling-Move-Stage1.png" alt="" width="330" height="247" /> <em>New level.</em></td>
</tr>
</tbody>
</table>
<h3>Dev.Mag: In a sequence of puzzles based on a small set of mechanics, how do you make sure the puzzles stay interesting?</h3>
<p>The misconception is that having a small set of mechanics means you’ll be very limited in the things you can do. That’s not necessarily the case though.  As long as you can keep wringing out new puzzles from the core mechanics, then the game will stay interesting.</p>
<p>A rule of thumb I follow is if I can think up five or more puzzles on paper with a single mechanic, then there’s a good chance I can come up with plenty more later on.</p>
<h3>Dev.Mag: How do you judge whether a puzzle is fun, and how difficult it is to solve?</h3>
<p>It’s impossible to know off the bat whether a puzzle is fun or not.  The only thing you can do is playtest it, and if you like it, have someone else playtest it and see if they like it.  If we don’t enjoy completing a level though, we usually look at it and see what’s not fun about it. That way we won’t make the same mistake again.</p>
<p>As for difficulty, we generally base that off of how much dexterity is required to complete a stage, and how much of the stage’s puzzle is built off of previous knowledge.  Of course, extensive playtests from other people help us isolate the trouble spots.</p>
<p>When designing MFQT, we also staggered puzzles which had a similar theme (such as modifying trampoline bounce height) so that players wouldn’t get similar puzzle types in a row. We also staggered the difficulty, so that after a particularly difficult stage, a player might bump into a few easy ones to sort of keep their morale high. Small things like that helped to keep the game fresh.  We had to tweak the stage layout for our game a couple of times to get it to where it is.</p>
<p>One of our regrets with MFQT was the second last level (the rotating squares with the red cross). I really liked the level, but in the end a lot of people couldn’t complete it.  Even though we had a skip button, nobody really wanted to use it, especially when they were so close to the end.</p>
<p><em><a href="http://devmag.org.za/blog/wp-content/uploads/2011/05/Quantum_Compilation_Change1.png"><img style="display: block; margin-left: auto; margin-right: auto; border: 0px initial initial;" title="Quantum_Compilation_Change" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/Quantum_Compilation_Change_thumb.png" border="0" alt="Quantum_Compilation_Change" width="680" height="51" /></a> This image shows how levels have been re-arranged over time. Click on it for a larger view.</em></p>
<h3>Dev.Mag: Do you use strategies in your design to guide the player towards the solution, and help them understand the logic of the puzzles?</h3>
<p>When we design a puzzle, we try to keep visual clutter to minimum so as to not distract the player from the actual goal.</p>
<p>Also, when the solution requires a certain amount of dexterity, we sometimes leave visual “markers” so that players know where to position their attempts. For example, in our “elevator” stage in MFQT, we used 2 background assets as indicators to show the player when to jump, and when to set a shadow.  That way, when a player knows the solution, they have some type of marker they can compare themselves to in order to refine their solution.</p>
<p style="text-align: center;"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="Elevator Indicators" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/ElevatorIndicators.png" border="0" alt="Elevator Indicators" width="641" height="480" /><em>Level with markers to help the player time actions.</em></p>
<h3>Dev.Mag: Do you have any advice for those who want to design their own puzzles?</h3>
<p>Make sure to iterate, refine, and polish your stages off. I feel like many designers making puzzle games think they can skip these steps since their games may require little to no dexterity. So you end up with all these physics based puzzle games, where the solution always end up being more about pixel perfect placement and less about clever solutions.</p>
<p>Oh, and if you run into problems with a level and things aren’t working out, don’t be afraid to cut. It’s always better to have someone beat your game than not.</p>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/' rel='bookmark' title='How are puzzle games designed? Dave Hall'>How are puzzle games designed? Dave Hall</a> <small>In this puzzle game design interview, Dave Hall from Toxic...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/' rel='bookmark' title='How Are Puzzle Games Designed? (Conclusion)'>How Are Puzzle Games Designed? (Conclusion)</a> <small>A distillation of the five puzzle game design interviews, taking...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How are puzzle games designed? Dave Hall</title>
		<link>http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/</link>
		<comments>http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/#comments</comments>
		<pubDate>Mon, 16 May 2011 17:08:54 +0000</pubDate>
		<dc:creator>Van Wyk Louw</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Game Design]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[Puzzle Game Design]]></category>
		<category><![CDATA[dave hall]]></category>
		<category><![CDATA[level design]]></category>
		<category><![CDATA[puzzle game design]]></category>
		<category><![CDATA[qube]]></category>

		<guid isPermaLink="false">http://devmag.org.za/?p=4057</guid>
		<description><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/>In this puzzle game design interview, Dave Hall from Toxic Games tells Dev.Mag how they designed the puzzles for Q.U.B.E.<h2>Related posts:</h2>
<ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/' rel='bookmark' title='How are puzzle games designed? Teddy Lee'>How are puzzle games designed? Teddy Lee</a> <small>Teddy Lee (maker of My First First Quantum Translocater and...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/' rel='bookmark' title='How Are Puzzle Games Designed? (Conclusion)'>How Are Puzzle Games Designed? (Conclusion)</a> <small>A distillation of the five puzzle game design interviews, taking...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<img src="http://devmag.org.za/blog/wp-content/uploads/2010/12/devmag_orange.png" width="29" height="29" alt="" title="Development" /><br/><p><img style="display: block; float: none; margin-left: auto; margin-right: auto; border: 0px;" title="qube_banner" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/qube_banner.png" border="0" alt="qube_banner" width="680" height="340" />Dave Hall is one of the founders of Toxic Games, the studio that created the compelling first-person 3D platform puzzler <em><a href="http://www.qubegame.co.uk/">Q.U.B.E.</a></em> As part of our <a href="http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/">series of puzzle designer interviews</a>, we asked Hall about the methods he used to design <em>Q.U.B.E.</em>’s puzzles.</p>
<p><span id="more-4057"></span></p>
<p>In <em>Q.U.B.E.</em> (<em>Quick Understanding of Block Extrusion</em>), players find themselves trapped in a mysterious facility where the walls are made from countless white cubes. Through a weird device attached to the players’ arm, some coloured cubes can be extruded, and with a bit of thought, the player can arrange these to form a route to escape each level. The game was inspired by the student film <em>The Room</em>.</p>
<p><em>Q.U.B.E.</em> was a nominated for the Best UDK Singleplayer indie of 2010, and it was a finalist in the non-professional category of the Indie Game Challenge.</p>
<p>http://www.youtube.com/watch?v=s21rMdmM0VA</p>
<p>Dave Hall answers our questions below.</p>
<h3>Dev.Mag: What are the qualities of good puzzle design?</h3>
<p>In a good puzzle the objective is always clear and it is easy for the player to understand the rules that the puzzle is based around. It should also be easy for the player to get started.</p>
<h3>Dev.Mag: What Process do you follow to design puzzles?</h3>
<p>I always start with the objective for the puzzle. For example; ‘how can I reach that platform?’ From there I think of the different ways that the player could reach that objective. In the early stages of development I would create a plan for each level on paper before creating anything in-engine.</p>
<p>However, it can be difficult to plan out every aspect of a puzzle because it doesn&#8217;t always work the same way in-engine. Now the first thing I do is create a prototype, then I test it and iterate on it until it works.</p>
<table border="0" cellspacing="0" width="680">
<tbody>
<tr>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution1" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution1.png" border="0" alt="solution1" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution2" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution2.png" border="0" alt="solution2" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution3" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution3.png" border="0" alt="solution3" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution4" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution4.png" border="0" alt="solution4" width="160" height="116" /></td>
</tr>
<tr>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution5" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution5.png" border="0" alt="solution5" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution6" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution6.png" border="0" alt="solution6" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution7" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution7.png" border="0" alt="solution7" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution8" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution8.png" border="0" alt="solution8" width="160" height="116" /></td>
</tr>
<tr>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution9" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution9.png" border="0" alt="solution9" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution10" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution10.png" border="0" alt="solution10" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution11" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution11.png" border="0" alt="solution11" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution12" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution12.png" border="0" alt="solution12" width="160" height="116" /></td>
</tr>
<tr>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution13" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution13.png" border="0" alt="solution13" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution14" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution14.png" border="0" alt="solution14" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution16" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution16.png" border="0" alt="solution16" width="160" height="116" /></td>
<td width="170" valign="top"><img style="display: block; float: none; margin-left: auto; margin-right: auto; border-width: 0px;" title="solution17" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/solution17.png" border="0" alt="solution17" width="160" height="116" /></td>
</tr>
</tbody>
</table>
<p><em>Solving a prototype puzzle. </em></p>
<h3>Dev.Mag: How do you design a series of puzzles based on a small set of mechanics that keep the players interest?</h3>
<p>When we introduce a new mechanic, we introduce it on its own so that the player can learn how different objects behave without having everything explained to them. Every puzzle in the game is based around the same set of rules. As the player progresses through the game they gain a better understanding of these rules, which allows them to complete more complex puzzles.</p>
<h3>Dev.Mag: How do you judge whether a puzzle is fun, and how difficult it is to solve?</h3>
<p><img style="display: inline; margin: 0px 10px 0px 0px; border-width: 0px;" title="qube1" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/qube1.png" border="0" alt="qube1" width="200" height="200" align="left" /> This is where playtesting is important. If a player gets stuck on a puzzle, then they may become frustrated and quit. Sometimes players will not realise something that I thought was quite obvious.</p>
<p>In other cases a puzzle will be designed to be completed a certain way, but some players will find another way to complete it. If you watch someone playing your game or ask them about it after they finish playing, you can find out what they enjoyed and if they were ever stuck, as well as other important information.</p>
<h3>Dev.Mag: What devices do you use to guide the player towards the solution?</h3>
<p><img style="display: inline; margin: 0px 10px 0px 0px; border: 0px;" title="qube2" src="http://devmag.org.za/blog/wp-content/uploads/2011/05/qube2.png" border="0" alt="qube2" width="200" height="200" align="left" /> The objective should always be clear and the player should understand how each object functions. I always try to make it easy for the player to see everything they need to complete a puzzle. It is also good if the player knows when they are getting close to completing the puzzle.</p>
<p>Many of the puzzles in <em>Q.U.B.E.</em> are in stages. They start out simple so the player understands what they have to do. As they progress, each stage gets more complex, but is still based around the same rule-set.</p>
<h3>Dev.Mag: Do you have any advice for those who want to design their own puzzles?</h3>
<p>When thinking of new ideas for puzzle, always start simple and then build out from there. Make sure the objective is clear and the player understands the rules. It is also important to start testing as soon as possible. You may think you have a good idea , but you don&#8217;t really know until someone else plays it.</p>
<h2>Related posts:</h2><p><ol>
<li><a href='http://devmag.org.za/2011/05/09/how-are-puzzle-games-designed-ted-lauterbach/' rel='bookmark' title='How are puzzle games designed? Ted Lauterbach'>How are puzzle games designed? Ted Lauterbach</a> <small>Ted Lauterbach, creator of the eerie puzzle game, suteF, answers...</small></li>
<li><a href='http://devmag.org.za/2011/05/23/how-are-puzzle-games-designed-teddy-lee/' rel='bookmark' title='How are puzzle games designed? Teddy Lee'>How are puzzle games designed? Teddy Lee</a> <small>Teddy Lee (maker of My First First Quantum Translocater and...</small></li>
<li><a href='http://devmag.org.za/2011/04/26/how-are-puzzle-games-designed-rob-jagnow/' rel='bookmark' title='How are puzzle games designed? Rob Jagnow'>How are puzzle games designed? Rob Jagnow</a> <small>As part of our series of interviews on puzzle game...</small></li>
<li><a href='http://devmag.org.za/2011/06/04/how-are-puzzle-games-designed-conclusion/' rel='bookmark' title='How Are Puzzle Games Designed? (Conclusion)'>How Are Puzzle Games Designed? (Conclusion)</a> <small>A distillation of the five puzzle game design interviews, taking...</small></li>
<li><a href='http://devmag.org.za/2011/05/02/how-are-puzzle-games-designed-guy-lima/' rel='bookmark' title='How are puzzle games designed? Guy Lima'>How are puzzle games designed? Guy Lima</a> <small>Dev.Mag talks to Guy Lima, one of the founders of...</small></li>
<li><a href='http://devmag.org.za/2011/04/16/how-are-puzzle-games-designed-introduction/' rel='bookmark' title='How are puzzle games designed? (Introduction)'>How are puzzle games designed? (Introduction)</a> <small>This article gives some background information on puzzle games, and...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://devmag.org.za/2011/05/16/how-are-puzzle-games-designed-dave-hall/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

