Monthly Archives: January 2010

Self-Training in Sprite Animation

With UFOs and the floating head of Nefarious no less!

Last night and tonight I put together another graphics test program, this one intended to investigate methods of doing shaped sprite animations, as well as scrolling endless backgrounds, collision detection, and on the fly modifications of the sprite and layer bitmaps. I think it turned out pretty nicely so I’m posting it as a tutorial-minded application that includes all the source code and source images that I used.

Due to a great many embedded graphics that I haven’t bothered to optimize or compress — mostly a nice picture of Costa Rican — this exe is uncharacteristically large at about a meg and a half. You cand download the executable (which contains everything you need to try this) here: ZenSpriteTest.exe

You can also download the fully-commented source code here: ZenSpriteTest.bas and ZenSpriteTest.rc

You can also download the images and icon here (these really explain instantly how the shaped sprites are composited): ZenSpriteTest-images.rar

Feel free to check out the YouTube video I made of the program running… As always, the capture process has caused some degredation in quality and framerate. Anyway, I had fun putting this together and it was much easier than I’d thought it would be. On Monday I’m going to quickly write a more complex collision detection function, and also maybe do a little OpenGL work before I dive into coding the “PUNG” video game with Saira. BTW, feel free to open the video in its own window instead.

Simple Graphics Scratchpad Miscellanea

My friend Saira called me up and after hearing that I was programming at the time, eagerly asked me, “Hey are you still willing to program a game if I design it? Because I have an idea now.”

“Ok, what is it?”

“It’s called PUNG! Isn’t that great?”

“Um, I guess so… let me know when you have more than a great title, ok?”

So anyway, for all I know it’s already sitting in my in-box, but while I’m waiting for the specs to “Pung” from Saira, I made a little graphics scratch-pad that does a variety of things that I may need to do variants on in a game. Bouncing balls, collision detection, fractal landscapes, screen capture and bitmap manipulation, fireworks, snow, starfields, emittors, and other particle systems, gravity, 3D animation, and so on… Nefarious actually had a lot of fun fiddling with it before school this morning.

If you want to download it, you can, although it does nothing useful, and I haven’t optimized or tested it in any way so it won’t surprise me at all if it is terrible slow on some computers (or perhaps the opposite), or even crashes. To use it, just run the executable, select a drawing mode, and, usually, move the mouse around to change settings and click in the graphics window to reset, initialize, and/or randomize: zengraphicstest.exe (39k)

Here it is running through its modes (in reality the framerate is much better than in this YouTube video — it’s the capture process that slowed it down)…

Avatar at Age Six = Best Movie Ever

Caitlin is off at quilting school tonight, while Nefarious and I went straight from Montessori school to the theatre where we saw Avatar in digital 3D (not IMAX), the third time I’ve seen it — still enjoying it just as much — and the first for her. She’s been independently asking to see it, which at first I thought was because of classmates, but it turns out none of them have seen it so I think she was basing the desire on Caitlin’s and my conversations about the film. I wasn’t sure if it was going to be too much for her at nearly three hours, but the story is simple and idealistic like a fairy tale, and there’s extremely little profanity, no sexual content, and no inappropriate or gratuitous violence, so I figured it couldn’t hurt.

I was very happy that she was glued to the screen and its rich and creative visuals — surprised at the end of the movie at the length, saying it had seemed so short — and as we walked out of the exit she loudly and excitedly proclaimed, “this is the best movie I’ve ever seen in my entire life!” (which is saying a lot, due to the lack of stereotypical Disney characters) and we talked about it in detail all the way home. It made it easy for me to explain my forehead tattoo to her in some more detail, because the movie discusses the same idea… in short, that we are all connected.

On that subject of Avatar, I was interested to hear from Caitlin that some of her boardmembers at the Atheist Nexus were complaining that the movie was too “religious”, I suppose makiung the shallow assumption that it’s some sort of primitive animist faith. This misses the point entirely, because the thing about the Na’vi, to me, is that they’re essentially atheists. Their “god” character is not some illusory figure — it’s an actual emergent super-entity that they are all a part of due to the biologically networked nature of the planet’s lifeforms. A real “deity”, not a supernatural one. I passionately hope that it turns out that something similar exists in reality, some sort of macro-consciousness that is superimposed on us.

That would be a god I could understand.

silly-face

A silly face as always, helped by the 3D glasses…

Keeping Busy

I admit that there are days — days as rare as I can keep them — that we don’t do much. If I’m not feeling my best, sometimes all I want to do is sit on the couch. And really, I don’t even want to do that, it’s just that I don’t want to do anything and that’s the minimum level of activity that’s open to me. But from a parenting point of view, this should be treated as a worst-possible scenario. Not just for your child’s sake (even if they jump at the possibility of TV hypnosis), but for your own — if you can summon up that minimum amount of energy to do something and do it with some small amount of cheer, it’s so much easier. This morning, even through a full dose of strong painkillers, my legs were throbbing badly as if I had taken nothing — serves me right for having a skipping and hopping game (“Daddy, I can be your skipping teacher”) with Nefarious before school — and I was worried that the day would be couch-ridden. I admit that for much of the day it was. I’m blessed with the ability to sleep through all but the sharpest breakthrough pain, and this exhaustion seems often to be my body’s response to discomfort as well (although strangely more so during the day than at night), and it really was wonderful to slip away into slumber and build up the strength I knew I’d have to — I’d want to — muster come 3:30PM.

