Wednesday, April 8, 2009

The Grid

While I was playing some WAR last Friday, I was chatting with my friend Marc about doing some iPhone work on Saturday. We talked about things we would be focusing on during our dev sessions. He started talking about doing specific modules needed for his game (like actual gameplay stuff) while I was talking about learning how to do animations (something that in theory I need but not for a while). This really got me inspired to change up my approach (again) to developing this game. What I need to do is actually make stuff for the game and when tech needs arise, make them but not try to build "engine" components way ahead of time. The major benefit of this is getting to see the game unfold as I develop the tech vs having to implement later and being left with a bunch of rather useless tech demos.

So a large portion of th game is based around a hex grid. This is filled up to create territories which player(s) vie over. Ryan wants the game to have randomly generated maps which is a scary thought for me cause I've never had to deal with complex algorhitms like that. Oh well its about time I tried to challenge myself.

I have already got a basic model / view mumbo jumbo going with the grid. I've seperated the data for the grid from the actual object that renders it and provides the front end (for user interaction like touches). My next objectives are allow the user to click on the grid and producing the proper hex (or hexes) that they touched and also attempting a "seeding" model for random generation.

I've been thinking of how to properly do the touch detection. What I'm gonna try tonight is:
  1. Turn the coordinate into "tile coordinates" by using the max width/height of a hex.
  2. Find the hex based on that coordinate (assuming hexes are square).
  3. Using some kind of point/polygon test (yeaaah!), test all hexes that neighbor that hex until you find the exact one that was touched.
The Map Generation...well I'm working on an idea that Marc suggested: Seed random spots on the map and come up with some method for how they grow and expand on their own until they hit some size then analyze what kind of map is created. This more involved but I may try to setup the basic interace to this and work on another night. One good test would be to cross this growing method with the touch interaction...we could let users create their own maps to play on :).

Another objective if I have time is to take all my coordinate translation stuff so far and formalize it. Right now its a bit scattered and not really reusable without a ton of hacked code.

I feel that this approach to development is going to be more ideal (along with previous "proper planning and not reckless coding" apporach) and will also produce a prototype much faster and also more naturally.

Tuesday, March 17, 2009

Open GL'n

The "organize" approach is still paying off. Well that and getting a hook up that lets me use my much larger PC monitor with the dinky macbook monitor.

So I've moved onto OpenGL on the iPhone which will end up being the way we render most of the graphics in the game. So far, I've simply just reproduce the demo I created using Core Graphics techniques. Next step is to "kick it up" a notch.

For my next demo, I'd like to master a few different things:

Demo Overview
Create a field of sprites that are running an animation. Allow the user to click on the screen and have the camera ease to that position. Allow the user to also click and drag to slide the camera along that specific path. Allow the user to zoom out and move around then zoom back in.

Demo Goals
  1. Learning how to draw 2d textures
  2. Create a 3dVector and 4x4 matrix class
  3. Creating a "frame" class that allows for easy maintenance of matrix (possible space for nesting frames..but this may not be necessary)
  4. Creating a functional camera class
  5. Detecting and using drag events
I feel this should be plenty to do over the next couple of weeks. I'm not working every single day after work cause I found this burns me out and leaves me an even grumpier mess so I've been moving at a slower pace and finding that I am more productive during that time then just plain hatin' myself (I have some serious issues).

Once I got a basic OpenGL renderer up (a modified EAGLView class created with the GL template from XCode), I started getting this ol' feeling of new Flash Development. While its not a scripting language by any means, the enviroment has so much built in functionality that I'm finding I can move onto fun stuff pretty quickly without worrying about every piece of technology to do every little damn thing. Flash is a lot like that. You get a lot provided for you, its just a matter of using it. Once I get the camera panning around, I'll get that nerd excitment I've wanted for a while.

Tuesday, March 10, 2009

Xml Issues!

I'm still working on the writing aspect of my tech demo and fortunatly I've discovered a handly little set of code called APXML which I hope to use tonight to solve this. It allows XML to become editable and then produces a string you can then use to write it back out. While I'll still be using a binary format for some data down the road, this at least lets me make xml files for debugging purposes.

Saturday, March 7, 2009

Sensible Planning, Better Tommorow

After having some frustrations with my initial outings into iPhone Development, I took a moment to sit back and rethink my approach. Initially I was being a bit brash and trying to do things quickly and in a "hack-code" format. This usually entails trying to get around making properly organized code and doing things the dirtest fashion. What I've noticed so far is that its not that easy in iPhone development to do everything in one class/file.

Anyhoos, I approached it with a better head and took time to organize the code and was able to get most of the demo listed below done. I still haven't figured out how to save data back out so that will be the next thing I attempt.

After this, its time to redo the whole demo using OpenGL ES. Right now I'm using "Core" graphics which is apparently not good for games which have to constantly update the screen.

Monday, March 2, 2009

Note

So found some stuff on how XML parser works in Cocoa. Apparently the parser is only designed to use a delegate for callbacks when it finds elements. This makes things a little interesting when creating stuff but it really should be a problem. Pretty much need to use a NSXMLParser along with NSData objects to parse / read in file. Also found that the developer documentation on the apple (http://developer.apple.com/documentation/Cocoa/index.html) is very good. Gonna start using that more often.

Additional Note: The delegate is just one object that could possibly implement all the callbacks. So you just assign it this object.

Target Demo

I'm pretty insane about keeping solid objectives when I program. Whenever I don't I tend to get unfocused and frustrated. In that interest, I'm going to start doing these "Target Demo" posts that will lay out (in more detail then first post) what I'm trying to achieve with a demo.

Focus:
  • Reading/Writing
  • Touch Events
Objectives:
  1. Create a basic window that allows us to create some text dynamically. There should be some sample code that does this. Draw the text at some random location (could be just <0,0>). Use the whole View model to make a drawing space - this should be done automatically by OpenGL template code.
  2. Allow for touch events to move the text. Click and text will appear at that location.
  3. Create or use some data system to fetch text from file. Also save position every time you click. When application closed and restarts, text should appear it last clicked location.
  4. Add a background to text by drawing a colored rectangle. Have rectangles properties come from file io.
Tech: these are possible techs we may use / create
  • SQL Lite - for data writing/reading. Could be useful to query information with vs xml but doesn't seem like it would be friendly to edit outside program.
  • XML Reader - idea to learn how to get an xml file loaded and read in values as well as write out to it. See if we can get this system up too.
  • vec2 - 2d vector for storing rectangle position/dimensions in our own controllable format.

Saturday, February 28, 2009

It Begins Again

Back when I was still a lass in school (yet still a chubby lass as I am today) I got very used to doing all my devlopment on a laptop. The idea of working on a mobile platform was very convient because it fed my desire to NEVER stop working...which my family and friends didn't appreciate. I gave our laptop to Laura when she went to NJ cause she needed it far more then I did. I had switched back to my desktop when I started working since I was really no longer doing programming outside of work.

However, that has changed! I'm now back on laptop but this time a mac book. Lets see how it goes.

Anyhoos...I'm about to begin my first jump into xcode and get a hello world app going. I'll post back here if its succesful.

I'm in a foreign and scary place with this computer. Wish me luck...and send choclate.