Saturday, 21 March 2015

The Game Overthinker: A Retrospective

Greetings interwebs!

I’d like to talk to you today about something my reader(s? Yeah probably not.) may be unfamiliar with: a little web show called The Game Overthinker. The show was created in 2008 by Bob (MovieBob) Chipman, who you may know of as the host of Escape to the Movies and The Big Picture. Basically the show was a platform for MovieBob to act as a video game culture commentator in a format instantly recognizable to long time Big Picture viewers. And it was AWESOME! A solid mix of insight, humour, and a strong personality, the show grew a large enough audience to propel it’s creator to the Escapist, Screw Attack, and beyond. 

All of which happened before I was even aware of the show or it’s creator. I was first introduced to MovieBob through Escape to the Movies and didn’t know about the Game Overthinker until Extra Credits plugged the show in an episode titled “Choice and Conflict in Games” in 2010. This was also around the time the show was making it’s first foray into having a framing narrative In which the Overthinker had wacky adventures in-between pontificating about game culture. It accumulated a pretty solid cast of characters over it’s run, all humorously played by Bob, and experimented with some cool special effects, though never really rising above the tech level of “Birdemic”. But that was a huge part of the charm as the show marinated itself in the kind of bonkers creativity, hammy acting, and low tech visuals that dominated video gaming in the 8 and 16 bit era’s. 

The story, and the show itself came to an end two days ago in the show’s 100th episode. In anticipation of the last episode, I took some time to re-watch the whole series and thought I’d share my take on it here, since I never seem to post anymore anyway. 

Massive spoilers for the entire series from this point on, so if the show sounds at all interesting to you, please go and check it out at http://gameoverthinker.blogspot.ca/. And if you like it, please consider contributing to Bob’s Patreon here. There’s a follow up series and some other projects in the pipe. 

The pre story era:

I’m gonna try and keep this short, since I want to focus more on the story than the cultural criticism, since that would basically take 100 miniature posts, and I don’t have that kind of time. However, there were a couple of things I found upon watching the re-watching episodes 1 to 42, so quick thoughts:

-This goes for the entire series, but it’s particularly noticeable with the older episodes. Since it spans as much time as it does, watching the show can be an interesting experiment media archeology. One can see the last 7 years pass in a few hours through 100 vertical slices. The show’s tendency to address controversies while they were relevant also means that there’s a mention of most of the small dust ups that would eventually coalesce into the HashtagWeShallNotDignifyWithAName.

-Speaking of, and I’m trying to word this very carefully, looking back on the early years, I can see how the people propping up said hashtag today would have felt at home with the early Overthinker. Don’t misunderstand, 2008 MovieBob would be just as pissed off about that shit storm as 2015 MovieBob, but the earlier episodes that mention feminism or racism are generally in a position defending games from it rather than criticizing the game. Of course said defences are given with a lot of nuance and the arguments being refuted are given a clear explanation, unlike an opinion from say, Fox News which would likely be given in straw man format. More importantly, he never argues that the discussion shouldn’t be happening. But I still find it illustrative the growth of it’s author over the better part of a decade, or even just a couple years. Compare “Pr0N,” and “Super Mario and the Sacred Feminine” from 2008 to “I Heart Bayonetta” and a Big Picture episode called “Gender Games” if you want to see what I mean.

-There’s a surprising amount of gratuitous T & A in the opening episodes. Nothing explicit obviously, but still more than you would expect.

-The sped up voice track used a lot in the early episodes bears such a resemblance to the effect that would be used for Ivan the fairy later in the series that it’s hard not to hear the episodes as Ivan and the Overthinker taking turns to speak instead of MovieBob throughout.

The Game Antithinker, and the Quest of the Overthinker:

In December of 2010, in Episode 43 “Double Trouble”, The Game Overthinker changed forever when a seemingly normal episode examining the concept of evil twins was interrupted by the Overthinker revealing that not only was “Wario’s Woods” the last game ever made for the NES, (which is true) but there was a real Wario’s Woods in Minnesota (which, so far as I can tell, is not). A Blair Witch style clip from his brother’s exploration of the forest reveals the Overthinker’s own evil twin, the Antithinker, who proceeds to take over the show and banish the Overthinker to Wario’s Woods. 

For the next three episodes, the Antithinker hosts the show and looks at video games, and the Megaman and Zelda franchises in particular, through the skewed lens of a man whose interest in video games consists only of Madden and Call of Duty, with all other games being the products of nerds creating a fantasy world where their lives sucked less. The caricature could get a little grating at times, in part because the gay as an insult thing is still irritating, even when done ironically, and the swipe at hardcore bro gamers was so over the top that it really only worked in small doses. I still enjoyed the character, and I wish we had gotten to see the Antithinker covers Mario episode I’m sure there was a plan for, but even I’ll admit, it could be a little much at times. The latter two Antithinker episodes we did get each contained at least a small moment in which the story humanized the Antithinker a little, and the second one, a nostalgic feeling of regret induced by Ocarina of Time, seemed to weaken the Antithinker.

Following the Zelda episode, the show went back to following the Overthinker, who had apparently felt the Antithinker’s moment of weakness and began a quest to ready himself for the time when the Antithinker would return to the woods to finish him. There was notable moment when straw man, a character from the early series who occasionally showed up to regurgitate a simplified version of an argument to be refuted on the show, voiced the complaints of a large section of the show’s audience that was angry about the new storyline. The Overthinker’s response, when asked to kill the annoying character that everyone hates, is to vaporize straw man on the spot, in an act that wouldn’t have any negative consequences what so ever. Over the next two episodes the Overthinker trains, first alone, then with the bald guy from Rygar, until the arc culminates in the 50th episode special “War of the Thinkers”, a commentary free, all action short in which the Overthinker finally defeats the Antithinker and frees himself from Wario’s Woods. 

Of the whole arc, the episode that stands out most to me is “The Zen of Grind”, which established an early prototype for what the new show could be at its best, with the framing story and the episode complementing one another. The Overthinker talks about the origins and impact of level grinding on rpgs and games in general, while he himself is grinding slimes to prep himself for fighting the Antithinker. “War of the Thinkers” is also notable for establishing the look and feel for the special effects from here until the appearance of the green screen tech used in the Robothinker arc. But we’ll get to that later. All in all the Antithinker/Quest arc was a well told, if a little rocky, story with an awesome finale.

The Ninja Saga 

