Saturday, October 30, 2010

TIGjam Day 2 and Photos

I decided on a game with Adam, which is to be announced later. The game includes a lot of scrolling to the right and is more about 'the experience' than winning or losing. But it's not an art game! (Or is it?)

We're in between TIGjam days 2 and 3 right now. I am currently blogging from my parents' house because I slept A LOT, which I needed. Yesterday was excellent (more learning, more lively than Thursday) and I bet today will be awesome, too.

This is about what TIGjam looks like during the day:

This is what TIGjam looks like when you stay around until 1am:
Playing games late at night

Two observations about TIGjam:
1. It's a lot like SuperHappyDevHouse, except it actually seems a lot more productive. Maybe because EVERYONE is working on games? Probably because it's 4 days instead of 1 and you feel like you could actually complete something in that time.

2. It's a lot like my lab at school, and damn, I am really lucky to get to make games for my PhD. [I'm a computer science PhD student at UW and my lab makes games like Foldit, Photocity, and Refraction.] I am surround (at TIGjam and at school) by people making games (mostly in Flash), artists, people chatting, people chatting about games. Sometimes there's too much going on and it's hard to work, but it's totally interesting and inspiring if you stop working and pay attention to the conversations around you.

Friday, October 29, 2010

TIGjam Day 1 and learning Flash and Flixel

So, I went to the first day of tigjam 3 today! It continues tomorrow and all through the weekend. Pictures and stuff later; for now, I just want to talk about what I've learned so far.

I started learning flash just a few days ago. That may seem like not very much time, and while I haven't made that many games in my lifetime, I have used a brand new technology for just about every game, so I should be pretty good at learning this stuff. (Some games I've made organized by tech: c++/opengl, assembly, python/pygame, java/home brew game engine, python/twisted/mysql/shell scripts/php/an entire cluster of machines)

