Sunday, January 28, 2007

headache from hell

It's a spike to the side of the head penetrating to the eyeball about once every 20 minutes. It's been going on since Wednesday eve. I've never had a headache last more than 2 days. My usual guarantee, Excedrin, was about as effective as puppy against a cyclone. Instead, two ibuprofen did good, which it (usually) never does. If it's still there on Monday, I'm off to the doctor.

Thursday, January 25, 2007

get the DVD when it comes out

I have rarely laughed so hard in my life than at the 18 Mighty Mountain Warriors. They're an Asian comedy troupe that skewers both Asian stereotypes as well as Asians themselves. (Here's their myspace page.)

KQED, the local PBS station here, aired a documentary about these guys, and how they pitched their show to (I think two) Asian TV stations in the LA area, hoping for a regular slot.

They were certainly good enough for it. But they got turned down. Why?

The fact is, all varieties of Asians have been busy trying to roast each other centuries before anyone in Europe had figured out a use for fire. Japanese think they're better than Chinese. Chinese think they're better than Japanese. Everyone looks down on Filipinos. Everyone thinks Koreans smell funny but they're jealous of how tall they are. Everyone knows the Vietnamese are lil dwarfs but that they also kick ass ("1000 years to kick out the Chinese, 100 years for the French, 10 years for the Americans.") The 18 Mighty Mountain Warriors isn't afraid to expose and exploit those feelings for humor.

