Welcome to my Programming Blog...

I am currently working on a couple of projects: An original game called "Implosion" which I am porting from Flash to the iPad, and a remake of Q*bert in Python (pygame), as part of the class I am teaching. Please feel free to use the "Labels" (at right) to follow a specific project or theme. If you are one of my Python students, I recommend that you check out the Python thread.

Saturday, June 19, 2010

Fans...

Whaddaya know? A shallower fan works. Onto the next windmill....

Memories...

A bit of a delay since my last post - I've been tilting windmills. (Actually, I've been hunting memory leaks, which are less satisfying.)

But first, I've been trying to make some fans (besides you, dear reader). The fans in question are 8 bladed, fan shaped objects that start off in front of the purple rings, so they are entirely visible. Then, as time goes by, they move backward, so that they gradually sink into the rings and out of sight. I'm not entirely happy with the look, but the idea of a secondary object that will partially obscure the main shape is one I'm pretty settled on. When the timer expires, both the ring and the fan should disappear, and they should be replaced by one of the original shapes.

The issue has been that although I could make the ring go away, and the new shape would appear, the fan didn't disappear. The code to make it do so was placed in the "deallocation" method, and it never was being called. And it wasn't being called because I was having an imbalance in my memory retain/release calls.

Memory management is one of the more annoying parts of the older, C - based language, of which Objective C is one. In Objective C, every time you create an object, add it to a list or tell another object about it, it keeps a count of how many objects know about it (a "retain count".) Whenever you remove an object from a list or another object stops keeping track of it, the retain count should decrease (it should be "released." ) If the retain count ever gets to zero, the computer knows it can safely stop keeping track of it. In my case, it never quite got to zero. And so I spent several evenings trying to hunt down what I had done wrong.

As it turns out, it wasn't the lists I was adding the rings to, nor was it the way I created the rings in the first place. Even the objects I was telling about the rings (the next and previous chips in the sequence) were handling the retain counts properly - I just wasn't ever telling them to let go. I made the new chip follow and lead the old one (which I didn't mean to do), but the preceding and following chips still held the same connections. Once fixed, the chips and rings started working tonight.

I'm still not happy with the fans, though. Because they are angled, the light hits some vanes better than others, so only half of them appear. And because they are almost as thick as the ring itself, there is a definite difference in apparent size of the fans between the leading edges and the rear edges - they show up around the outside and inside of the ring, when they should be exactly the same size - all because of perspective. In short, it looks ugly and distracting.

So, I am going to try tilting the fans to less than 45° to see whether that helps, and if not, we will go for a shrinking disk in the middle, a lá the timer.

Saturday, June 12, 2010

"My God, It's Full of...."

I've added two new features to the Implosion game. First, stars. When the player clears a level he or she earns a star - the purple stars appear under the game grid, and the player may collect quite a few of them. If the player has a star, he or she may use a three-finger swipe to use it - doing so lets them advance to the next selector. This is quite handy if the player is having trouble matching the current shape.

I had a little bit of trouble getting the star to show up. I am getting better at blender - I was able to make the star pretty easily, and got the vertices colored nicely. But no matter what I did, I couldn't get it to show up in the game. Then I realized that I had created the star in a backup copy of the implosion folder - so it wasn't associated with the current version of the game! Doh! This "encouraged" me to learn how to copy objects from one blender file to another. (Here's the online resource I found.)

The second thing I did was add an "on-deck" selector shape to the screen. This lets the player anticipate what is coming next, and make a better decision about whether to use a star. It took a pretty short amount of time to get it working, so that was nice. (Of course, that means there's probably a bug it it that I haven't noticed yet....)

Next up: It's time for me to get the timed obstacle chips up and running. These pieces can't be selected - after a while they "pop" and replace themselves with a random chip of the original four flavors. This is what the original purple ring chips are for, but I want to have a way to indicate the progress of the chip towards popping. Again, I'd like for it to be something that makes sense from any angle, and although I could do a radial effect like the timer, I think I would like it to look different. My current thought is of a "fan-shaped" obscuring object that disappears over time. We shall see.

Tuesday, June 8, 2010

Saturday, June 5, 2010

Leveling up

Now that the doors are working (and they show up where they belong - I had forgotten to add the doors to objectsToDraw), it has been short work to make them open when the user removes the chips at the corresponding locations. Next, I have a "level up" mechanism working, so that when a certain number of doors opens, the level advances and the doors all close. (The catch is that there will need to be more doors opened to get to the next level...)

While I was at it, I added in some sounds. I've borrowed the sound effects from the original Flash version I wrote, so the game feels more visceral to me now.

Next up, I am splitting my time between creating a timer and putting some text on the screen. I am trying to come up with a timer that makes sense when viewed from any angle - it needs to be radially symmetric, but still convey both macroscopic and microscopic change. I've got an idea for this - I hope to post it soon. The text will be for such things as "level," "doors remaining," "score," and various hints at the start of the game. It should be pretty easy, so I may add it in before I start on the timer....

Thursday, June 3, 2010

One door closes and another one opens

Working on getting the doors to appear under the Chips. It's starting to become familiar territory now. I was able to make a squashed cube in record time, vertex painted it, exported it, and started work on importing it into the program. I've made a custom "Door" class, (updated it to be C++/ObjC), and made mechanisms for opening and closing the doors. Looks good so far, the only problem is that all the doors are showing up in the same place. - I must have missed a parameter somewhere, and it should be a quick fix, but I had to call it a night.

(I had to loan my iPad to somebody last night, too. Lonely!)