Posted on



The Noob

Almost exactly six months ago, I decided to embark on an adventure. Before October of 2010, I had never programmed a day in my life. Okay maybe I had a week-long unit on the very very very basics in sixth grade. But that is all. I had no idea what to expect. October 19th, 2010, I tweeted: “What have I gotten myself into. I’ve just embarked on learning programming, having absolutely no experience. Oh man I’m already nervous.” That was the beginning of a path that I’m so glad I have taken. I’m not looking back.


I’m going to give you a quick overview of my first few months, because it was pretty boring. I started with Invent with Python, a really awesome book for complete noobs. To show you how beginner it was, here is a quote from the book: The + sign tells the computer to add the numbers 2 and 2. To subtract numbers use the – sign, and to multiply numbers use an asterisk (/*).

After I got the very basics down, I made a bunch of random text-based games, like hangman, jotto, and guess-the-number. My first big hit was a game called “The Man-Rodent.” It was about a Man-Rodent, whatever the hell that is, who was terrorizing the village. He was hiding, and you had to guess where he was:

This was also when I received my first piece of cherished fan art. I posted the game on Reddit and Michael Hussinger made this AMAZING cover art for it:

Next, I moved on to my first quasi-graphics based game: Minesweeper. This is when I really started to understand why creating a flexible game engine is really important (yeah, like I created a game engine). The game was still text-based, but it was completely flexible, in that I could specify board size and mine amount. This ended up giving it some replayability and it was fun to play around with crazy numbers just to see what happened. Here’s that game:

Welcome to iOS

At this point, I felt I was ready to move on to actual graphics. I felt at an impasse. I had absolutely no idea where to start. I took a look at SDL but was in way over my head and got quickly discouraged. Since I knew I eventually wanted to make an iPhone app, I asked Matt Rix (Trainyard), who gave me some sage advice. He recommended I start by learning C, then Objective-C, then Cocos2d. I’m happy to say that as of today, I’ve learned all three of those! The basics anyway.

During the period of learning the basics of C and Obj-C, I came across a lot of frustrations and I didn’t make many games. Many times, I really wondered if I could ever get past the hurdle and figure it out. A few of the things that I pulled my hair out over when I first learned of them: structs, arrays, multi-dimensional arrays, properties, views, view controllers, protocols and delegates, memory management and many more. And there is still so much out there that is way over my head. But I’m going to keep trucking because everyone I talk to says the only way to get better is to just keep making games. Being a piano player, I am well aware that practice pays off, so that’s what I’ve been doing (and will keep doing).

Welcome to Cocos2d

Once I finally got the basics of creating an iPhone app down, I was ready to delve into Cocos2d. I was nervous but excited. Now, I don’t know if I’m crazy or stupid but I have found that the Cocos2d documentation is not very good. All the classes, methods, and properties are listed, but I am constantly struggling to understand things because they are not explained well. An example: every “node” (the main Cocos2d element) has a “(BOOL) isRunning” property. It sounds simple enough, but it could easily mean any number of things. All the documentation says about this property is: “whether or not the node is running.” Uh, okay . . . Needless to say, I’m still pretty confused about a fair amount of things in Cocos2d.

But enough of the insults. I am loving Cocos2d. Once I got a hang of the basics, I started to see how much easier it was to get a simple game up and running in no time. And since I already know how to do music and sound, and also know a little bit of Photoshop, I was really starting to see some pretty cool results. Since I was really confused by Cocos2d at first, I started with a few of Ray Wenderlich’s awesome tutorials.

A Bunch of Sorta-Games I’ve Made

Here is my first Cocos2d game, which I created by directly following Ray’s tutorial (it even had my own music and stupid sound effects for when an enemy died!):

Next, I made a Pong clone. It even had multiplayer!:

After Pong, I was feeling encouraged, and decided to try to make Tetris. Big mistake. I was not ready. I ran into a lot of really annoying errors and bugs, and when I finally got the basic framework down, I tweeted something like: “So proud of myself. I just created a really complex class/subclass system for my Tetris clone.” Noel Llopis quickly informed me how bad of an idea that was. So I looked at some tutorials and tried to completely revamp my Tetris clone, but it was still too difficult. I will return and defeat you one day, Tetris!

After my failed attempt at Tetris, I made a little Tilt to Live inspired prototype, except in this version, you get points for collecting red dots, instead of avoiding them. And this one didn’t have the music I did for the real game (that is a link to the Tilt to Live soundtrack. Buy it now or red dots will eat you while you sleep.):

After a lot more learning of Cocos2d, I had a random inspiration to make an endless crumpled paper background. So I crumpled paper and made it an endless background. Then I put a little paper circle in the game that you could roll around using the accelerometer. I was really proud of myself when I figured out how to roll the circle because it involved some math that I hadn’t done in a long time (even though it was fairly simple trigonometry). The background was buggy – there were frequently gaps between the images of the repeating background – but it worked:

Next, after seeing a trailer for the awesome looking upcoming game Bumpy Road, I got inspired and wondered if I could recreate an effect similar to its bumpy road element. Needless to say, my graphics were a bit more barren, but you can compare.

Bumpy Road:

My version:

After this, I wanted to try my hand at actually animating something. I had never animated anything before and gave it a go on Photoshop. Man was it tedious. Even for just a stupid little line drawing. But what I came up with was who I like to call PARTYMAN. All he did was open and close his mouth over and over again, each time making a randomly chosen grunt noise. You could also move him around the screen. And the background flashed different colors. And he only grunted and partied when you were actually touching the screen:

Somehow, PARTYMAN gained a small following. I think he might be next in the long list of icons including Mario, Link, Samus, and others. I actually ended up sending a copy to Jared of Touch Arcade (hey, he asked for it). Then, to my great surprise and utmost joy, Craig Sharpe of Retro Dreamer created my second official piece of fan art! Here is Craig’s AWESOME take on PARTYMAN:

His drawing was so awesome, in fact, that I had to include it in one of my next games. But first, on a whim I started making a game about a guy jumping over poles. The original point was just to see if I could make a parallax background with a simple game mechanic, but I just kept going with it. It ended up having a title screen, score-tracking, replayability, music, sounds, variable jump heights, a jump height progress bar indicator, and even a credits page! It was my most complete game yet. I drew some pretty awful sprites for my game, as you can see here:

Since my drawings sucked, I asked Michael Hussinger (of “The Man-Rodent is in the Barn” fame) if he wanted to do a few quick doodles for it, and he did! He drew this awesome pizza guy in probably 20 minutes. It would take me hours upon hours to draw something that good, if I even could at all. He also drew a nice mountainous background for my parallax scrolling. Here’s how the game looked after his help, along with my title and credits pages:

The game in action!

My next game was inspired by Trainyard. I wanted to see if I could create a grid that I could draw roads on that a vehicle would follow. What better opportunity for a return of PARTYMAN, right? So I called it Partybus. The point of the game was to click a spot on the grid to make a party (a flashing, color-changing spot with music coming out of it), then to draw a road to the party and have PARTYMAN drive there in his Partybus. Needless to say, it was a really easy game. But the cool thing is, when he reached his party destination, the music got louder and bassier, the bus started doing a dance, and Craig’s fan art of him appeared above the bus and started shaking to the beat!

The code was very buggy and pretty damn broken. I tried to have my brother play the app and it took him three tries to do anything at all because he would click the wrong square at the wrong time and it would basically ruin the game. And I would have to completely restart the app each time because I didn’t build in a “restart” feature. But I was still pretty proud of my crappy Trainyard ripoff. Matt should pay me for it.

My next project was a Snake clone. I found this tutorial on how to build Snake in flash and basically just ported it to iPhone. It gave me a lot of insight into how to make this game. Before the tutorial, I was planning on having the snake move once per frame, but was having a lot of trouble figuring out how to make his tail follow him. I was considering building up an array of all the past moves and assigning them to each of his tail pieces every tick, but that would have gotten really annoying really fast. This tutorial flipped my world upside down when I realized the Snake was not actually moving. Instead, the illusion of movement was given by simply adding and removing snake pieces from the grid on every frame. Then, when you picked up an apple, all it did was tell the program not to remove any pieces for five turns. I need to remake this game for sure, because the UI sucked, the controls were awful, and the code was pretty messy due to my hacked together port. But for a basic Snake game it turned out pretty well!

After Snake I tried making Partybus 2: Partyman’s Big Weekend. I got a little further than before. Ended up adding a speed slider like in Trainyard, a depot that the train could leave from, sound effects (when he crashed there was the sound of a massive car accident and he yelled “No partying today!”) and just overall cleaner code. But again, I soon ran into entangled code and whenever I tried to fix one thing, another thing wouldn’t work. My biggest problem was that when I set the speed slider all the way to its highest value, the bus would crash at a random joint in the road. This was due to the updates being called too often and the code not updating enough before the next tick. Even though I sort of knew what the problem was, it would take too much work to go back and fix it. I think I will have to make a Partybus 3: The Final Party.

My most current project is a remake of Doodle Jump. So far it’s coming along quite nicely. I have platforms that keep moving higher and higher, a jumper guy, some items (well, so far only a spring), custom music and sounds, and a UI that totally rips off the original game. I’m pretty happy with this one so far. I’m going to try to keep adding a bunch of stuff to it.


It truly is amazing how much practice helps. Every time I write a new program, I run into a ton of unforeseen problems and bugs. While frustrating at the time, I usually plan around them the next time I program. This makes me feel like I’m in my very own while loop:

while (stillPrettyBadAtProgramming) { programmingPracticeTime++; Program /*newProgram = [Program programWithType:ProgramTypeGame]; if (newProgram.isReallyGood == YES && programmingPracticeTime >= A_HUGE_AMOUNT) { stillPrettyBadAtProgramming = NO; } }

I’m going to keep creating. It’s been a blast so far, and I can’t wait to see what the next six months entails. Be sure to return next time, when I will talk about the long process that went into making the music (and a few sounds) for Casey’s Contraptions!

来源: [http://www.whitakerblackall.com/blog/first-six-months/](http://www.whitakerblackall.com/blog/first-six-months/)


几乎刚好是6个月前,我决定开始从事一项新的职业。2010年10月之前,我从未接触过编程。要说有,那也只是在6年级时学过了大概一周的非常基 本、基本、基本的编程知识。就这些。我不知会学成什么样。2010年10月9日我在微博上写道:“我究竟想干吗?我决定学习编程,我没有任何的基础。唉, 兄弟们,我有些担心。”这是一段生涯的开始,我很高兴能走上这条路。我不会回头。


我将只快速简单的给你们讲一下我前几个月的学习过程,因为这段时间非常的枯燥。我从Invent with Python这本书开始,这是一本对新手来说非常不错的教程。为了让你们知道它是如何的初级,我向你们展示这本书里的一段话:

  • 这个符号是来告诉计算机把2和2相加。做减法用这个符号 -,做乘法用星号(/*)。


也就是在此时我收到了我的第一张珍贵的粉丝画的作品。我把这个游戏发布在了Reddit上,Michael Hussinger为它制作了这张令人惊叹的封面画:

接下来,我转移到了我的第一个半图形游戏:”扫雷“。在此时我才开始真正的理解构造一个灵活的游戏引擎有多么的重要(没错,就像我开发的这个游戏引 擎)。这个游戏仍然是文本形式的,但已经有相当的灵活度了,在这个游戏里,我可以指定布景的大小和地雷的数量。这样一来游戏就可以从头再玩,你可以把地雷 数量设置很小而很快能看到游戏的结果,这样有趣多了。下面就是这个游戏:


此时,我已经感觉到应该转向真正的图形游戏了。我感觉陷入了僵局。我根本不知道从哪里入手。我研究了一下SDL,这个东西超过了我的接受能力,我很快放弃了。因为我知道最终我想做iPhone应用程序,我请教了Matt Rix (Trainyard),他给了我一些很好的建议。他建议我从学C语言开始,然后学Objective-C,然后Cocos2d。今天说起这些我很快高兴,这三种语言我都学会了,虽然很基础。



一旦我最终把iPhone应用的基本知识攻克下,我立即开始研究Cocos2d。我很紧张,也很兴奋。现在,我不知道自己是太挑剔还是太笨,我感觉 Cocos2d的文档写的不太好。所有的类,方法,属性都列出来了,但却很难让人读懂,它们解释的不太清楚。一个例子:每个”node“(Cocos2d 的主要元素)都有一个”(BOOL) isRunning“属性。看起来非常的简单,但它似乎能够表示任何意思。所有的文档对这个属性的解释都是:”标志这个node是否在运行。嗯,ok … 不用说,Cocos2d里面有很多东西我都十分的困惑。

尽管这些的不满,我还是非常喜欢Cocos2d。一旦掌握了一些基本知识,我就开始研究它如何能够容易的做出一个简单游戏,让它马上能跑起来。我已经知道了如何做音乐和声效,我还知道一些Photoshop,我就真的开始要让它输出一些很酷的结果了。起初我对Cocos2d很困惑,我从Ray Wenderlich的一些非常棒的教材开始学习。




Pong之后,我受到了鼓舞,决定开发Tetris。这是个巨大的错误。我根本没有准备好。我遇到了各种让人懊恼的错误和问题,当我最终把框架搭起来后,我在微博上写了这样的话:“我很骄傲。我为我的Tetris仿品开发了一个真正复杂的类/子类系统。”Noel Llopis很快的告诉我,说我的决定十分的错误。我搜集了一些教材,试图好好的修改一下这个仿Tetris游戏,但太困难了。我决定放弃,但有一天我会打败你的,Tetris!

这次Tetris失败的尝试之后,我受Tilt to Live的启发做了一个游戏初始原型,我计划在这个游戏里,你需要去收集红点来获取积分,而不是像其它游戏里去避开它们。现在做的这个里面并没有加入真正的游戏里面会有的音乐:

学习了更多的Cocos2d之后,我突然来了灵感要做一个循环的褶皱纸样式的背景。于是把一张纸做出褶皱型,以循环方式填充背景。然后我在上面放了 一个小圆片,你可以用加速器让它在上面滚动。当我弄明白如何让这个小圆片滚动后,我为自己能做出这个东西很自豪,因为这牵涉的一些数学知识,我并没有用很 久的时间就把它能明白了(尽管只是一个很简单的几何问题)。背景很难看 —— 但很好用:

接着,当我看到了即将发布的游戏Bumpy Road的令人惊讶的海报后,我受启发,心想是否能够也做一个跟里面的高高低低的路面相似风格的游戏元素。很显然,我的做图水平很有限,你可以比较一下。

Bumpy Road:


这之后,我想在真正的动画上试试身手。以前从没有做过动画,先在Photoshop试试。人物的制作很乏味冗长。即使是画一条很傻很短的线条也很费 劲。但我还是完成了,我把他称作“狂欢者”。他能做的就是一遍遍的张开和闭上他的大嘴,每次都随机的发出一些哼哼声。你还可以在屏幕上移动他。背景闪动不 同的颜色。当你触碰屏幕时,他只能哼哼和张嘴:

然而,“狂欢者”有了一小队粉丝。这些粉丝的头像图标里包括Mario, Link, Samus,等等。事实上我把这个游戏发给了Touch Arcade的Jared(嘿,是他向我要的)。之后,让我大吃一惊和无比高兴的是,Retro DreamerCraig Sharpe创作了我的第二张正规的粉丝的艺术作品!下面就是Craig为“狂欢者”创作的杰作:

他的作品是如此的优秀,我甚至把它放入了我的下一个游戏里。但起初,我突发奇想,要做一个跳杆子的游戏。起初的出发点只是为了使用一个简单的游戏技 术测试一下视差背景的效果,但做下来就做成了这个游戏。最终的游戏有一个小屏幕,有记分功能,有重玩功能,有音乐、音效,各种跳跃高杆,有一个高度指示 器,甚至还有一个鸣谢页面!它是我的功能最全的一个游戏。我在游戏里画了一些非常丑陋的精灵,就像你下面看到的:

因为画的太差,我询问Michael Hussinger是否愿意为我做一些简单的修改,他同意了!他在二十分钟内就画出来一个让人惊叹的匹萨伙计。我估计花几个小时也画不出这么好的作品来。他还为游戏中的视差效果画了一个漂亮的山作为背景。下面的就是在他的帮助下游戏的样子,我加上了标题和鸣谢页:


我的下一个游戏受Trainyard的启发。我想看看是否能做出 一个地图,上面画些网格道路,卡车能跑在上面。看看,制作“狂欢者”有了很好的回报。所以我称这个为“狂欢大巴”。游戏的玩法就是点击地图上的一个地方就 设定一个聚会点(一个闪烁的,颜色变换的点,伴有音乐),然后图上会画出一条路,通向这个点,“狂欢者”会把他的“狂欢大巴”开到那里。不用说,这是一个 非常简单的游戏。但里面很酷的东西是,当他到达目标地点后,音乐声会变大,卡车会开始跳舞,Craig画的作品会出现在开车上面左右摇摆!

代码写的很乱,有很多问题。我让弟弟试玩了一下,他式了三次,什么都没干成,他总是每次都是在错误的时间点击到错误的地方,这样游戏根本就不能正常 玩下去。每次我都要从头开始玩这个游戏,因为我没有给它加入“重新开始”的功能。但我还是挺为这个Trainyard的复制品感到自豪的。Matt应该为 此感谢我。

我的下一个项目是要做一条蛇。我发现了这个如何用flash做出一条蛇的教程, 我只需要把它移植到iPhone上。这个教材让我明白了很多如何做这种游戏的内幕。之前,我计划让蛇每一帧移动一次,但在如何让蛇尾和蛇身保持一致的问题 上遇到了很多的麻烦。我本打算建一个数组存所有历史动作,蛇尾将按照这个数组里的信息做它的每个动作,但这样一来它动的太快,让人很不舒服。这个教程整个 颠倒了我的思维,我意识到蛇其实根本没有动。这种看起来在移动的视觉效果其实是简单的在帧上添加和移去一小段蛇身产生的。这样,当你捡起一 个苹果,所需要做的只是告诉程序不要删除任何片段。事实上我需要重新写这个程序,因为界面太难看了,控制的也不好。因为我是移植过来的,代码写的很乱。但 事实上作为一个基本的游戏来,它还是很不错的!

在完成这条蛇之后,我打算制作“狂欢大巴2”:“狂欢者”的周末狂欢。我把上一版升级了一些。我在里面加入了一些Trainyard里面的速度条, 一个车站,车可以从里面开车,一些声音特效(当他被碰着时会出现很大的汽车相撞的声音,而且会喊出“今天没有活动!”),程序也整理的更整洁了。但没多 久,程序又开始变乱,当我要纠正一个问题时,另外一个东西又出现了问题。最大的问题是当我把速度设成最大时,卡车会在路上某个点崩溃。这是因为更新调用的 太频繁,程序来不及在下一次调用前更新完。尽管我知道这个问题的原因,如想修复这个问题需要重做大量的东西。我想我需要升级到“狂欢大巴3”:最后的狂 欢。

我最近的目标是重做Doodle Jump。目前为止一切进展顺利。里面很多小平台,移动速度会约来越快,一个会跳的小人,一些其它物品(目前为止只有一个弹簧),自定义音乐和声效,以及完全从原作里拷贝的背景。目前为止我对做出的东西很高兴。我会继续往里面增加很多的东西。


练习给人带来的进步是惊人的。每次当写出一个新程序,我都会遇到大量的无法预知的问题和bug。当遇到挫折时,我一般是将问题移到下一次升级时解决。这让我感觉自己就在走一个while循环: while (编程技术仍然很糟) {

  程序 /* 新程序 = [程序 程序类型:游戏];

  if (新程序.做的很好吗 == 是的 && 练习时间 >= 大量) {
      编程技术仍然很糟 = 否;



我会一直这样制作下去,一转眼就到现在了,我几乎等不及想知道再6个月后会是什么样。请下次当我来述说如何给Casey’s Contraptions制作音乐(和一些声音)时,请记住一定来看看!

本文由“外刊IT评论”网(www.aqee.net)荣誉出品 [英文原文:My First Six Months of Programming: From Man-Rodent to Partyman ]

来源: [http://www.aqee.net/first-six-months/](http://www.aqee.net/first-six-months/)

转载请注明作者(RobinChia)和出处 It so life ,请勿用于任何商业用途