With the previous storyline having demonstrated what the show wanted to be, it fell to the ninja storyline to establish the form the show would take from here on out. It starts out slowly by establishing a couple new cast members: Ivan, the Overthinker’s fairy intern straight out of the Ocarina of Time, and Police Commissioner Bunnyface, played by Dylan the rabbit. It also introduces Jack Lieberson, a ninja-American senator seen around the edges of the series, mostly just used to poke fun at the ubiquity of ninjas in the Overthinker universe. The plot picks up when Bunnyface requests the Overthinker’s help in dealing with the strange new plague of video game creatures that have begun appearing around the city. It’s explained that the events of “War of the Thinkers” created a rift between the world of video games and the real world that allowed the creatures to slip through. Meanwhile, a mysterious figure is seen destroying game stores and the Sharkcade, a favourite childhood haunt of the Overthinker. The figure is eventually revealed as the Pyrothinker, a ninja with power over fire, and the Overthinker’s investigation of him introduces his counterpart, the ice ninja Cryothinker. On top of that, the pair turn out two be the sons of straw man, out for revenge against the Overthinker. To defeat them, the Overthinker forges a sword out of the Antithinker’s medallion left over after their battle, and fights both ninjas hand to hand in “Ninjamaggedon”. When killed, each of the ninja’s bodies is found to contain an stone charged with elemental energy, the apparent source of their fire and water powers.

It has a few hiccups at the start, most notably on the first episode “Putting the Cart Before the Cloud”, where the main visual is the Overhinker staring down at the laptop with the script on it. There’s also the issue of the near two minute opening credits with inconsistent music, but by the forth episode, both of those had been ironed out. The third episode, “What we learned in the dark”, introduced an act breaks structure that saw the commentary portions broken up once or twice by the the story segments. It allowed for a clean separation of thoughts in the commentary, and neatly handled the time required for traveling, or building, or defrosting between significant action and plot moments. As discussed before, the structure worked best when the story and commentary complimented each other, which happened a couple times this arc. The Sharckade’s destruction led to discussions of the significance the arcade era to gaming, and the presence of ninjas tied into the dominance of Japanese culture in the medium and its fading influence over the modern industry. 

In the special effects department, the frozen effect is my favourite in the series. While the dynamic fire and lighting effects always stood out, frozen people always managed to look like part of they were in the scene while maintaining the artificially coloured look. Ivan likewise usually didn’t look terribly out of place, though, it’s likely because as a light emitter, there’s no expectation for him to have a shadow.

Probably the best idea in the run was to make final showdown with the ninja’s into a mailbag show, where between action clips, the Overthinker would answer viewer questions. This allowed the action scene to jump from cool moment to cool moment without worrying too much connecting fight choreography or consistent scene geography. This would be the format for most of the big battles throughout the rest of the show.

The Retrothinker and the Necrothinker

After finding a VHS tape in the ruins of the Sharkcade, Ivan and the Overthinker discover that a gaming TV host calling himself the Retrothinker froze himself in 1990 building’s basement and was released during its destruction. The Overthinker manages to talk the Retrothinker out of of a suicide attempt, but all progress is lost when the Retrothinker goes to check up on the Sonic franchise. In a moment of grief, a shadowy figure abducts him and grants him the earth stone, with power to raise the dead game characters from his era back to life, turning him into the Necrothinker. The Necrothinker sets his minions loose upon Activision and Zynga, and creates a tower fortress out of the ruins of the Sharkcade. After defending the Activision and Zynga from the zombie hordes, the Overthinker leads a selection quality modern game icons in an assault on the Necrothinker’s tower. After a sword fight with the Necrothinker himself, the Overthinker uses the water and fire stones to seperate the Necrothinker from the earth stone, turning him back into the Retrothinker. He then hides the Retrothinker from the police and assures them that while they won't find a body, the Necrothinker is definitely dead.

This was hands down the best arc of the show. Not only did the episode topics like zombies, preservation of the medium, and retro gaming tie in beautifully with the Retrothinker storyline, but the Necrothinker was the deepest villain in the show. The best villains are have a little bit of the hero in themselves, and the Necrothinker was a reflection of the Overthinker’s own fondness for the golden age. We can sympathize with his sense of loss and his desire to see the characters he loved restored. His whole transformation works as a perversion of what the Overthinker said to talk him our of suicide: that he has to live to share what he remembered with the world. Meanwhile the fight forced the Overthinker to defend aspects of gaming that he wasn’t as attached to and fight a person he really didn’t want to kill. He had to confront his own beliefs about modern gaming and find the good in the games of today. 

This arc also revealed the biggest flaw in the show’s new format. The Game Overthinker wanted to be topical, have a well shot, well written story, and have the story and commentary tie into each other whenever possible. But writing and shooting take along time and being topical depends on being able to air at the time rather than several weeks later. This was best shown in “Seeing Red” where a discussion of Dizzy and other retro characters and their prospects for modern revival was replaced by talk about the reaction to some concerns regarding Call of Duty’s complete omission of the Geneva Convention raised by the Red Cross. It was an unfortunate loss of what would have been a nicely themed episode. The solution taken here was the one used throughout the series, namely dropping more thematic tie ins in favour of being topical.

The show made format adjustment to the teaser - commentary - epilogue setup that would be used for most of the remaining episodes. While the change was made official in episode 46 “Beyond Sopa” a number of preceding episodes had already wound up with most of their story at the beginning and end. With the commentary crossing the narrative less often, the theming became less noticeable but also easier to ignore when it didn’t work out, and the move also helped to placate the more vocal members of the audience who didn’t care for the story, allowing them to easily skip it. 

But despite the flaws, I still maintain that this was the high water mark the show.

The Robothinker Saga

This arc took the form of an extended parody of the Cell saga from Dragon Ball Z. The Antithinker reapears, but is killed immediately by a pink haired time traveller with a sword called the Omegathinker. The Omagathinker had come from the past to both to prevent the Antithinker from killing the Overthinker, and stop the Robothinker, an air stone powered military drone AI that had been plugged into Xbox live before turning on its creators, from destroying the world. After the Overthinker and Cobalt Core, Senator Lieberson’s hitherto unknown private army, are unable to stop the Robothinker, the Omegathinker begins fighting him in a battle that gets periodically cut to during the next several episodes. The Overthinker stays at home and hosts the show as usual allowing some world building to happen in the background. The key point is the introduction of Mr. Phibb (a.k.a. the Devil), who allows the previously killed Pyrothinker and Cryothinker to return from the dead and freeze the Overthinker before moving to interfere with the Omegathinker/Robothinker battle. The Overthinker is saved by Dr. Beardo, the creator of the Robothinker, who still hopes to stop him. Meanwhile the Retrothinker goes to fight the Robothinker, but finds himself completely outmatched until the Mr. Phibb convinces him to use the Earth stone to change himself into the Necrothinker. The Overthinker and the ninjas arrivee just in time to witness the transformation and battle ensues. The Overthinker and Omegathinker keep the ninjas in check while the Necrothinker and Robothinker duke it out, and Ivan is sent to have Dr. Beardo unveil the Overthinker’s new teleporter use it to save get the good guys out of the fight. Using the teleporter, they move themselves from the battle to their apartment, move the ninjas to the apartment while accidentally fusing them into the Plasmathinker, remove the air stone from the Robothinker, and move the Plasmathinker into prison. Finally they teleport the now power deprived Robothinker to the apartment where the Omegathinker finally kills him.

