Over this weekend there was a sensei in my presence. Even more interesting was that he watched from the shadows without my knowledge. A full night into developing a major component of Project OGUR and he sprang to begin a battle that I didn’t want to fight.

A challenge was being held. SimplePathXna never had support for text display, but it was always planned as an addition to the (soon to be) library. Project OGUR finally reached the point of development where I needed to show some fonts, so I did what I’ve done with everything else thus far. And that was my fatal mistake.

SimplePathXna makes use of both a handful of singletons and a number of classes which are effectively useless without their publicly available static methods. As soon as text wanted to join in on the fun, I wrote a TextManager class. Just like there existed a GameplayObjectManager class, an XnaManager class, etc etc.

But something was different about adding this Manager. As if a weighty gaze was keeping my normally dexterous hands from doing the deed. It was here that the teacher came for my lesson. It was time to truly understand the reasons why my usages of the static keyword throughout my implementation of Text wrappers was a terrible, crippling design.

A crux of the  mechanics within Project OGUR is local multiplayer with up to four gamers on one screen, with live drop-in and drop-out. While trying to manage text from a single location seemed like a great idea, it was really a lazy solution to a complex problem.

Text was needed not only for each player, but also for numerous properties about each player. By making the TextManager a chunky singleton, each player’s HUD was stored in the same location. This made managing a single player nearly impossible without stomping on the data of another player.

An entire day of programming was not lost however. One of the principles I’ve learned from Beautiful Code is that bad, procedurally focused code can be transformed. Key applications of OOD will turn a pile of wet sawdust into a mighty oak, ready to grow new branches and withstand the changes of time.

This experience with multiplayer is the first concrete example I’ve experienced where throwing tons of logic into “Manager” classes failed miserably. On the other hand, refactoring that barely functioning code was a great mental exercise, and much of my labor was able to stay. Without too much referencing Fowler’s great book on refactoring, the deed was done. An hours and a half led to a much more OO friendly design that provided any given player with its own TextHandler object, wherein the existence of a player meant the TextHandler existed, so many many technical hurdles were lessened.

More explicitly, the issue was that keeping everyone’s data in a singleton meant that the HUD of every player was flushed when any one player changed their display, resulting in a lot of overhead processing. By splitting management into a more cohesive handler that each object could contain as a member, the difficulty in tracking various properties within the management class went away without much hassle.

Above all the programming experience was the way in which stepping back from the raw code enlightened the entire design process. Drawing out the basic flow of data between different classes, and redrawing a handful of times, on a white board lead to a very fluid workflow where each class had a minimal amount of responsibility. It wasn’t a legitimate UML diagram, just enough detail to help me visualize what needed to  be changed.

There are still going to be some singleton’s in the first full release of the SimplePathXna library (which won’t be until Project OGUR is finished as a project to use as a library’s proof of concept). For example, TextManager still exists. However, the first iteration of the class handled multiple operations. It allowed any logic to add text to be shown on the screen at any location using any font. It could also get a static resource that cached the Font information. That second piece, the caching, will still be the core purpose of retaining the TextManager class. TextHandler steals the other functionality as a means of scoping the text data. When a player issues a command, that command can trickle down through some object logic and manipulate the state of that command’s related text in a place where no damage can be done to other players.

I think a good rule of thumb to come out of this is that for most logic, anything that is more than a simple accessor should not a statically available resource. By that I mean something which should be singly available to any other given piece of logic. Say, the sprite used by an object to represent itself. Why duplicate that memory heavy piece of information more than once if it can be avoided?

This is certainly not anything new to the world of OO, but I like documenting the exact way in which the principle of singleton’s not being the silver bullet became clear to me. Perhaps it will help someone else understand the great disasters singletons will cause when misused.

 

I find that a project should become easier and more refined in focus over time, not more complicated and more difficult to use. SPX was always intended to be a bare bones framework that allowed for absolutely nothing more than helping developers creates game at a great pace and higher quality. Today was a successful growth in project OGUR, knocking out some of the critical sub-systems required to build the game.