But the chickenshit TV station perceives this as damaging to the Asian image as "model" immigrants. The station wants to present a unified Asian face to the Americans (read: whites) because they still fundamentally believe we all look alike to them. They want Americans to continue thinking of Asians as serious, smart, hard working, pro-family, pro-education, trustworthy, thrifty, clean, loyal, courteous, kind, cheerful, and obedient. (Otherwise what? They'll deport us all?)

This does both the Asians and the Americans a disservice. There never has been a "unified Asia." It's as sensible a term as "unified Europe." No one considers Italians and English and Slavs and Swedes to be the same kind of people, why should anyone think Asians should be?

Support these guys. Don't let them fade into obscurity.

Memoirs of a Chinese Geisha (5:44)


Condom Ad (1:51)

Tuesday, January 23, 2007

Trader Joe's - disappointing

TJ's is good for some things: cheese, bananas, corn chips, beer, frozen fruit and veggies, desserts. Unfortunately, many of their prepared foods are simply bad because they over-pepper them. I normally love pepper, so for me to say something is over-peppered means it must be extreme. I can recommend the chicken pot pie, the quiches and calzones, but nearly nothing else.

The other thing is seasoning things that are not normally peppery. When you want tartar sauce, you don't want TJ's tartar sauce, to which they felt compelled to add some zip. TJ doesn't give you an alternate, nor do they warn you that they added some hot to it.

So I thought I knew what I could buy there. I'd been pretty pleased with their meats, the David's kosher rib eyes in particular. Good flavor and not too lean.

Today we got the kosher ground beef. Sad news: badly oversalted. Salting is normally part of the koshering process, but it's supposed to be rinsed afterwards three times. If it was rinsed, it must have been with a spray bottle or something.

Friday, January 19, 2007

mutant orange

This critter was apparently rejected by my tree as too weird to support. This is the view from above:
Here are some mug shots. He's in a seashell so as to stand up proper.



In all its full weird glory, it reminds me of Frank the rabbit in Donnie Darko. This orange basically has multiple hare lips (pun not intended.)

The part that looks like imbedded dirt appears to be the pulpy part of the flesh, but unfused and dry. There *were* grains of dirt in there, but I think those may have been brought by ants.

Sunday, January 14, 2007

Flash PnC tutorial – 6. Inventory management

I'm writing this one on the fly so it may not be all tidy and organized.

You would think that there should be a tie between your inventory object and what you click on to get it. This is natural, because we think of it as one item. However, the way I managed inventory (and a number of other things) in Sonia was that there is only a coding tie between the thing you click to pick up, and the item in your inventory. I don't know if there's another better way to do it.

At the beginning of the game, all inventory objects (and I use that term tightly) exist in your inventory, you simply can't see them. Naturally, if you can't see them you can't use them. Clicking on the pickup item makes the inventory version of it visible
itemname._visible = true ;

and makes the pickup version invisible (so you cannot pick it up again).

I did it this way because the pickup version usually looks different from the inventory version. It might be barely visible, it might be distorted (like the mirror lying on the table).

You have several functions defining how your inventory items operate. Each item is defined as draggable with:
itemname.onPress = function() {
startDrag(itemname, true, 10, 10, 590, 480);
};

The 10, 10, 590, 480 define the bounds of where you can drag the item. I made this 10 pixels smaller than the size of the gameplay area so that the item cannot be dragged so far to the edge that it may be lost.

Next you have to define how the item behaves when it hits the target area (a button named "targetbutton" in this example.) You actually need to do this twice, once for the onRelease and once for onReleaseOutside methods.
itemname.onRelease = function() {
this.stopDrag();
didhit = checkTarget(this, targetbutton, 93, 477);
if (didhit == true) {
// reset a global variable perhaps? this indicates the room is now unlocked
_global.roomlocked = false;
// play a sound called soundname
soundname.start();
// say something to the player in the dialog box called dialogboxname
_root.dialogboxname.text = "You did something to something else successfully.";
// grey out the item and make it unmovable
itemname._alpha = 50;
// redefine its onPress method as essentially doing nothing
itemname.onPress = function() {
this.stopDrag();
};
}
};


And lastly, the checktarget function

function checkTarget(drag, target, putback_xpos, putback_ypos) {
if (drag.hitTest(target)) {
// put it back in its location in inventory
drag._x = putback_xpos;
drag._y = putback_ypos;
return true;
} else {
// put it back in its location in inventory
drag._x = putback_xpos;
drag._y = putback_ypos;
return false;
}
}

Friday, January 12, 2007

Flash PnC tutorial - 1. Frames and layers

I knew very little about Flash when I started writing Revenge for Sonia. I still know very little, but what I’ve learned might be useful to someone so I’m gonna write it up.

Frames and layers

In PnCs, a frame is usually going to be either an individual scene or a fixed portion of the play screen. A frame can exist for the length of one frame, or it can be stretched across several frames. I know this is a little confusing, but this is what layers are for.

When I started doing this, I could find no instructions on what layers are for, apart from the obvious fact that items in a higher layer are going to be displayed on top of items in a lower layer. Maybe I didn’t know what keywords to look for. But organizationally speaking, it took me several restarts before figuring out a schema that made sense.

In a PnC you have inventory, places to go, things to do, and people to see. These are the four essential layers: inventory, backgrounds, actions,and dialog. Yeah, I'm pushing the analogy a bit, but what the hell.

Let’s try to make some sense of what frames and layers are.

In the above figure, Inventory is layer with a single frame that starts in frame 2 and stretches across most of the entire length of the game. In other words, it exists in every scene but the first and the last. It is a layer by itself and is essentially one frame with a lifespan, so to speak, of 34 frames. Code associated with the inventory objects (manipulating them, their descriptions, etc) is also stored in that layer.

The dialog layer has two frames, one starting at 1 and the second starting at 11. This layer contains my dialog box (the smaller blue box below), where the game gives messages to the player, e.g. “You are now in the living room.” The first frame, spanning 1 through 10, is/are my introduction scenes; 11 – 36 are the actual game. The only difference between the dialog boxes is a slight change in size. The introduction scenes are more wordy, and I needed room for the Next/Skip buttons to the right of the box.

The game part has less text, so the box is not as tall, and text looks better balanced with even margins, so the textbox is stretched.

A frame with a clear dot means the frame has no objects (pictures, buttons, movie clips, etc). It turns black when you put one of these items in it. The alpha symbol indicates there is Actionscript code in that frame. Sonia has 36 frames and 11 layers.

I separated the backdrop pictures (‘background’ layer) from the buttons and movie clips that do stuff (‘actions’ layer). These backdrop frames have essentially no code. Most of the code is in the actions layer.

Looking at the layers list again, I see that ‘bgloop’ could probably have been consolidated with the ‘dialog’ layer, since their lifespans, so to speak, are identical. Bgloop was where I kept the background music loop and the sound on/off button. More keyframes make your Flash file fatter, so you want to reduce those when possible -- but this also has to be balanced with your organizational sanity.

Each keyframe can contain code (Actionscript), which executes upon entry into that frame. A lot of different things can be happening, which is why organization into layers helps keep your sanity. A keyframe automatically has a number, but it can be named as well. The red flags in frames 11-36 in the background layer indicate the frame has a name. This is essential for controlling navigation from one scene to the next. You can have your navigation buttons refer to frame numbers, but if things are still open and loose and you insert a frame, well, your navigation is now fucked because, unlike inserting cells in Excel, the code will not automatically adjust numbers to compensate for the new frame. If you name your frame and your nav buttons refer to those names, they will always find the desired frame.

When you tell Flash to go to a frame (whether numbered or named), all the layers that also have a keyframe in that frame are executed. For example, frame #15 has a keyframe in the Actions layer and a keyframe in the Background layer. If you execute GotoandPlay (15), all the instructions in those two layers get executed. Instructions in the Inventory, Dialog, and Bgloop layers were executed earlier and are being held in memory; they will not be reloaded, but functions defined there are active and can be called by objects in frame 15.

Flash PnC tutorial - 2. Dealing with keyframes

When you add frames and keyframes, some mild care needs to be taken with how you go about it. Right-clicking a frame gives you the choice to insert, or convert.

It’s always safer to convert. If you already have several layers in the timeline and you insert a frame, that will shove all later frames in that layer down a space. This does not automatically insert frames in other layers for you, however, so mismatches can result.

Working with keyframes was not initially natural and obvious to me. Let’s say you start with a keyframe lasting 35 frames, and this keyframe contains an object. If you convert frame 10 to a keyframe, (splitting the timeline into 2 pieces) that object is still there in both keyframes. However, they are now essentially two different objects. If named before the split, both objects will have the same name. If you change the size of one, the other will stay the original size.

However, if you converted frame 36 (initially empty) to a keyframe, it is empty. Your object isn’t there. If you converted from 10 to a blank keyframe, it would be empty.

One last thing about keyframes: You stop an object’s existence by converting to a blank keyframe the first frame after the object is supposed to die. For example, your object lives for frames 10 through 12. Frame 13 must be made into a blank keyframe.

Flash PnC tutorial - 3. Objects

You have button objects, movie clip objects and graphic objects. Buttons have a simpler set of behaviors than movie clips, which can span multiple frames. An example of a button is what you click to move from room a to room b. An example of a movie clip is a button that will not only take you from room a to b when you click on it, but has an arrow that wiggles in the room-a-to-b direction. A button can swap colors when you mouse over it, but it cannot (afaik) change size, move, or change colors subtly/gradually.

Graphic objects just don’t seem to be used all that much. Button objects are more functional, and movie clip objects are the most functional.

Button and movie clip objects can be given behaviors in two different ways.

The first way I’d call internal. I’m sure there’s an official term for it, but I call it internal reference. When you place the button on the frame, and select it, in the Actions (i.e. Actionscript) panel you’ll have a place to put code. You’re putting the code in the button itself, and the way you control its click action looks like
On (release) {
Do stuff
}


The second way is external. The code is placed in the frame that contains the button. (i.e. select the frame in the timeline, then look in the Actions panel). In order to reference the button and give it instructions, the button has to be named (done in the Properties panel). In this situation, your code would look like
Buttonname.onRelease = function () {
Do stuff
}


There are advantages and disadvantages to both. For a simple navigation button that gets you from point A to point B, I tend to use the internal form of coding. You don’t need to bother with naming the button. But with more complex instructions, the external form is better.

Flash PnC tutorial – 4. Instantiation

Generally, the point behind objects is to create items that have specific behaviors that can be re-used over and over. For example, inventory objects share common behaviors, such as dragging and dropping them on things. What I haven’t figured out yet in my very brief acquaintance with Flash is how to create a library of behaviors not tied to a specific picture. A typical PnC inventory will be between 6 and 20 diverse objects, i.e. knife, hammer, screwdriver, teddy bear, unopened magical box, lighter, any number of keys, papers with codes, mysterious object of unknown purpose, etc. In other words, although they share the drag/drop behavior and will probably grey-out when they’ve been used, they all have different graphic images. And the object library seems to start with the graphic, rather than the behavior.

I’ll address that when I figure it out. Anyway….

The only place where I’ve found the library particularly useful is in making buttons. The general way of making a button is to draw a borderless box (or circle) of appropriate proportions, select it and press F8. Name it as desired, convert it to a button with the registration mark in the center, then go to Properties and set the alpha to zero. Instant button.

This results in two things in your library. A graphic of the box you just drew, and a button object. They are irrevocably tied to each other. If you delete the picture, the box will disappear from your button object. Bizarre but true.

If you go about happily drawing separate boxes and converting them for every single button in your game, your object library will quickly become overwhelmed with a huge number of boxes, both graphic and object.

Don’t do this. Create one button object for your library, and whenever you need a button, drag and drop it from the library and resize it. Leaving you with a grand total of one object and one graphic in your library. Much more tidy and obviously a much smaller library size. These dropped versions are instances, and each instance can have its own name, its own code and size/shape.

Flash PnC tutorial – 5. layout and common commands

Overview: a PnC adventure game has typically four or five segments:
- Preloader. The preloader ensures the entire game is loaded into memory before it begins, and displays the load progress to the player. They usually consist of two frames and three layers, they can be simple or fancy, and many can be downloaded as freeware from sites such as flashkit.com.
- Introductory scenes may include some animation, sets the storyline, and may have a help screen to explain how to navigate and so on.
- Help screen (could be part of the intro, but depending on your game, you may want it accessible from any point during gameplay)
- Game: rooms/walls, puzzles, scenery, cutscenes, etc.
- Ending scene(s) and credits.

It is definitely better for your sanity to place (most) all your scenes and name your frames first before setting up any navigation buttons or other action. It may behoove you to write a list of backdrops, the frame number, and what you named the frame. There’s so much stuff on the Flash 8 screen that there is not enough room to display everything at once unless you have enormous screen real estate. I found myself constantly switching between Actions and Properties, and scrolling the Layers window up and down, and scrolling the Actions up and down. It’s really pretty annoying and I wish Actions and Properties could be moveable windows, rather than being glued in place below the picture.

Commonly used commands

Important note: Flash is case sensitive. If you name an object ObjectName, this is different from objectname and objectName. Be really careful to stay consistent. This applies to commands as well, and Flash commands have a very annoying casing scheme. onRelease is a fish halfway out of the water. Fortunately the action panel's + and target icons will insert the correct command or object name.

Flash is more often employed as a way of making movies and animations. Normally frames flow. With a PnC, however, the action is stopping at pretty much every single frame (aka room). So the Actionscript for pretty much every frame in your Actions layer is going to end with
stop();

The navigation button moves you from one frame to another, whether left, right, up, down. Its code is usually
On (release) {
gotoandPlay(“SomeOtherFrame”) ;
}

or if being coded externally,
navbuttonname.onRelease = function () {
gotoandPlay(“SomeOtherFrame”) ;
}


Displaying text in your dialog box is always done externally (you did set its type as “dynamic text” in Properties, didn’t you?) In the Actionscript for a button, code as follows:
on (release) {
_root.DialogBoxName.text = “You are now in some other room.” ;
}


or in the frame’s Actionscript:
objectname.onRelease = function () {
_root.DialogBoxName.text = “This is a box of unknown function.” ;
}

Wednesday, January 10, 2007

disconnect

OK I have worked for this place since 1989. That's kind of scary to think almost eighteen years, but what the hell, the job is comfortable and the pay is decent. But the relationship between the bosses and the bees has been slowly deteriorating and I don't think I like it here anymore.

When I started working here, R was the top guy. He was a damn good boss in that he would talk to the bees spontaneously and easily, and he was good for spirit. He'd let us off early on the workday before major holidays. With him we had yearly picnics and such little staff parties. You felt like someone cared about you.

Around 2000 the union got up and made some trouble. Certain board members who were very anti-administration got elected. These two factions made it impossible for R to continue, so he took retirement, and nearly all the administrators (7 out of 8 people) left because R had been protecting them from the union and the board. In short, we got shook down.

So all us bees in the administration office got new bosses and we got a new top dog, P. P has a friendly smile and sounds nice, but she is not kind nor does she ever go out of her way to make you feel valued. She doesn't let us off early before the holiday. We don't have picnics. The last few years have been grim. It doesn't take much to make bees happy, but meanness and pettiness have taken hold, and they deny us these small things. P hands out little soap bars to everyone as a Christmas gift. A boss should either give nothing, as R did, or give something decent, not some worthless piece of shit that costs less than a dollar.

Over Christmas we moved into our new office building. Previously, we'd been renting space, at a fairly high price, and last year finally got the money to buy. It's a nice building, and my cubie space has grown larger and is close to a window. That's nice. But for some reason that I cannot comprehend, bees don't get keys to the building.

If we want to come in on the weekend or evening, we have to check out a key and alarm card from our bosses. We can't just drop by the office when we feel like it. It's like the place is not ours. The policy is worker-hostile and this makes me sad, disappointed enough that I'm considering leaving. It seems like a very small thing but really, it's just the most recent of these small slaps that make work unpleasant.

Tuesday, January 09, 2007

my 3 hours of fame :)