The first thing to note about this arc is, as you may have guessed from that monster of a paragraph, that this was where the plot started to become much more complicated than the usual "guy wreaks havoc, Overthinker fights back" setup that the previous arcs employed. In the 12 episode context of the series it’s not that difficult to follow, but it definitely lacks the relative cleanliness of the previous arcs. Admittedly some of that is par for the course when you’re doing a Dragon Ball Z parody, but after Phibb resurrects the ninjas, there starts to be too many balls in the air.

The bigger issue is the ending. My feelings on it are kind of mixed. The use of the teleporter is clever and the last moments of the Robothinker still have suitable gravitas, but the introduction of the teleporter isn’t telegraphed at all. I don’t know that it’s quite a deus ex machina, since the teleport continues to be used as a teleporter through the rest of the series and it never does anything unexpected for a teleporter, but… well… 

Consider the Oversword, the weapon the Overthinker makes from the Antithinker’s medallion. Ivan informed us that the ninja’s could only be harmed by anti-metal. The Overthinker then says that he has some and pulls out the medallion. We saw in “War of the Thinkers” that the medallion was all that remained of the Antithinker after the battle, and we saw Overthinker pick it up. Then an entire episode is detected to making the sword. By contrast, there isn’t a single mention of having a teleporter, working on a teleporter, or even to the Overthinker working on a mysterious “Protocol Erricson”. The first mention of the protocol is when the Overthinker tells Ivan to activate it at the beginning of “The Next Crash” and it’s revealed to be a teleporter and used the first time in the epilogue of the same episode. Again, I liked the use of the teleporter once it's established, but it bugs me that it basically gets conjured out of thin air.

Time was another interesting thing in this arc. A few jokes are made pointing out the inconsistencies in the Omegathinker’s knowledge of things that shouldn’t have happened in his reality due to the Robothinker destroying everything before they could happen. The show’s solution was to just ignore the question, but it does expose unique problem with combining the narrative and commentary portions of the show which I think is worth discussing. Obviously the commentary portions of the show take place in unique moment in time at which they were filmed, but the story segments tended to have a more flexible relationship with time. Way back in the Antithinker saga, all the time between episodes was assumed to have passed normally. We saw snapshots of the Overthinker’s exile, but it was assumed that he continued to survive, train and explore the forest off screen between episodes. But if the same view of time were held in the ninja saga, we would have to conclude that the Overthinker’s time as a popsicle, and the accompanying ninja dance party, lasted nearly a month. However, the show never explicitly gives out a date for the story events, which provides a neat way around this inconsistency using a sort of temporal doublethink. Multi episode character interactions can be thought of as events displaced in time so that the events of the previous episode always happened just prior to the events of the current one. In this case of the Omegathinker’s recorded history, everything that happened in our reality also happened in his because he always got here yesterday morning and the Robothinker always showed up last night. 

On the technical side, this is when the show introduced the green screen tech that would be used for the rest of the series to handle multiple Bobs being on screen at once (except in the apartment scenes where the lighting could be carefully controlled). While it often surrounded the characters with a fidgety green aura, it made up for that by allowing much greater variety and complexity in the interactions between characters. Ariel fight scenes, characters moving while being shown at a distance or in exotic locations, characters appearing in groups of 5-8 instead of two, all were only achievable with the green screen. The show also settled on the version of the intro it would use for the rest of the series and the long battle over act breaks finally ended in a draw: they’re there when they are, and they’re not when they’re not. 

Despite the somewhat anticlimactic ending, the Robothinker arc was still an enjoyable one. As complex as my synopsis made it sound, the changes are spread out over enough time that they’re not overwhelming, and the fact that the game was always changing meant the story never got bogged down. I also really liked the unexpected turn in the parody, with the Overthinker going from the Goku analogue to that of the minor characters hiding and watching the fight on tv. It’s also worth noting that this was the only arc not to handle the big battle with the mailbag show setup, and while that did take away from the ending a bit, it’s impact would have been undermined in this arc simply because the Omegathinker/Robothinker fight was cut to in almost every episode. 

The Ultrathinker, the Second Quest, and the End of All Things

Remember when I said the Robothinker arc put too many balls in the air. This was where they became a problem. It’s definitely the most convoluted storyline and is riddled with sudden changes in direction and plot points hastily happening off screen. So for this one, I’m just going to cover it in a point form summary. Here we go!

- The Necrothinker turns back to normal
- The Omegathinker returns to the future
- Senator Lieberson and Commissioner Bunnyface have the Retrothinker arrested for his crimes as the Necrothinker, and place the Overthinker under house arrest
- The Antithinker re-appears, released from hell by Mr. Phibb, and busts the Retrothinker out
- The Plasmathinker turns back into the two ninjas off screen
- Lieberson appears on TV, flanked by the ninjas, introducing himself as the leader of the Oolong Tea Party which is now in control of the government with the help of their new cybernatetic army, the Justice Iron Shadow Militia (J.I.S.M.)
- The Antithinker delivers Retrothinker back to the apartment and explains himself, revealing the mysterious shadowy stranger as the Ultrathinker, and setting him as the puppet master behind all the Overthinkers prior enemies
- He also remembers that the Ultrathinker needed something called Lost Cross to find the ultimate weapon
- The heroes investigate a mountain cave looking for information about the cross and find Dr. Beardo inside
- The J.I.S.M. troopers are revealed to be powered by the video game creatures (now dubbed vidspawn)
- Dr. Beardo finds the Lost Cross… in his car…
- The Ultrathinker teleports the Overthinker into his weird inter dimensional limbo place
- Retrothinker uses the stones and the lost cross to go through the Gamer’s Gate and claim the ultimate weapon: the Golden Axe
- The Ultrathinker reveals that he was a monkey that interacted with the predecessors of video games in the 70’s before being shot into space where cosmic radiation transformed him into a trans-dimensional being
- Lieberson imprisons Bunnyface and unmasks himself to reveal that he was Dr. Beardo all along, and he possesses the Golden Axe’s counter part, the Master Sword
- Omegathinker reappears and joins the team as they fight the J.I.S.M. troopers and the ninjas
- The heroes kill the ninjas
- Retrothinker runs inside to fight Dr. Beardo
- The Robothinker reappears and joins the fight against the heroes
- The Ultrathinker kills the Overthinker and enters the real world
- The lead J.I.S.M. guy kills the Omegathinker in a flashback
- The Antithinker kills the J.I.S.M. leader
- Ivan possesses the Robothinker and uses him weapon to steal the Master Sword from Dr. Beardo, allowing Retrothinker to kill him.
- The Overthinker is raised from the dead into some kind of ascendance where he speaks with a being called The Captain
- The heroes fight the Ultrathinker from the top of a Boston skyscraper 
- The Overthinker appears to the heroes and gives the Captain’s power to the Retrothinker allowing him to finally slay the Ultrathinker

