Wednesday, March 30, 2011

Valley Story continues

Yeah, still working on Valley Story. Harder than I thought this would be.

Right now I'm trying to get the graphics working on iOS. My previous prototype was in Javascript, so now I have to take what I learned from my JS code and write equivalent in Objective C. One big thing I learned was that I probably don't need a full isometric engine for this. Instead I can just have sprites for the player characters and for anything that might be in front of them, which isn't very many things since I can control the paths of the characters to avoid getting too near any obstacles.

I'm planning on totally isolating the game logic from the graphics. The game logic will just spout out commands like "Drew walked in the door", "Drew sat in the chair" and then my graphics code will show that. This lets me prototype the gameplay as text while I still don't have graphics for everything.

Sprites I'm going to show by just creating UIImageViews and moving them around on the screen. So when the graphics code gets a message like "Drew walked in the door" from the game logic, it will first see if we have this "Drew" guy already on screen. If not, then it will look at character definitions to see which sprite sheet Drew should be using. Further which sprite in that sheet, cuts out that UIImage from the sheet and updates Drew's UIImageView using that. Then it keeps updating the graphics and location while Drew walks around, sorting the UIImageViews properly so that it appears in front of / behind other stuff.

Here's another shortcut that I came up with from my prototype. In the prototype I had a "sort point" for each sprite that signified the point in the texture that should be used when deciding if this character is in front of / behind something. I don't really need that, instead I can align all sprites such that the sort points would overlap by just positioning more carefully in my art.

I know UIImageView already has "animationImages" and "startAnimating", but it seems more convenient to do it myself each frame as I have to update the view location there anyway. Also my graphics in the sprite sheet might not be in the order I want to animate them in and the ordering might depend on what the character is doing. Like if they are sitting down I have to show some sprites in the opposite order than if they are getting up.