During the process of crafting some logic I came upon an error in SimplePathXna. I have already pushed a fix for this problem and have decided that I want to do a small amount of work cleaning up some of SPX’s workflow. This will involve two major (albeit overall they are small) steps.

  1. Bring over most of the changes made to SPX to fit the needs of OGUR
  2. Separate the business logic of SPX into a separate library file. This will make both setting up SPX and developing larger projects with it much easier to swallow.

Step two is definitely the larger change coming to SPX, but I feel that it is required. Currently a person is tied to the directory structure of SPX if they want to use it. This doesn’t feel clean and actually gets a bit in the way on a project I’m currently developing. Once the project is separated into the framework itself and the sample demonstrating the framework I will push everything in one swell foop.

======

Having pushed everything, there are a couple of lessons learned. For one, there is a bit of coupling in the DLL to the end graphics that I want to investigate removing. Specifically the ways in which SpriteTypes are used to drive the animation engine and the constructors for the GameplayObjectFactory require GameObjectTypes to be defined, which aren’t available until defined by the end game.

 

Five hours is a long time to sit silently and ponder. It’s just enough time so that you are guaranteed to be both hungry and losing the appeal of driving within a single day. Additionally, one might contemplate long enough to have some lifestyle breakthroughs.

Today’s drive to Connecticut in the AM and back to New York in the late PM helped me understand that past focuses aren’t satisfying neither my desires as a developer nor as a human being. Time now past would find me flinging to an extreme position or direction to take life, but that amount of shifting doesn’t feel necessary anymore. On the contrary, the major recurrence in thought throughout the day was balance.

I’ve never been good at balance, but its usefulness is growing on me. Waking up this morning brought me into a state of being wound to the point of snapping. A sense of cosmic scales tipping off center weighed heavily on my morning routine. It took two and a half hours locked inside a Chevy thought cage to slowly release the tension placed on my life.

Long story short, I simply cannot focus on business-centric development full time. I can do it as my primary source of income, but on my own time I cannot be working on similar projects. The work is monotonous and provides very little motivation to better oneself.

My solution to this newly understood problem is straight forward, its time once again to continue game development.

 

Most of the time, I use a piece of software and I’m willing to put up with it. As I command a program to do as I say it tends to comply around ninety percent of the time and spends the other ten percent getting in my way. Years and years of fiddling with computers has always lead to this same abusive relationship continuing in an unhealthy manner. My expectations of software written by other people was never very high, and said software was always underwhelming in ability.

Tonight this changed. Software and I…we just might be able to work things out.

You have to understand, I’m just a very stubborn man with very high standards. Software tried time and time again to impress me, going through tons of cosmetic shifts in an effort to please me, but the same flawed core always stood out in front like a two inch gap between her teeth front teeth, and a zero inch gap between her eye brows. A smoking hot compiled chunk of code would waltz onto my laptop and try her best to win me over, only to trip me into a puddle on accident and force me into buying a new pair of pants.

These are just the little things, but while reading through “Beginning Ruby” from Apress I came across a line that made me shudder. “It’s unavoidable that the programs you develop will contain bugs.”

Finally, after all the years of playing the love-hate game with software created by other people I understand why we just weren’t right for each other. Bugs are today seen as a necessary product of human error and inexperience. That no matter who writes the code, it will have errors and will be wrong for some inputs, etc. This is what I think could be the mental handicap that leads to destructive software being allowed into the wild.

Do I see the benefits of TDD? You better believe it. Do I try my best to write unit tests for everything I develop? Not yet, but I’m learning. I do however feel like there are a ton of problems with the social culture of programmers that I’ve met. Most people in this community are arrogant, secretive, and have absolutely no confidence about what they can do.

To me, the aforementioned extracted sentence is the intellectual equivalent of saying “We’re nerds, so we must accept that only women with low self-esteem and high blood alcohol content will date us.” Maybe that’s true for some people, but why should the general feel of everyone so quickly get in line with that mentality!? Set the bar higher!