And then theres a final resolution scene and the end.

It was no secret that the show was always making up the story as it went along, but this was the only arc that really showed it. The Second Quest is talked up as this big event in the show, but it boils down to only two scenes and the “it was in my car” reveal of the Lost Cross. The show bent over backwards to work every character into the finale, then killed the Omegathinker a flashback so he wouldn’t interfere with the fight with the Ultrathinker. Meanwhile some episodes basically had no story whatsoever, though one of them, “Pink Rising,” made up for it by being narrated by Commissioner Bunnyface. Basically the show alternated between cramming in major reveals and changes to the situation, and marking time till the final fight. 

But while the story was kind of a mess, a lot of care was taken to ensure that every plot thread was resolved, however haphazardly, and went somewhere, even if they didn’t really affect the plot at all. Despite the lack of a plan, the series as a whole actually managed to finish with very few real continuity flaws. I think I found two, but they’re both pretty tenuous. Over episodes 95 and 96, Liberson appears with the ninjas and some J.I.S.M. guys at the foot of the Ultrathinker when he had just kidnapped the Overthinker, then at the end of episode 96, Dr. Beardo is in the apartment helping with the quest with no indication that he had left at any point. There was enough time with him simply not in the shot that he might have snuck out, but it’s definitely ambiguous. 

The other goes way back to Episode 47, “Farm Team,” which contained the very first tease of the Ultrathinker as his voice was heard monologuing over a control panel playing videos of the Overthinker and Antithinker. The camera zoomed out to show the panel was on some form of spacecraft orbiting the Earth. This seems to show just how early a rough idea of the space monkey back story had been dreamed up, but it ship in orbit contradicts the “trans-dimensional being that evolved in deal space and can only subtly influence the real world” version of the character. Given the time between the two versions though, this one’s easily forgivable.

I guess there’s a small problem with the ninjas still having their powers when they come back from the dead without the stones, but it seems like in this universe, characters who go to gel maintain the state and abilities they had at the moment they died. This also helps explain why the Antithinker had only limited use his alternate form after coming back since he died in human form. At least I think it does.

But enough about the flaws, what worked? 

Well the characters for one thing.  The Antithinker was much more fleshed out and interesting this time around, and the banter between all the characters in the apartment kept things funny and enjoyable. Most of the time. The only joke that really got tired was the Overthinker, the author insert character, sighing with irritation at the story segment and asking Ivan to just roll the credits, but only because it was used for about five episodes in a row. I also liked the little touches in each character's weapon in the final battle. The Retrothinker goes from his yellow Necrothinker sword to the Golden Axe. Ivan, the OOT fairy wields the OOT Master Sword (via Robothinker of course). And the Antithinker is seen using the Oversword that had been made from his own medallion.

And for all the times it interfered, the show’s topical nature ultimately helped it to tie the finale together. The lead up focused on explaining the HashtagWeShallNotDignifyWithAName, and the topic occurred as a running theme in the mailbag questions during the first two final fight episodes. In the final episode, the Overthinker arrived at his final thesis on the subject. 

The show ended with the promise of two new spinoff series: A back to basics Overthinker reboot, and an adventure series with the side characters. I’m anxiously looking forward to both of them. It’s a little ironic that after all the backlash over the framing story, the reboot really will be dropping it. But it isn’t dropping it to be popular.  The story is going away because it was finished, and it was well worth the telling.

Thank you Bob.


That reminds me,  BOB, IF YOU’RE READING THIS: In re-watching the series, I came across “Who’s Your Daddy Megaman” and “I Heart Bayonetta,” both of witch seemed like the first instances of recurring segments that were never followed up on. If you’re still taking suggestions, I would love to see more episodes like those, doing design and aesthetic breakdowns of a character or stage.

Thank’s again.

And rest in peace Door Guy. You will always be remembered. 

Tuesday, 23 December 2014

SpaceChem should be taught in school

Greetings interwebs, long time no... blog?

Anyhoo, I just started playing SpaceChem last weekend, (got it for a dollar. Thank you Steam sales.) and while I only just finished the second world this morning, I'm not kidding about that title.

For the uninitiated, SpaceChem is a game in which you are an engineer working for a chemical engineering firm in the 2700's. Your job is to build and connect custom reactors which take one to two chemicals in and sent one to 2 chemicals out. The inside of a reactor is split into 2 halves, the red half on the top and the blue half on the bottom. Each half has its own input, output, and 'waldo', a bull's eye looking thing that travels at a constant speed along the 2D circuit you layout. Along the circuit are commands to grab or drop an atom (and any other atoms attached to it),  bind/unbind atoms, admit a new input, release an output, or wait for the waldo on the other circuit to pass a given point. There are probably other commands I haven't seen yet, but what I've described is enough to get the gist of it.

The trick is that while the waldos can run over and through each other all day, the atoms they are carrying cannot. Any collision between atoms crashes the whole process, so you have two parallel systems that have to work together and cannot collide. On top of that, your reactor will be part of a pipeline and if a reactor down the line is slower than the reactor feeding it, the unused input will queue up at the pipe until the molecule at the back is unable to leave the reactor and is it by the molecule behind it, again causing a crash.

So you have a set of procedures with inputs and outputs that run in parallel, form a pipeline, and must not crash. Some of you are probably thinking, "Man, that sounds a lot like programming!" and if so, good, because thats basically my thesis here. Not that I'm the first person to say it by any means, in fact that was basically the pitch from my friends trying to get me to play it. But I think it's more interesting than that.

