Video Game Artifacts

Isn’t it beautiful? There is something hypnotic about that watching that video game – Robotron 2084. The levels are all fundamentally the same, and the action always takes place in an open arena.

But later, the enemies start getting silly. Glowing circles, rainbow-color-changing enemies, and, my personal favorite, the number “2084” shooting stuff at you.

Some of these enemies actually take advantage of graphical artifacts from that era of computing, such as indirect color registers, which store color information outside of the screen buffer. By changing a single register, you change the color of every pixel on the screen. By running through a loop and changing this register, you create flashing and color change effects.

I like this aspect of graphics : Playing with registers to create a cool graphical effect.

Fun stuff.

How to Code

I love this programming article by Terri Burns on Rookie Magazine! I could probably just retweet/share/like it, but I wanted to add my own $0.03 worth (up from $0.02 because I’m more opinionated than most…)

A step-by-step process:

1 Consider your Interests.

What I really want you to do here is to pick a platform. Do you want to write a game? What will people use to play it? Will they play your game in their web browser? On an iPhone? An Android? Or would you rather write a game within Minecraft that people play on a Minecraft server?

A web game will require you to learn JavaScript, and probably a game engine like EaselJS or Phaser. You will also need minimal HTML5 and CSS3 skills.

An iPhone game requires you to learn Objective-C or the Swift language. Android and Minecraft both require Java skills. There are loads of books targeted at Language and Platform, and you want to start with materials that apply to both. Don’t just pick up a generic HOWTO Java book when there are so many materials specialized to your needs.

2 Pick a Language

If you’ve done your job in step 1, then you may skip this step. But if you have a choice here one way or another, consider this: Many starting developers want to learn a language that’s hot, and a language that’s new.

And that’s exactly what you SHOULD do!!!

Github has an index showing language popularity in its open-source projects.  These languages are constantly changing by improving and adding new features for programmers to utilize. There is a reason for this : These new features help developers do more powerful things with less headache.

When it comes to programming languages, modern is better. Popular is better. Don’t learn an obscure language just because your programmer buddy tells you how Elite it is.

3 Learn It!

If you want to code, you must do two things: read code and write code.

Get a book with lots of examples, and watch YouTube videos. Pause the videos and type in the exact code the tutors are demonstrating. You really will learn by doing this! Follow your curiosity and try things. You can’t break it. Get a StackOverflow account and ask questions. Don’t worry if the moderators mark it as duplicate or ask you for more details. You are learning and that is the point!

4 Consider your Resources

YouTube videos, Safari Books Online, the library (often with free online resources!)… The list goes on. The less structure, the better! Don’t sign up for a course unless you really want the fundamental theory and mathematics. You don’t need university courses unless you’ve decided to make this your career. Programming can be a hobby just like sewing or landscaping!

5 Join Communities

Join Meetup.com or check around your local universities for groups with similar interests – Not just programming, but programming on the platform using the language you’ve picked.

Once you start working with other developers, you will be bombarded with a torrent of cases and tricks and techniques you never dreamed existed. You’ll start to get the feeling that you really didn’t know anything in the first place. That’s OK! Programming is a deep field that takes years to master. Learn, build, and don’t worry about it.

6 Build Something

It takes reading and writing to learn coding, but it you have to try to build something unique to really test the limits of your knowledge. Expect to spend a lot of time debugging and trying to figure out why things don’t work.

This is where tools are important. A good Integrated Development Environment (IDE) is important here (the books you picked in step will tell you which IDE to use). Take the time to learn the features of the IDE, especially the debugger and code refactoring. And I highly recommend you learn git or some other Version Control System (VCS). It gives you a backup for all of your work and allows you to track changes. You’ll be happy you learned it the first time you break a working program and need to revert to a working version.

Don’t worry if it’s not perfect! It’s yours! It works! You made something, and that is really cool!

7 Keep it Up!

If you want to be a software developer, develop software. It is its own field. Programming is unlike any other discipline. It is not science, it is not engineering, it is not business, it is not art.

We design, gathering and assembling the pieces we will need to realize our vision.

We write, carefully considering the expressiveness of what we write. The future of the project often rests on the quality of the code.

We solve problems, using math and technology to light the way.

It’s a fun hobby.

It’s an awesome career.

Functional JavaScript