Aiming to write bug free code should be a tangible goal that one can work towards, and I feel from the great deal of research I’m doing on Ruby, the world is getting closer to the day when this task can be accomplished. However, putting it in the light of an unsolvable problem that we must cope with doesn’t make any ground. A better approach is to look to people that produce truly astounding pieces of software and learn from their development practices.

One such group of developers, is JetBrains. Time and time again I will try a piece of their software and be blown away by the power it grants me as a developer. Recently, yet another mind-blowing opportunity rolled up to my door. Her name, RubyMine. She seemed a little chunky when I first opened her up, but after writing ten lines of Ruby I realized that there was something magical about her. It wasn’t the easily configurable…everything…no, it was something less subtle.

It was tab completion. I’m not talking about crappy tab completion that you get on a Linux terminal that scrolls through with a random guess as to what you wanted, but a really intelligent tab completion system. Almost anything you need can be accessed with just three key presses. Anytime you get that stomach lurch reminding you that you’re about to convert a struct into a class, you’ll happily feel the stomach acid reside as you fly through the creation of the attr_accessor method and anything else you need to manipulate the state of the class.

Software like this is what I want to make and see more of in the wild. I want programs that aren’t interested in ringing every last penny out of customers, but affording them the chance to program faster and with fewer errors. Can it be done with languages other than Ruby? The plethora of IDEs available from JetBrains leads me to believe that it can be done. Can any one man shop produce products with this much functionality without compromising the integrity of their code? I’m going to be trying to my best, and I wish the best of luck and skill unto anyone else daring enough to try.

Don’t set the bar low. If you think and act like you can only get a three, then you’re going to get a three. Go for a ten. Everyone wants a ten. Even if you aren’t good enough for a ten, your attempt will be a lot closer to ten than the schmuck who takes the easy way out and compromises what he wants.

 

As I delve deeper and deeper into the world of computer science a sense of stagnation has been hovering over me each day. A slowly launching summer is making me reflect on what exactly it is that I value in the day to day. The past months have had a very long-term focus, and that has severely damaged the impact I’ve been having on people in the short-term.

After three hours of laughter filled story telling with two of my favorite friends I found myself longing to be as involved with real people as I once was. The emphasis here is on real people. I’ve been very involved with new people on Internet in various forums and the like, but I never meet them face to face.

As those three hours came to a close I drove through a torrential downpour thinking on small ways I can ramp up to serving people in the short-term while still having my long-term goals in mind. After some prayer and deep reflection an idea was born.

One of my friends is currently working through an ambitious list at the following blog: http://fairchildk.wordpress.com/. She’s admirably tackling 101 intriguing milestones. This list gave me a foundation for my own set of tasks. There have been a number of times that I’ve felt pushed to share my thoughts with someone in the form of an e-mail, letter, etc, but fail to follow through for various reasons.

In an effort to jump start my life back into action, I’m going to write one letter (either on paper or an e-mail) each day. Every letter will be intended for a different person. This will continue for an entire month. Should I miss a day of writing, then I need to make up for it the next day by writing three letters total. A recipient is welcome to totally ignore a letter and pretend it didn’t happen, or they can reply and we will begin an interesting discussion.

I’m going to compile a list of people that will be receiving letters, but this list will be private. That way no one will know which of my friends and people from my past might have received a letter. The list will contain a wide selection of people, but the letters cannot be frivolous. It is required that each letter contain something of serious consequence to me by sharing it. I don’t know exactly how this process will shape the future, but I’m excited to see how God uses this step forward.

 

Throughout the years I’ve used a growing list of development platforms. ActionScript, Java, C, C++, Python, C# (.NET). In an effort to ease development of AMIWAM and improve extendability, the language chosen was C# within the Mono platform. The only graphics library that appears to be useful within Mono is GTK-sharp. Tao SDL hasn’t been updated for six years and nothing else appears to get the job done.

This choice has proven much more costly than first estimated. The documentation on GDK-sharp doesn’t have any examples so far as I can tell of this type of application being built in GTK-sharp, but GTK is the framework on top of which the GIMP is constructed. Therefore, I know there’s a way to achieve my goal of rebuilding a C++ application powered by SFML in C# under Mono and GTK-sharp. At this point I’m considering giving this another two or three tries. If no solution can be found within those attempts, then I’ll move onto rebuilding Eucalyptus in a different language.

 