On the surface, the game is obviously very different than conventional programming. But I think the reason everyone relates it to programming is that it captures the core experience of programming without duplicating the everyday mechanics. When you open a fresh reactor, you come up with some idea of what you need to do, assemble the circuits, and then run. And then it breaks. Something doesn't happen the way it's supposed to, so you look it over and diagnose the problem, then change the circuits to fix it, and try again. And it breaks in a different way, so you find the new problem, and fix that. Test, analyze, modify, and repeat until done. And when it works, it's just as surprising and thrilling as seeing seeing your program finally doing what it's supposed to do. If I wanted to explain to someone how programming worked, I would probably show them a simple program or point them to turtle graphics or something. But if I wanted them to understand why I program, to understand what it felt like, I would make them play SpaceChem. It hits all the same notes without having  installing any new libraries on their computer, except Mono if they're on a Mac. (Pro tip: nothing makes a downloadable application sound safer than naming after an actual virus.)



And that is why I think everyone should play this game at least once. It communicates the basic appeal of programming that so often gets lost amongst the jargon when you try to explain it to them. I don't think it should be a mandatory course, just one of the many applications on the elementary school lab computers that students ate encouraged to try. And if a student really likes it, get them started on python or javascript, because they're probably good candidates for future programmers. And your future software engineers? Look for the kids who can't abide a backup even if it isn't bad enough to keep them from winning.

As for people who are already programmers. Play SpaceChem anyway, it will be good training for you too. The game's focus is on parallel processes in a pipeline, where the goal is fast, reliable throughput. These are concepts we talk a lot about in computer science, but for practical reasons, rarely get to play with. At one point in the game, I wound up having to slow down one a producer to keep from overwhelming a necessarily slow consumer. That situation would never come up in my hobby projects or my job, but in large scale data management, it's a very real possibility.

So there you have it. Whether your a programmer yourself, or someone trying to understand what  programmers are on about, or even just a person looking for unique and interesting game, you should definitely check out SpaceChem.













....Why are you still here......

Oh you want update on the other thing... *sigh*...

Stratagem (working title) has been through rather a large pivot over the last several months. After my last post I dove into getting an HTML5 javascript version a good way in, but I was dragging my feet. At the same time, I came to a realization that nearly every studio in Vancouver is using Unity, so my not knowing how to use it was a bit of a negative for future resumes. And then I thought about why I chose the HTML5 javascript route in the first place: playability on lots of devices (via the good ol web) and a skill set I needed to build anyway, and I realized that both of those apply to Unity way more. So I dropped the old prototype and started working on a Stratagem Unity project. The only problem was that I knew jack all about Unity and was slow to force myself through learning it. I've gotten over that particular ump now and I've officially surpassed the old prototype's functionality. I'm hoping to have a really simple playable version by new years eve, but I have other stuff I need to do as well and it's Christmas, so we'll see how far I actually get.

See ya.






.... What? You need me to sign off? But it's super embarrasing!

Fine.

I'm Lambwatt, and this is day.... 236?!  OH #*@& ME!

Sunday, 22 June 2014

Collision Course

Howdy Interwebs,

So about a month ago I was inundated with a stream of emails informing me that a tweet I made back in November had suddenly started recirculating.  November was the Concentric Game Jam, in which I succeeded only in failing spectacularly, partly because I was trying to to use an engine I'd been working on and it wasn't ready by a long shot, and partly because I got hung up, as I often do, on getting reliable collision detection working. That prompted me to tweet this:



I think it resurfaced because I barely tweet at all these days, so when I announced I was updating this blog again last month, this relic was the most recent tweet before it. And at 7 retweets and 2 favourites, this is easily the most traffic I've gotten on twitter, or even the web at large. Admittedly I'm still a bit shy of internet famous, but it's a a start.

But I didn't come here to advertise a tweet.  God help me if I ever do. I just thought it was an odd coincidence, since that collision problem has continued to gnaw at me, and since I was getting back into the habit of working, I set about fixing it.

Side note, throughout this post, some of my fellow developers will be screaming "VECTORS! VECTORS! VECTORS!", and they're not wrong. In the later part of development of this library and the writing of this post, I came up with a 3 box check that can solve the whole problem and many other problems relating to angular collisions. Should I need it, I will probably code that library up too, but most of the times i have found myself in need of collision detection, I was just using simple x, y, width, height hit boxes (Henceforth WHYX hit boxes) and so that is what this program and post concentrate on.

So in simple platformers, the easy solution to collision detection is to ask 4 questions of each object in the scene. Is it above me? Below me? To my left? To my right? If the answer to all of these is no, the object must be inside you. This method easily tells you if you are colliding with something in your current position. Of course if you're moving, things get more complicated. If an object is 20 pixels by 20 pixels and is fall down at 10 pixels at a time, it will always detect the the ground beneath it by checking if its new position is hitting the ground. But if it's falling at 40 pixels at a time and the ground is only 2 pixels thick, then the objects new position underneath the ground is clear so it will proceed as if the ground isn't there and fall forever. Very sad.

To solve this problem, most tutorials I've read suggest using a super simple technique. Instead of moving all at once, we move in even increments, say 20 pixels at a time, and detect collisions as we go.  This solves the first problem, but there are two other important problems it doesn't solve. Suppose the object is falling toward a deadly spike, but above that spike is a thin platform. It is possible that the same collision check of a 20 by 20 pixel box that first detects the platform also detects the spike. So now you need to know which was hit first. In this case we were going down so the object that is higher is hit first. But if it's moving up then this is all backwards and if we move diagonally, it introduces a whole bunch of new possibilities. So should you resolve the x first or the y? Either way you will slightly favour the player in some situations and hurt them in others. A player trying to avoid falling down a pit stands a better chance of snagging a ledge if the x is resolved first, while a player trying to just barely jump over a spike will find it a lot easier if the the y is resolved first. You could resolve both first, but now an object might move through a diagonal hole much smaller than the object because the two object sized check regions are on opposite sides of the whole with an overlapping region in the middle that does fit. (Think of how the overlapping section of a venn diagram isn't as long as the full diameter of either circle.)

You can solve most of these problems for a simple game by moving the object one pixel at a time. This way you hit the first object first and if you balance your x and y changes you can move in approximately the right diagonal shape. with slips only ever being by one pixel, which the user is unlikely to notice. The problem here is one of scalability. Checking every object against every other project for every pixel traveled is painfully inefficient once there are more than a hand full of objects.

And this is the meat of the problem and the point I wanted to make with that tweet. Collisions are n squared no mater how you handle them. Every object against every other object. Almost all the well known techniques are made to make the check simpler, or reduce the number of objects considered: only check the collisions with moving objects, combine walls in a row or column into a contiguous object, only collide with certain types of objects, narrow the field with quad trees (or oct trees in 3D), all just reducing n. Nothing can really fix the complexity of it. No matter how you slice it, it's going to make you cry.

And what I've ben working on doesn't really do much better, but it does aim to be an improved version of the simple iterative method, only checking the space at the necessary level of detail. It's gone through a couple revisions since the original idea of expanding the above, below, left of, right of test, (henceforth ABRL) breaking each line into a combination of a sloped line and a vertical or horizontal section as shown below.