Fun Fun Function is a wonderful video series for learning JavaScript and functional programming. I decided to try my own Map/Reduce filter in JS and uploaded it to my toybox. Some random notes of things I learned along the way:

  • JavaScript has four different variable scoping modifiers: letvarconst, and default (no modifier). let scopes to a block (like a loop), const also scopes to a block and prevents reassignment (though referenced objects may still be mutable), var scopes to a function, and the absence of modifiers indicates a global variable. As always, beware of hoisting which allows a variable to be scoped after it has already been used in code. Not all of these are available in all versions of JavaScript.
  • Running his examples using babel as an ES2015 transpiler is not trivial. To get it to run, I had to do:
    • npm install –save-dev babel-cli
    • npm install –save-dev babel-preset-es2015
    • export PATH=”./node_modules/.bin:$PATH”
    • babel –presets=es2015 medalOTM.js | node
  • JS map takes one parameter and returns one result. This is what you would expect of a mapping or relation.
  • JS reduce is more complex. It reduces the entire pipeline to a single object. This function takes a single callback function parameter and an optional initial value.
    • The initial value can be thought of as the starting point for an object to be built up by the reduce callback over many iterations of the pipeline. Our value is just {}, an empty object.
    • The callback builds up the object. It takes the object to be built up as the first parameter, and it returns a new value for that same object. The second parameter consists of the current pipeline element.
    • The general idea is to use each pipeline element to build up the object.

Functional is fun! And JavaScript is deep!

Thanks to  Kos on StackOverflow for helping me with my basic command-line syntax issues.

Too Many Dependency Managers

Package managers and dependency managers are essentially the same thing : They both install software you need. If you want to load an application onto your computer, you need a package manager. If you are developing software and want to import some libraries, you need a dependency manager. Both do mostly the same thing. They install software for you, automatically find and download dependencies, update to the latest version with an easy command, and generally make managing software installation much easier.

I now have enough of these managers on my development machine that I am starting to become bewildered : bower, brew, npm, maven, gem, cocoapods, pkgutil, and maybe some that I have missed. Each of these differ in scope, purpose, and behavior. I run them all on the Mac OSX command line.

pkgutil is the built-in package manager for Mac OSX, and is responsible for installing the very operating system itself. If you happen to have a .pkg file (somewhat rare), you can use this utility to install it. You’re more likely to use this tool on the command line to see what Apple put on your computer. pkutil --pkgs will give you the complete list of packages installed on your computer by Apple through your OS or applications from the App Store. Pick a package name like Essentials and you can see what files were installed using pkgutil --files com.apple.pkg.Essentials. An even more power feature is the ability to tell which package a particular file belongs to. Try it with pkgutil --file-info /bin/ls.

Sidequest! Let’s see if I can figure out which package manager I used to install NodeJS on my computer! pkgutil --file-info /usr/local/bin/node tells me… it was not installed using pkgutil. Well, the prefix /usr/local should have been a clue. Homebrew puts its installations there, as do other package managers.

Homebrew and MacPorts are package managers backed by a central database containing thousands of apps. Homebrew has a sexier web page, so I use it. I heard that it is implemented on top of git, and git rocks my world. Putting an application like NodeJS on your system with Homebrew is as simple as typing brew install node. You can upgrade all of your applications using brew upgrade, or view a list of all installed apps using brew list. You could also see them in /usr/local/Cellar. Brew uses beer puns like that. To a fault.

Homebrew can be installed using ruby, which, like gem, is installed on Mac OSX in the package Essentials.  Speaking of gem: gem is used to install ruby programs. You can use gem list to see a list of all installed packages, or gem list --remote to see a list of all available packages.

And it seems like neither gem, brew, nor pkgutil were used to install my local version of node. Hmm…

When using the package manager npm, it is important to distinguish between global and local installations. A global installation acts like a package manager for system commands, while a local installation acts like a dependency manager for development projects. Several other dependency managers have this split between global and local mode, including bower.

A local npm installation starts with npm init, which creates the package.json file used to track dependencies between frameworks. npm install fontawesome -save will create a node_modules folder containing fontawesome and all dependencies and update the package.json file. Additionally, npm will save the raw package files in your home folder under .npm as a kind of local cache to speed retrieval if you decide to use the same library for another project. This tutorial shows how to install the build tool Gulp using this method.

Global npm installations are intended for system commands, and they are really very different from dependency frameworks. Most npm commands can be followed with -g to make them global installations. npm install bower -g will install bower in /usr/local using subfolders and soft links. In more detail :

?? cd /usr/local/lib/node_modules/bower/

?? ls

CHANGELOG.md README.md lib

LICENSE bin package.json

?? cd /usr/local/bin

?? ls -l bower

bower -> ../lib/node_modules/bower/bin/bower

Bower is a package manager aimed at web development. It is actually built on top of node and npm, so we need those before installing bower. It seems redundant in purpose to npm, but it adds features. Look at a typical bower installation command :

?  ? bower install jquery
bower not-cached    https://github.com/jquery/jquery-dist.git#*
bower resolve       https://github.com/jquery/jquery-dist.git#*
bower checkout      jquery#3.1.0
bower resolved      https://github.com/jquery/jquery-dist.git#3.1.0
bower install       jquery#3.1.0

jquery#3.1.0 bower_components/jquery

Notice how verbose and clear everything is? However, bower does not handle nested dependencies (frameworks that require other frameworks), so that is something that must be handled by manually by the developer.

OK, I have no idea where my /usr/local/bin/node came from, but it’s time to update! brew install node followed by brew link --overwrite node brings node under my management umbrella, and now everything is up to date. Yay!

I’m going to save CocoaPods for another post.