I need to catch my breath. I’m currently in my home town without any need to remote back to the office for the first time in a long time. Looking back over the past seven days is a breath taking experience throughout this rainy day.

For starters, yesterday was my younger sister’s birthday. As a surprise I helped her learn the basics of building a website. Within a few short hours I saw someone move from not caring about programming to truly appreciating the power granted by learning to program a computer. Her funny little site is by no means the next killer app of the Internet, but I’m excited to see my passion for software engineering rubbing off on a family member. This opens a new channel of discussion between us, as well as a new path for affirmation. Both of her intelligence, and my role as an older brother.

At the same time, research is being conducted about the appropriate platform on which to build a potentially massive web application for a friend. It appears as though Ruby on Rails will be the best bet after reading many stack overflow posts on the debate of RoR vs. other languages and frameworks. Rails does a great job of pulling me into the beautiful design philosophies it embodies, the coming weeks will tell whether or not beauty can tame the beast of an application that needs construction.

However, RoR really exposes the weaknesses of Windows’ terminal support. The Console in which I run Git Bash is atrocious for reading longer outputs, but Powershell is slower than death. This meant a cleanup of my Ubuntu partition to make space for full-time RoR development under Linux. Setting up the latest ruby with the latest gem package manager was as simple as configure/make being called on ruby’s source snapshot and then  running the setup.rb script for the gem package manager. Once rails was installed from gem, everything started moving along smoothly. Over the next handful of days I look forward to continuing progress through the tryruby.org site and reading books on Rails.

Another interesting development is that of the direction my plans for an Xbox 360 Indie game are heading. The plan on paper is a platformer with a handful of unique gameplay mechanics driving puzzles and exploration. However, tonight I made a return to some rougelike games and have started to plan a second game. This second game is far more interesting to me personally, so there’s a chance that I’ll back burner the platformer for now until I make some headway on planning this second game.

I am more motivated to work on this new project because I’ve always wanted to build my own rougelike game. Ancient Domain of Mystery by Thomas Biskup has always been my favorite rougelike,  but I have many ideas beyond the styling of that game’s core play mechanics. Building this for Xbox will present an interesting challenge and I look forward to solving the problems that arise. There’s still much planning to do if I seriously want to build this, so its not the highest priority at the moment.

Then there’s AMIWAM. I’m fighting a battle at the moment with the Views of AMIWAM to overcome some awful flickering that occurs when I redraw the screen. There are numerous solutions available for this problem across the Internet, but so far none of them has proven useful. Every day I’ll tackle the problem with new ambition, only to break the effort an hour or two later to make progress on other projects. Once the rendering works perfectly the amount of work to rebuild Eucalyptus will be trivial.

 

 

As the gears shift into more framework development  for the next Xbox 360 game, I wanted to write a quick note about a new project on the Projects page.

Eucalyptus was a great proof of concept into the idea of a keyboard driven image mocker, but it has two major flaws in my opinion. Firstly, it is built in C++. This means the application has great low-level power, but rapidly building new infrastructure is difficult and often blocked by barriers in memory management. Secondly, RPI could claim total control of the project should it ever develop into a serious tool.

In an effort to overcome both of these shortfalls, I am taking the time to rebuild the entire application from scratch in C#, without referencing any of the code in Eucalyptus. Many of the same ideas will carry over, with a small numbers of improvements. Predominantly, I want this application to be geared towards image mocking that ranges from hideous and blocky in a way that fits immediate develop needs, as well as allows for mocks that might carry the same elegance as the 8-bit Nintendo era games.

Programmatically speaking, this will involve a new system wherein a user can switch contexts after finishing the vector body of an image. At this point, it can be exported and used in whatever code is being developed, or a raster editing context can be entered where a slight amount of refinement tools will be made available. The goal is still to keep out as much bloat as possible while still providing the most convenient means of mocking graphics without the impediment of a mouse.