At the outset this seemed like a clever idea, setting up 4 tests for each motion, then running every object against them to basically use the same technique, but accounting for the motion of the object. The tests of course would have to be generated for each moving object (or subject), but that wasn't the killer. The problem was deciding weather to measure each the other object against the slope or the orthogonal portion of each side. This was easy if this was the only case, but invert either the x or y direction and every one of those tests would change. This led to an if tree that got about 4 layers deep and differed only in the very fine details from case to case, making it extremely difficult to generalize, and really hard to write bug free by hand. A wise man once said that good programmers are lazy. If something looks like it's going be a gigantic pain in the ass in which you have to fine tune every little detail, you probably aren't using a very efficient method of doing it.

I briefly hit upon the idea of using vector math to rotate all objects about the origin until the situation mirrored the one case with a positive x and y shown above, this may still be a viable idea, but the process of rotating all the objects changes the relation between their width and height and the origin of the object, since that origin may be in a corner other than the top left. There may be a smart way to deal with that, but I was starting to see another giant if tree forming and decided to back up and rethink the entire strategy.

Having shelved this for a while, I looked it over again after my last post, vowing to complete a project, any project, and a good collision library has been a sorely missed asset in my various jam projects, so it seemed like a good choice to get myself up to speed with again. (Yes I do realize that almost 2 months have passed and I really need to focus on that speed part.)

I went back to the iterative solutions and came up with a three level collision check. On the first level, I check one box containing the initial position in one corner, the final position in the opposite corner, and everything in between. This is over checking by a lot, but it is only here for two reasons: one, find out if more detailed collision checking is necessary, and two, narrow the list of objects that might be crashed into to only those which collide with this box. This way, later checks with very little movement between checks, will compensate by having very small lists of candidates.

The second level moves the object moves the object by unit differently depending on its velocity. If the velocity has an x component of greater magnitude, the object moves based on its width, otherwise it moves based on the objects height. Whichever is chosen is considered the primary length, while the other is the secondary length. The idea is to define a series of boxes with the original position once again in one corner with the opposite corner containing a new position that is moved one primary length forward in the primary dimension, and an appropriate distance in the secondary dimension according to the velocity. This way the box encompasses this step's actual covered area and the box around it the same way the first level did for the entire trip. If there is no object in the box to collide with, the destination becomes the new origin, and the process repeats.

If a collision was detected, the method goes back to the tried and true, move the object along its course one pixel at a time until a collision is detected. If no collision, go back to level 2, if there is a collision, then there was a collision and the object, or objects detected are returned as the result.

I could go into more detail about the inner workings, but I think it's all better explained by this visual debugging program which I build to develop it. The blue box is the subject. Move the mouse and click to test a final position. The box moving with the mouse is the intended final position will be green if it made it there without colliding, and red if it did not. The pink sections are the collision boxes used in the section of code that returned the result. Level one collision boxes are not shown. The lines that can be collided with will turn red if they were considered in the deciding check.

Download test page at:
https://github.com/Lambwatt/CollisionSys/blob/master/debugCollisionDemo.html

As you can see, the last collision box in level two can actually extend beyond the final position. I intended to specially handle this edge case, but it turned out to be rather problematic, and it didn't seem to be having problems with it anyway. The reason no new problems emerge is that the level 2 checks only check the results from the level 1 check, not the global list of objects. This means that an object colliding with a level 2 check but not a level 1 check is actually invisible to the level 2 check so it doesn't cause any errors.

It's not a pretty algorithm. It's a bit more convoluted than I intended and it uses a lot of complex return values, (objects sent back with companion data to the intended return value), and it isn't sophisticated enough to handle hit boxes being on an angle. But for most of the games I would be making at jams, this is sufficient without requiring any new infrastructure around it, like a quad tree implementation, and works well enough even with a huge number of objects flying around the screen. And my real criteria for success was to be able to hold a bunch of objects with 1 pixel thick walls. As shown in the demo below (press and hold the left mouse button to advance time.), I believe I've done that*.

Download demo at:
https://github.com/Lambwatt/CollisionSys/blob/master/stressTestDemo.html

All code related to this project can be found at https://github.com/Lambwatt/CollisionSys.git

I'm Michael Pattie, and this day <checks calendar> 53.... damn.

*The demo piece hit some weird cases with particles below about 6 pixels by 6 pixels and completely breaks for 1 x 1 particles, however these seem to be more related to the less well thought out way in which I resolve collisions than a failure to detect them. I decided what I had was good enough for me to move on. It's time I got back to a certain other project.

Thursday, 1 May 2014

Lambwattage 2.0

Greetings interwebs,

I've been pretty quite lately, and for that I'm sorry.

I also didn't do that thing I was going to do, and I'm sorry for that too.

What thing you ask? Pick any one you want, this blog has basically been one long string of broken promises. (Except the hair thing. It remains uncut.)

I want to promise that will change tonight, but I feel I've lost my credibility.

Nevertheless, tonight IS different. Up till now, I've been a student. My life came in 4 month blocks, each its own fresh start. Each time I swear I'm going to get more done, and each time I have failed. But tonight is different.

The last two terms have been a co-op in Vancouver. I liked the job and they liked me enough to hire me indefinitely. Today is the first time in 6 years that there is not another semester coming. Of course if you count high school and elementary school, then it's been nineteen years all together. 19 years of another fresh start just around the corner. but not tonight. From now on, some other institution is not sending me things to learn nor burning up my off hours. The learning, the teaching, the work, and the motivation will only come from me.

I recently saw "The Wind Rises," an anime about an aviation engineer as he creates the Zero fighter amongst the political turmoil of the twentieth century. He is told at one point that an engineer has 10 good years before he becomes old and useless. The count started from the day he graduated and he is told to use them well. I am also an engineer, and as of today I am no longer in any form of school. My ten years start tonight.

I want to use my ten years well too, so I'm dusting off this blog and trying to buckle down again. One last fresh start. No more mulligans.


This is Lambwattage 2.0,

I'm Michael Pattie, a software engineer and game designer,

and this day 1.

Friday, 24 January 2014

On The Dangers of Creepy Pasta

Good morning(?) interwebs,

So I'm writing this stream of consciousness style while sitting in bed at 3:30 in the morning because roughly an hour ago I listened to a creepy pasta story and wanting the benefit of actually sleeping without the cons of having to have my eyes closed or dreaming. In order to get myself more comfortable I have been watching a bunch of Ze Frank and TED talks, but this has only led me to hear my own thoughts in Ze's voice and phrasing. Not a terribly good sedative, but a great motivator to go blog.

