Fucking flash

Riddle me this.

You're using Flash-based software on a really old Windows PC to teach an English class. The images displayed during a song lag. What do you do to fix it?

If your answer was "Click on the roleplaying section, close it and then play the song." Your answer is totally correct.

I am wracking my brain here to figure out why this would work. Is there some part of the code where closing out the roleplaying section releases some memory the application was using and lets the application run better? Mind you, this works opening and closing any of the various roleplaying sections, and it works even if you never touched the roleplaying section while using the app. Just if the application happens to slow down, you can speed it up again by opening and closing this one section.

It has to be a memory thing, right? The app isn't managing memory right and yet there is a bit of code in closing the roleplaying section that does manage it and lets it behave better? Maybe it loads the roleplaying section(s) when you open the app an that causes the slowdown on some PCs?

Holy shit, I hate this software. There are new textbooks next year and I worry the software will somehow be worse than this shit.

I forgot my iPad

I have been using my iPad a lot for work this year. Yet somehow this morning for the first time since I bought it last year I forgot it. I meant to put it in my bag. But in my bag it did not end up.

So I get to work and realize that I am doing something every day that requires the iPad now. The students got used to it. Shit. What am I going to do? Well, I have my iPhone, but all my apps are on the iPad.

Except I have Xcode on my computer. And I have the projects for those apps. So I build them for my iPhone and they run. One needed a bit of a layout change but other than that they were up and running in seconds. And then I just used Air Play from my iPhone instead. Classes went great.

I just love a happy ending.

Switching over

I started working on a game in early 2012. I got fairly far but after the engine by hand, I found I was doing a lot of manual creation for tile-map layouts. I stalled. Then I discovered a map engine that could be used with Cocos2d. Awesome. I ported it over. The touch controls just didn't feel good. I stalled. This weekend I rewrote it in Unity. Both in the original and in the tile-map versions, I simply had some files that contained all the map data. So I figured I'd do that with Unity. One scene per room. But that felt clunky and silly. Plus, every time new room would load the controller would stop taking input on anything held down. Not cool.

So now I'm doing it how I think it should be done in Unity. Each room is a GameObject and they get activated and deactivated as the player enters (and thereby leaves) rooms. And it works! I had to fix some math for bounds checking, but the camera just dances around the scene as necessary. Which should allow me to do some cool ideas I wasn't sure how I was going to handle if each room was a completely separate entity.

[rainblocks development retrospective] 19 - Sliding and the web

2014.03.28- Added subaku to web view - Added Rotation for web view

There was a gross-looking web view that I had for "How to Play" which just described the game and had a link at the bottom to subaku. It was pretty gross.

2014.04.24 - Added sliding movement

This was a big deal and took a lot of time to tweak to be smooth and usable. You can slide a little bit (anywhere on the screen) and see what would happen. Once you let go, if the block was moved more than a certain amount the slide would happen and the . I wrote down that I "added sliding movement" but it was a few weeks until it was right.

Fixing flying blocks [rainblocks]

Bugs found and fixed! Weird little bug in the Android version of rainblocks. If you exit the application during the tutorial, the blocks will be gone when you go back. Whoops! What happens is that the game tries to pause, but since there is no pause menu for the tutorial it just hides the blocks. Simple fix - just don't force it to pause if it is in the tutorial. No reason to, as there is no time limit here. This fix, plus a Japanese localization, is in the 1.0.1 release which you can get now.

Another little weird bug which I fixed after uploading 1.0.1 was the blocks sometimes flying to different positions when moving a block that can't move. It was a problem with the blocks remembering their starting position as part of how they should shake in the case of a bad move. It has no impact on the gameplay but looks weird graphically when it happens. But that's been fixed and will be in an update after I confirm that there is nothing else odd going on.

Localizing in Unity [rainblocks]

Researching into doing localizations for Unity, I found a lot of plugins, but no "here's how to do it" solution. I was so used to using NSLocalizedString() to handle all of my localization needs, even art. (Just fill up the localization plist with the different file names.) But I'm new to Unity and unfamiliar with its best practices. I wasn't sure what to do until I ran into Application.systemLanguage. All the menu items in rainblocks are images (because of the custom fonts), so I just created the following script and attached it to all of the necessary Game Objects.

using UnityEngine;
using System.Collections;

public class TextLocalization : MonoBehaviour {

  void Awake() {
    SpriteRenderer renderer = GetComponent<SpriteRenderer>() as SpriteRenderer;
    renderer.sprite = Resources.Load(Constants.SpritePath() + renderer.sprite.name, typeof(Sprite)) as Sprite;
  }
}

And this function went into my Constants class which I use for a bunch of helper functions and static variables.

static public string SpritePath(){
  string retVal = "Text/";
  if (Application.systemLanguage == SystemLanguage.Japanese) {
    retVal += "text_jp/";
  }
  return retVal;
}

So if the SystemLanguage is Japanese, it points to the proper folder for the images. If I add any more localizations, all I'll need to do is plop them in the right folder and add a check in SpritePath. If there is a better or easier way to do this, I'd love to know it. It did, however, take me less than ten minutes and not much code to have the whole game localized in Japanese.

[rainblocks development retrospective] 17 Fixed again?

2014.03.17- Added level select - Changed time gained per match to half of the speed - Fixed animation bug - Changed rainbow display - Cleaned up rainbow and added text - Sent out beta #6

I had completely forgotten that I was sending out betas this early. The game was pretty much "done" at this point, it was just the fine-tuning stage until the art was ready. Level select was originally a debug-type thing which turned into an unlock for those who paid to remove the ads. Once again I thought I had the animation issue figured out. This really was the greatest challenge of programming rainblocks for me.

[rainblocks development retrospective] 15: Leveling up

2014.03.15- Added level singleton - Added level leaderboards

Adding levels also allowed for the introduction of leaderboards for each level. These are time based leaderboards for how fast players complete one of the stages. Sure, starting out on a level means there would be a bit of a bonus in remaining time and starting with a rainbow. The rhythm is not there, however, nor can you hop into a level far ahead with a big combo from the previous level.

So I'd like to think it balances out, particularly since the stage select is available as part of the ad-removal In App Purchase.

The yearly Apache fixing

Ah, the yearly tradition of updating OS X and then forgetting that Apache/PHP/MySQL gets turned off for... safety reasons? I dunno. But if you, like me, use a PHP script to play a digital version of the memory game with Christmas themed objects and need your script working in time for class today, this article can help you too! Also this Stack Overflow “question" proved to be exactly what I needed to do to finish getting MySQL up and running.