Well, my game (here in its new public home on Dazed's server) kept my friends on Nordinho busy for a little over 3 hours before they solved it. I don't know if that's a compliment to them, to me, or both. I think it's about average, as this kind of game goes. It was fun and completely bug-free as far as I could tell. I panicked twice -- once when someone said their bottles disappeared, and when people seemed to be having trouble solving the safe. The disappearing bottles turned out to be a slow computer. I dashed into Flash 8 Pro to verify that the number codes I'd set up matched the puzzle symbols.

On the first one I fumbled -- the code is mirrored, and I drew one symbol backwards, which is visually forwards, but backwards by coding -- but I held off the urge to post long enough to check the other four. They were okay, I went back to the first and re-checked it, and swashed the beads of sweat off... funny how I want this little game to be totally perfect...

Sunday, January 07, 2007

of course no

jackpots. Not even a random win to cover my ten bucks. Oh well.

Victories are usually made, not bestowed by luck or chance. I've just written my first (and possibly last) Flash game, a point and click adventure with some puzzles, temporarily housed here until I find a home with better bandwidth.

I was really surprised how quickly I picked up Actionscript -- exactly 10 days from start to finish: installing the Flash trial, and getting to beta. And it's not really beta but rather logically and logistically complete, with only literal bells and whistles needing to be added. Then again, I'm a SQL (and a pinch of PHP) programmer -- I swim in similar waters all the time.

Tuesday, January 02, 2007

the kind of omen we like

For portentous beginning-of-year dreams, I like the one I had last night: I won $15 million in the lottery.

Several years ago I got a phone call from a radio station. The deal was, listen to their station at a specific time every day, when they would pick a name from the hat to win a thousand dollars and a radio station tour. Seemed even more of a no-brainer when they said I could choose the time I would be listening. I set my alarm clock for about 1 minute before readoff time. For several weeks I listened, never anxious or wondering when the game would be over. When they called my name I was completely unsurprised. The mate and I looked at each other, shrugged and smiled. There was something so completely zen-like about it, like we knew it was gonna happen.

So I went out and bought some lottery tickets. Tomorrow night, we'll see if I knew it was gonna happen :)

Monday, January 01, 2007

happy new ear

Apparently the Japanese consider it auspicious if you dream of Mt Fuji, eagles, or eggplants on the night of the new year. I dreamed I was watching a music video of Donald Rumsfeld rocking out in front of a jeep. He wore a Saddam Hussein mustache. Frankly, I wouldn't count that hawk among the auspicious variety.

I'm kidding. I have no idea what I dreamed.

The Chinese consider what happens on the first day of the year to be indicative of the rest of it. They particularly enjoy gambling then. Even a little win is probably a good thing. Like all omens, it's a very subjective thing.

Today is beautiful, sunny and cold, I haven't smoked for a month and have no desire to do so. That's a good start (although 2 weeks from now I'll be running a memorial for my friend, where I might smoke one just for old times' sake. Might.) And I just discovered the white ginger plants I smuggled from Hawaii two years ago are growing flower buds. That's really nice. The mate is feeling better today, and though there is still one more test scheduled (February was the earliest we could get), feeling better is a definite indicator that the antibiotics are working for the moment. Finally, I'm having fun writing my first (and probably only) Flash game.

If today indicates the rest of my year, I can't complain.