I've been allergic to horror in pretty much all forms since I was a kid. I didn't go near it except when I saw pieces of it accidentally while tuning in for something else. And I wasn't even comfortable with the tame kids stuff, I was uncomfortable with "Goosebumps" and "Are you afraid of the dark?", the latter probably owing to the fact that I was, and still am. sort of. It mellows out most of the time, but when I've seen something that disturbed me, I find it comes roaring back and I need the lights to always be on around me. That and opening closed doors to dark places becomes a terrifying experience as I picture what might already be detecting me on the other side and preparing for an ambush in that first blind moment.

As I've gotten older though, It has become more manageable. Much like pain tolerance, the familiarity of the sensation and the perspective of more intense emotions allows me to ignore it more easily. I find myself remembering a comment by Susan Arendt about watching a lot of horror movies and playing horror games, and finding that over time, they had a sort of inoculating effect. Confronting horror through experiences that are intense, but ultimately safe. The mind gets used to these feelings and is therefore better to manage them in the real world.

And in relating this back to games, I thought about a classic game design skill: learning through analysis of your own emotions. It's tricky to do, since you need to thing about what you are feeling and why at the moment when you are feeling it, and you still have to have be feeling it at the same time. But if you can get good at it, it's a great way to study experiences in all forms and figure out what about them is compelling or off putting. And I find this has also been the technique by which I manage this fear. As I'm walking down the dark hallway, which I know is empty even though my mind keeps conjuring things to be in it, I am aware of my fear of the dark, the things my mind is conjuring and the physical sensations. And that helps me label them and put them in a box to study instead of feeling. There's a kind of distancing there, as if I am in fact in a horror movie, but my consciousness is outside sitting on the couch, watching it all on a screen and knowing it is a movie and not real.

The whole thing also reminded me of a conversation from earlier today. (or yesterday I guess.) One of my co-workers children was getting shot, and the nurse was surprised to see the child intensely, and calmly observing the shot rather than looking away or crying. Here to there seems to be a calming effect from observation. I think it's a combination of increased apparent control and distraction. Now that you are observing, you expect that sensations will soon be traveling to your brain and you will need to pay attention to them and make mental notes. This sort of observation and distraction can also bee seen on those unfortunate occasions when you need to remove a sliver from your skin with a needle. Not being a surgeon, I find i usually tear up the area of the skin with a lot of misses, but the experience doesn't feel anxious because I expect the pain, and as the source of the pain, I can stop damaging myself at anytime.  On the whole, it's a far less distressing experience than  having the same thing done to you by someone else.

I think I've gone on long enough with this, but before I go, I should probably explain why I am still awake and watching youtube videos this late. I left some personal project work to this point in the week, still hoping to sneak most of it in before friday when the global game jam starts. Then I realized this morning that my evening was already occupied by an event I'd almost forgotten about. When I got home, I still wanted to get it done, so I downed some tee to stay awake and got down to work, by which I mean watching youtube videos with the attention of working at some point. And then I came across the aforementioned pasta, and the rest I've told you.

This was fun, but I really need to get to bed. Good ni............

Tuesday, 25 June 2013

Updates and Things to Come

Hey Interwebs,

Sorry for the gigantic delay. I've been busy with so many things in the last several months that the blog got a bit neglected. Rest assured, I have been working, I just haven't done a good job talking about it.

I suppose I should start with the biggest news. I have a website now. You can check it out here. It's not the most amazing thing ever and there's no backend to speak of, but since all I needed was something to sit there and show off my resume and prototypes, it gets the job done. The most dynamic thing I would be working with is this blog anyway, so all I need to do is link to it. I may try to integrate the blog into the site proper later but it's pretty far down on my list of things.

Next: STRATAGEM UPDATE

I have some rudimentary jQuery communication working and the front end is now returned by the server, giving the 1st contact the 1st player and the 2nd contact the 2nd player. Next order of business is to get the turns encoded and sent to the server then handle the responses on the front end. This involves building an animation system, so it's been just enough work to keep me interested in other projects. However, my hair is becoming problematic again (for those new to this blog, I pledged not to cut my hair again until stratagem saw some form of release), so my motivation to get back on it is steadily rising.

One of my other big projects last semester was developing a Flashpunk game for NEPTUNE Canada that could be used to educate people about the project, a massive underwater cabled observatory that allows hundreds of instruments to stream their readings live to NEPTUNE's archives and the Internet at large. We, my teammates, Tom and Colton, and I, developed a skeletal prototype for the game. You can play it on my website here.

We also had a summer game jam a couple weeks ago, this time with an emphasis on developing games for the new UVGD project, Verb the Noun, a minigame collection in FlashPunk. I brought my contribution, Repeat the Level, to a pretty much playable state, although the game doesn't really end yet and the assets are only standins. The idea is that the level will repeat over and over with the obstacles in the same order each time, however, the assets will get simpler and simpler until some of the obstacles are indistinguishable from each other. Players must remember the sequence to reach the end. I'll get back to this one pretty soon. For now you can play the prototype here.

Lastly, I would be remiss if I didn't mention Jeode. What is Jeode you ask. Well the short version is that it's a templating system for creating programs, games in my case, that I have been developing for my own use. The project is in Ruby and you can find out more here, but I plan to have a full post about it in a week or so, once I've taken care of a couple other bits of work I need to attend to. Suffices to say that I'm excited about it, and I can't seem to put it down. And that's a very good thing.

And that's all for now.

Keep calm, and wait for more news about Jeode.

Saturday, 2 March 2013

Tsukino-con Followup, Javascript, and a Useful Code Segment

Howdy interwebs!

Sorry this is a bit late, but 1 week is actually better than I normally do.

So the Strategem front end now has most of the functions I wanted to get in for the extremely basic prototype.  It distinguishes which units are yours and which are not, you can save orders in terms of angles.  The on screen pathfinding still has a bug when it switches cases, but as of now it isn't worth hunting down.  On the bright side, aside from the bug, the pathfinding system works just like I wanted.  

