Friday, July 24, 2009

PHP global variables

I was fighting with an issue that turned out to be pretty simple in the end - variable scope.

As I'm going through and cleaning up the code for the game project, I'm going through and making functions out of things that should be functions. Being a not-so-good-programmer type with minimal experience, I didn't know (or think) about variable scope (which makes total sense to me now).

I was having issues passing vars back and forth between functions, and was getting no love. Now, I've made the appropriate global calls and everything is working!

Chalk up another learned lesson. Yay lessons!

Thursday, July 23, 2009

Game project - now for the confusion

In ways, I'm at a really good point right now. I've get very basic functionality working for combat. VERY simple stuff right now until I can grasp the more complex stuff.

Unfortunately, I've hit the point I always seem to hit: Everything has become extremely convoluted and I'm having trouble keeping track of where everythign is. I'm trying to clean it all up, but I'm not entirely sure what best practices to use, so I'm developing my own organically, dynamically.

I'll do more cleanup in the morning. once everything is neat and in order, I think the rest will fall into place.

PHP Project - Stupid game

A few days ago, I decided to start a simple little game with PHP as my chosen language. Why PHP? I see a lot of job prospects asking for PHP skills, so I figure a little sharpening (ok, a LOT of sharpening) couldn't hurt.

The general structure is coming along ok, but I've hit a big snag - the combat system. This is the part of all code projects that I eventually reach where the complexity gets a little overwhelming. I'm going to try really hard not to give up out of frustration - hopefully by focusing on the simpler parts, until I figure out the hard parts.

Now, I have to say, the first "hard parts" was on day 2 when I moved all data from internal arrays to a mysql db. Simple? Sure, but I was never great with mysql stuff from scratch (now THAT was a good exercise!). It was daunting and I kept tryinig to avoid it, but I finally did it and now it's easy. I just have to get to the same point here. It's not any specific syntax, it's just the logic.