In spirit, the program’s name will embody this principle. Amiwam Makes Images Without A Mouse, AMIWAM. AMIWAM currently has both the keyboard input sub-system and rendering capabilities needed to start the principle development, so I just need to table the work to be done and accomplish it. This summer will be a great experience both at Apprenda, and working on these new and exciting projects. Looking over the fruit of my labors from the semester is a sweet taste indeed, and I look forward to more in the coming weeks.

 

RPI’s term is coming to a close which means I will soon have time to jump back into some project ideas for the summer. Over the past two weeks, there was an application that had to be built as a final assignment. After thirteen days of building it in C++ it began turning into spaghetti. Over a thousand lines of code to convert between different data structures used by other parts of the application. Gross.

Why was this code so bad? It turned foul because I had no idea what I was building from the get go. In a general sense, a simplified SSL client was being fashioned. Technically speaking, I had no clue.

This lack of knowledge lead to me jumping into programming as a means of learning what I had to make. That sounds backwards, but it is a trend I find myself in all the time when learning about new things. Sometimes I am better able to visualize and comprehend a subject by programming it instead of researching and planning the architecture ahead of time.

With that said,  as my knowledge increased about the workings of SSL my code was growing more and more fragile. Closer and closer it got to the edge of usability until it fell and broke a hip. A few conversion function changes lead to all encryption breaking.

The project was due in three days from that time. I had already invested dozens of hours into this project. A tough call needed to be made. Should I continue wrestling with memory error ridden C++ that was near completion, or was the wiser choice to start over from scratch in Java?

Start over from scratch? Two thousand lines of C++ for nothing?

No, not for nothing. Writing that awful code was an exciting experience filled with twists and turns that I didn’t see coming. That’s the thrill of gaining understanding on a new subject. I don’t think programming as a task should be that way. Its too easy to be overjoyed with accomplishing a job that the time isn’t taken to do it well.

Yes, re-writing the entire application from scratch sounds like a grand undertaking. On the contrary, knowing exactly what I needed to build meant better planning before even touching the keyboard. By the time I was coding the application was well designed on paper, so writing the code itself wasn’t as thrilling.

Such if life, that we can get excited about the wrong things. Perhaps if people spent more time brainstorming and less time pounding out rushed code then we’d have a few more Linus Torvalds rising from the ranks of my peers.

 

The basic functionality of Bombard360 is finished to the point of what is due for my coursework. Now that I basically need to freeze the repo until classes are over (for grading purposes) I used the free time available to abstract out a lot of the code from Bombard360 into an easy to use framework for other 2D games.

This new framework can be found at this GitHub repo.

To get a feel for how the framework is used, try the following to add a new element to the game.

  1. Draw a new sprite in the next open open row of “SimplePathXna\SimplePathXnaContent\GameplaySheet.png”
  2. In the VS2010 solution, add a new element to the SpriteType (\Sprites\SpriteType.cs) enum that described the object you want to add to the game
  3. Add a new dictionary entry defining the contents of the sprite to SpriteSheetManager (\Sprites\SpriteSheetManager.cs)
  4. Create a new class that inherits GameplayObject (\GameObjects\GameplayObject.cs). In the constructor, pass the location and SpriteType into the protected Initialize method. This will handle most of the graphical setup for the class.
  5. Create a method within your new class with the following signature: public override void Update();, and define the object’s game logic here.
  6. In GameplayObjectFactory (\Factory\GameplayObjectFactory.cs), add a new case to the switch statement that defines the way your new object shall be created
  7. In GameplayState (\States\GameplayState.cs), call the function Add(GameplayObjectFactory.Create(400,400,SpriteType.YOUR_NEW_SPRITE_TYPE)); in the constructor
  8. Run the application, and an instance of your new object should show up on screen at 400,400. If not, then there’s a good chance that a null exception will be thrown before the game can launch, showing you what step you missed in setting the object up.

The benefits I’m finding from using this growing framework is the topic of a future post, but feel free to shoot me an e-mail if there are any problems encountered in getting setup with the project.

© 2012 Simple Path Studios Suffusion theme by Sayontan Sinha