The architecture is in a somewhat unmanageable state as all the work has been done in a single javascript file, which is now up to 600 lines.  Yikes. There is a discernible model-view-controller split so the next version should be able to put them in different files and either assemble them with the builder, or just reference them on the server.  Web architecture is still rather alien to me, although javascript itself is less so now. Prior to this work all I had done with the language was a few scripts running in a django system, (that's a python server system, not a slave system rising up against the oppressive admin that stole its wife.)  and some short scripts for a security course.  

Javascript architecture lives in the strange domain of the web script, where there isn't a clear main and scope is an eternal mystery.  Depending on how you look at it, scripts are either run in a space with several global variables, or in a class with several member variables that can be accessed throughout.  Either way, I found that the singleton pattern to be both incredibly useful and easy to set up.  

var Singleton = new function Singleton(){
   //Add variables here
}

I realize it's debatable wether this is genuinely a singleton, or just a global object in which I can put several other variables and can be reliably retrieved with a simple "Game.x", but in the end, with everything being the same script, it had the same effect.  The example I was using online also had the usual getInstance() method, but the Game. syntax was shorter and worked well enough. 

This doesn't detract from my larger point, that in javascript, since document is floating around anyway, having game next to it doesn't seem out of place, making javascript an unusual place where global variables are not a mortal sin.

You know, it dawns on me that I very rarely post code on this site.  I should fix that, and I know just how.  Behold:

function getAngle(xo, yo, xd, yd)
{
    var x = xd - xo;
    var y = yd - yo;
    var angle = 0;

    if(x == 0)
    {
     if(y > 0){ angle = 270;}
     else if(y < 0){ angle = 90; }
    }
    else if (y == 0)
    {
     if(x > 0){ angle = 0;}
     else if(x < 0){angle = 180; }
    }
    else
    {
     //var tmp_angle;
     var tmp_angle = Math.atan(Math.abs(y)/Math.abs(x)) * 180 /      Math.PI;

     var rem = tmp_angle % 45;
     if(Math.floor(rem/22) < 1)
     {
            tmp_angle -= rem;
     }else{
            tmp_angle += (45-rem);
     }

     //var switch_var;
     switch_var = 0;
     if(x>0){ switch_var+=1;}
     if(y>0){ switch_var+=2;}
     switch(switch_var)
     {
      case 0:          //quadrant 2
           angle = 90 + tmp_angle;
           break;
      case 1:          //quadrant 1
           angle = 0 +  tmp_angle;
           break;
      case 2:          //quadrant 3
           angle = 180 +  tmp_angle;
           break;
      case 3:          //quadrant 4
           angle = 270 + tmp_angle;
           break;
     }
    }
    return angle;
    
}

This is a simple function I wrote for Jeubble to make the bubble shooter rotate to face the mouse, butwhen testers found the controls too touchy, I added in this section:

var rem = tmp_angle % 45;
if(Math.floor(rem/22) < 1)
{
     tmp_angle -= rem;
}else{
     tmp_angle += (45-rem);
}

Basically it separates the angle into 45 degree increments.  The original Jeubble version used 15 degree increments, but Stratagem uses 45 degrees to differentiate between the 8 possible1 space moves from a given square.  I also recently used this function in the NEPTUNE game to deal with the different directions available from hex and takes th increment as a paramater instead.  It's probably the best version of this, but it's on my other computer and I don't want to dig through github right now.  Anyway, when you find you've used the same code 3 times, its time to save it somewhere.

Let's break it down.

This first part assigns the x and y components and initializes the output angle to zero.  Nothing fancy yet so I didn't copy it.  But the next part is where things get interesting.


    if(x == 0)
    {
     if(y > 0){ angle = 270;}
     else if(y < 0){ angle = 90; }
    }
    else if (y == 0)
    {
     if(x > 0){ angle = 0;}
     else if(x < 0){angle = 180; }
    }
    else
    {
     //var tmp_angle;
     var tmp_angle = Math.atan(Math.abs(y)/Math.abs(x)) * 180 /      Math.PI;


Typical use of a tan function has issues about where it works.  Firstly, at 0,90,180, or 270,  there is often some sort of asymptotic bug.  Game Maker has probably the funniest version of this where rather than crashing, the angle just grows, so the object will slowly rotate forever.  Signs also don't match in most cases, because screen coordinates are reflected in the x axis (positive y is down).  Lastly, atan is only defined over a 180 degree section between 2 asymptotes.  I've found this varies from implementation to implementation, but the one thing you can always count on is the first quadrant, 0 to 90 degrees, being accurate.

To deal with these issues, my function starts by catching all 4 asymptotes.  First it checks if one of the coordinates is 0, then checks if the other is above or below zero.  The double zero case kind of slips harmlessly through the cracks.  It takes the first if because x==0, but it doesn't take either of the followups, and instead jumps to the end of the function without changing the initial value of angle.  So in the end, the method returns 0, which while not technically correct, isn't detrimental to an place I've used this program.

The else section takes the arctan of the ratio of the 2 absolute coordinates, giving an angle 1-89 degrees above the positive x axis.  The next step is the truncation bit we talked about earlier:


var rem = tmp_angle % 45;
if(Math.floor(rem/22) < 1)
{
     tmp_angle -= rem;
}else{
     tmp_angle += (45-rem);
}


It takes the remainder of the angle retrieved in the else and rounds it to the nearest multiple of 45.  So now we have an angle of 0, 45 or 90.  Obviously there are 5 other possibile angles which aren't represented, so we need to take our answer out of the 1st quadrant and translate it to the correct one.


     //var switch_var;
     switch_var = 0;
     if(x>0){ switch_var+=1;}
     if(y>0){ switch_var+=2;}
     switch(switch_var)
     {
      case 0:          //quadrant 2
           angle = 90 + tmp_angle;
           break;
      case 1:          //quadrant 1
           angle = 0 +  tmp_angle;
           break;
      case 2:          //quadrant 3
           angle = 180 +  tmp_angle;
           break;
      case 3:          //quadrant 4
           angle = 270 + tmp_angle;
           break;
     }
    }
    return angle;

Ah switch case manipulation, how I love it.  Switch cases are in the same camp as for loops in the school of constructs created to quickly perform a simple common operation that can be subtly reworked if you know what you're doing, and made to perform a more complex, but fundamentally similar operation.  This isn't too much of a hack, but it does demonstrate creative use of the switch variable. 

First let me stress that this is done for screen coordinates rather than normal coordinates, so positive y is down.  So we once again start by checking the x and y coordinates against 0.  We can think of our 4 quadrants as hypercube in 2 dimensions.  I'm using x as the bit 0 value and y for the bit 1.  In an integer, these correspond to adding 1 and adding 2 respectively.  This creates a number between 0 and 3 that will correspond to the quadrant.  In each quadrant, we assign angle to be the tmp_angle is between angle and the x-axis.

And then we're done.  So the function isn't amazing or super insightful or even as general as it could be,  but it is useful and it has prompted me to start a pseudocode list for UVic Gamdev of useful functions like this one that can be dropped into any program and modified to fit the language.

Well I hope you find this useful random reader, and don't be afraid to tell me how I could make it better, or how much it sucks, or how it was the missing piece that made your most difficult problem suddenly go away.  I'm not realistically expecting that last one, but hey, a guy can dream.