Because it was band practice day, Nefarious and I filled the bathtub (thank you to Leila for having installed a big one) with blankets and pillows, closed the doors to make it the quietest room in the house, and read Harry Potter and the Goblet of Fire (Caitlin poked her head in and snapped this photo of us reading). The last few chapters have been great, with the appearance of the Death Eaters, and now Mad-Eye Moody and the announcement of the Tri-Wizard Tournament.

bathtub-reading

At school they’re reading the Narnia series in class — she’s reading it in grade one, whereas I think I read it in grade seven, although I’m not sure — so she’s being thoroughly immersed in fantasy literature. I’ve been thinking of trying to find a good sci-fi for us next, but I’m not sure what would be good, and I don’t want to stumble across age-inappropriate scenes, so if anyone wants to suggest anything… She can handle complex stories, but I want to avoid sexual content and profanity and so on.

After school we usually play games for a while. I prefer games of skill like chess or memory or even connect-four, but someone gave us Quirkle for Christmas, a dominoes sort of game, and Nefarious totally loves it. There’s more of a random element than I like (you pull your tiles out of a bag and hope for combos of either color or shape — in some ways it’s a lot like the card game gin rummy), but it’s an enjoyable game of a predictable duration (which is good if you’re wanting to plan it into a schedule). Today as we played it we watched a documentary about a family of tigers after a small amount of howling that I wouldn’t let her watch TV like her mom does (which for all I know is the exact same line that she uses in reverse when she’s there).

playing-quirkle

Oh, and if you play Quirkle, we made a minor rule adjustment that improves the game play — if you play all your tiles at once (including your final move in the game), you get double the points. It’s a simple change, but it forces a little more strategy and emotionally makes it more stressful as you desperately hope for the piece you’re needing to make a set when you reach into the bag of tiles.

We did a little painting as well. Caitlin got us a new shower curtain last week so the old one has been laid out on the studio floor as a drop cloth. Nefarious and I are splitting the work on the two paintings, building them up layer by layer, probably in flat colors rather than complex fades or such things. I’m forcing her to take it seriously though, so it’s as much a “lesson” as it is for fun.

sky-painting

Speaking of lessons, on school days, now that Nefarious doesn’t have a room that has a sunset window (at our old place the sunrise woke her quite early) — to say nothing of the later winter sunrise — she is usually still asleep when my alarm goes off. Instead of just normally waking her, I’ve been going up to her room and playing the piano to gently rouse her. I’m not a very good piano player, but I play well enough to help get eyes open both on the day and on creating music herself. Tomorrow should be a great day for her, because the gymnastics class that Caitlin got her set up in starts and she’s been very excited.

Sense, and sense of awe

This morning I watched a BBC documentary that included an interview with an astronaut about gravity, and the lack thereof while she was working in orbit. She was talking about how in space, everything floats, and after a couple of days you’re begging for gravity again, begging for something to just stay where you put it and not float away… But then when you come back to Earth all of a sudden you’re so heavy and so aware of being pulled down toward the Earth, and how horrible this is and how she instantly wonders why she ever wished to have gravity back. That’s a little what losing muscle strength is like for me — a hyerawareness of my own weight, because even holding my body up and doing the simplest activities takes conscious effort and is as painful as if I was at the gym at the end of a strenuous weight training session. The documentary by the way — “The Man Who Lost His Body” — was about a guy who lost all feeling in his body, including the “sixth sense” that tells you where all your limbs are located, so he had to retrain his mind’s eye, and is actually the only man with this condition to ever relearn how to walk, through incredible conscious effort and visualization.

Speaking of both consciousness and the innate sense of self, yesterday I was thinking — as I often do — about how amazing it is that we are a collection of space dust that somehow congealed into organic molecules, self-replicating chemistry and life, became more and more complex, and eventually gained a soul — because what is a soul but the act of wondering whether one has a soul — that contemplates the space dust from whence it came. How amazing is that? How lucky is my particular collection of particles to be this-conscious-me? Although I suppose, I didn’t have a choice. After all, as I’m always telling Nefarious, I’m not 36 year old, I’m 13.73 billion years old, but I’ve only been awake for the last 36, so I don’t have a very good memory of when I was younger… Well, at least the pieces that I’m made of are 13.73 billion years old. So it all depends on what the word “I” means at that moment. But in the absence of passing religious faith on to Nefarious, I want to share with her the same sense of awe and wonder that I feel about our beautiful physical universe. I feel like this reality, and our connection and important part in this reality is so much more amazing that any “God” myth primitive humans have invented.

Which reminds me, last year I posted about the Symphony of Science videos that auto-tune Carl Sagan and others into music that talks about those very feelings. Since I made that post, two more videos have been added to that series. Here they are, “Our Place in the Cosmos” and “The Unbroken Thread”.