The setup for today:
Language in: actionscript3
IDE: flash builder 4
Extra libraries: flixel (
Flavor of computer: mac

As it turns out, Flixel has a lot of the elements I saw before in PyGame and even ODE. There is a main event loop, and some combination of 'move objects', 'detect collisions', 'get user input', 'draw stuff to the screen' happens each timestep.

As I acquired more and more skills throughout the day, I made two not-really-games which are not even worthy of posting online, but which I'll show you pictures of. The first game was Pong, because I knew undergrads at my school in a games capstone class started out with Pong. I got on screen text, moving paddles, a particle emitter, "scores" (score a point for hitting the ball with the paddle)... and then I got bored and moved on to other things.

The second non-game involved an animated sprite (and sprite sheet), keyboard controls again, and drawing a trail behind the player as it moved. You could basically get this little guy that wiggled his arms to skate around the screen an occasionally drift off and be lost forever.

Lessons learned:
- Oh my god don't forget to add "super.update()" in the appropriate places. Why doesn't collision work? Why isn't my sprite at the right place? Why do I have to update each sprite manually? All questions that are answered with a well-placed super duper super.update().
- Animated sprites are pretty easy.
- Particle effects are really easy.
- IF you used loadGraphic to get an image into your sprite and set the reverse argument to true, THEN you can say "facing = FlxSprite.LEFT" to change the direction of your sprite at your discretion.
- You can draw things (sprites, shapes) or a trail of things to the screen by making a big, transparent sprite the size of your game and then saying hugeSprite.draw(testSprite,x,y),  permanently rubber-stamping the smaller sprite into the huge sprite.

Sleeping now... more games tomorrow!

Monday, October 18, 2010

Mount Pilchuck Hike Report

I hiked up Mt. Pilchuck with Adam on Saturday (October 16, 2010). This weekend was possibly the last hiking-friendly weekend of the year up here in the Pacific Northwest. Anyway, conquering a mountain totally counts as a project for the purposes of this blog. Especially when the hike is tracked by GPS and the hikers encounter treacherous ice!

The trail:
There is no map at the trailhead, but the 3 mile trail (which ascends over 2,200 feet) looks like this from above:

I had hiked up to Lake Serene a few weeks ago, which is also some 2000+ feet in under 3 miles, and involves a lot of switchbacks and wooden staircases built into the trail. I expected the same of this Pilchuck mountain, but it's not really like that at all. The first mile of the trail is kind of similar: tame, upward-sloping trail, the occasional man-made steps, a little creek to hop over about 5 minutes in. At about one mile, the trail has a switchback through a bunch of boulders. The second mile is a little rockier. After about two miles, there is a lovely panoramic vista to the north, and then the trail really starts scrambling up the mountain.

The treachery:
At this point, maybe 2 miles in, I had to put my camera away so it wouldn't get crushed between myself and a rock if I slipped and fell. The trail was basically all rock at this point, which would have been okay, except that it was icy rock. Many places you'd normally want to plant your feet on the granite were too slippery. Mud from other people's boots froze on the popular stepping locations so you had think hard about where to step and aim for gravely crevasses. The iciness was probably a consequence of doing this hike mid-October.

This photo may give you a good idea of all the rocks, if not the ice. The trail manages to transport hikers from this vantage point all the way to the top of that there mountain.

distant summit

The summit:
Towards the top of the mountain, the trail came around to the sunnier South side and stopped being icy. At the top of the mountain is a nifty lookout hut with history information inside and a sweet wraparound balcony. It's not just on top of the mountain, it's on top of a crazy pile of boulders on top of the mountain. The most scrambling of the whole trip happens here to get up the boulders and then up a ladder to the lookout. It's very cool.

top of the moutain hut

Driving directions:
This hike is accessible from the Mountain Loop Highway, near Granite Falls, WA. It is a little bit past the entrance to Mt. Baker National Forest. I read on the internet (and can now confirm) that the Mt. Pilchuck access road is the right turn directly after the silver+blue truss bridge. The access road is about 7 miles long and kind of gravely. There's a parking lot at the end that requires a Northwest Forest Parking Permit.

Some handy GPS coordinates of the turnoff so you can get driving directions:
48.085808,-121.760623 (turnoff from mountain loop highway)
48.071677,-121.812766 (approximate location of parking lot trailhead)

Hiking time:
Somewhere the internet said the hike took 3.5 hours round trip. It took me 5 hours. While I consider myself a fit 20-something, I do hike kind of slowly, especially on rocky, icy terrain. I also stop frequently to take pictures.

In conclusion:
Do this hike! I recommend waiting for a dry, warmish day... and maybe bringing your hiking poles. It's fun and challenging, the summit lookout shack is neat, and the view is amazing. A whole slew of photos from my trip can be found here on Flickr.

Wednesday, October 13, 2010

Maintaining PHP Sessions Across Multiple Machines

As you may know if you've ever tried to play PhotoCity, the website likes to randomly log you out and make you log back in again before uploading more photos or checking on your progress. The reason is that there are multiple machines in a round robin hosting the website, the website uses sessions, and when a different machine picks up your request, it doesn't know about the session that says you were logged in that the first machine was using.

How to keep sessions alive and consistent across multiple machines?? Some people told me a load balancer was the answer, but since I don't actually maintain the machines myself, that wasn't an option for me.

Yesterday afternoon, I had a list of 4 potential things to work on. Vanquishing this obnoxious sessions problem was one of them. True story: I flipped a 4-sided coin/generated a random number in python, got a 3, and set to work investigating cookies vs. sessions and possible solutions. What I learned:

This is the main website I read:

Lesson 1: Cookies are cool and all (and look easy to use) and are stored locally, but they are too easy to tinker with. I could have stored a player's ID in a cookie and then checked which player was logged in, but the player could have changed a field in the cookie file to be someone else's player ID and then logged in as someone else.

Lesson 2: You can write some magic code and make a new table in your database and then trick the PHP session handler to save its data to a centralized database. I believe sessions also use really small cookies, so basically there is a cookie on the user's computer that tells the database what session ID to look up. The session ID is complicated and hard to guess. E.g. "gm6uf16d20k3vt6kjq790q9fp0". Yeah!

The first step is to make a new table in your own database.

The next step is to write your own session handler/steal this one that I just stole from someone else. Included is a php file that uses the new session handler.
link: magical_session_handler.php (.txt file)
link: hello.php (.txt file)
(I basically borrowed the code from this page, but that one had a bug or two)

You can play with the actual webpage here and watch sessions be preserved:
Without the special session handler, that page is just really simple example of sessions.

Lesson 3: THERE IS A BUG!
The super-easy answer:
By calling session_set_save_handler() again after session_destroy() it will work.

Lesson 4: If you want to display the name of the machine currently serving up your webpage (which one in your round robin, for debugging/curiosity purposes) you can write in PHP:

echo exec("hostname");

The PHP variable $_SERVER did not have quite enough information for me. However, 'hostname' is a standard unix command so you're just getting PHP to run it for you.

I haven't transferred this play example to PhotoCity yet, but I will very soon.

Monday, October 4, 2010

Android Dev Notes

I forgot where all the android dev stuff lived because it's been about 6 or 7 months since I used it. So, some notes to myself about what/where things are.

Eclipse - Yeah.
ADT - Android Development Tools plugin for Eclipse.
Accessible from within Eclipse, under Preferences.
SDK and AVD Manager - AVD = Android Virtual Devices.
Accessible from within Eclipse, under Window->SDK and AVD Manager, or by running 'android' from my terminal.
Emulator - Good ol' fake phone.
Start one from the AVD Manager. I think I can close the AVD manager after I've started up a fake phone. Yes.
ADT eclipse plugin preference page
Android SDK and AVD manager!

Also, applications with maps work better once an api key has been obtained ( AND, for some silly reason, the 'custom debug keystore' in android build preferences filled in/set to the same thing as the default debug keystore. I had been getting this error in logcat over and over again, "MapActivity Couldn't get connection factory client", until I did those 2 things.