(no subject)

Apr 05, 2010 01:16

I came home last Monday. Mum decided she was too exhausted to drive me, but offered to pay for my train ticket. This turned out to be a good thing: the ticket-seller at Canley station told me how to save £7 on these journeys in future. I get two tickets, one to Cheltenham spa and the other from there to Bristol (or to Coventry or Canley, in the reverse direction), and it works out cheaper for the exact same route. So yay for that.

Most of my productive time for the past week has been spent on PyWeek. My entry with Alan is Roly-Poly Samurai. You move the mouse to tilt the platforms, making the samurai roll about, and you click to make him jump. The aim is just to get as high as you can, but there's an evil ninja who teleports out of reach every time you get close, which adds a little to the final product.

Things I would like to have added:
* Damsels in distress, who the ninja would try to kill; you would have to save them by getting close and making him teleport away. If you take too long, they die. If too many die, you lose.
* Scrolling background, and a better ninja image.
* Fade in/out effects for the ninja teleporting. Better yet, the ninja jumping instead of teleporting.
* Jump sound effects. (The current voices were taken from a free sound effect website, which is why the ninja's condescending "hah" sounds a little like an inquisitive "hm". This wouldn't easily work for jumping, because I want something in two parts, one for building up power and one for the actual jump.)
* A better algorithm for placing platforms.
* More precision in jump power. As it stands, your jump is fully charged after 1/3 second, which is too fast.

But I think the game is pretty fun even without those, so I consider it a success.

I probably won't be using Python again without good reason. I like the language well enough, apart from some bearable warts, but it's too slow for games programming. The game doesn't run at full speed on my machine even when it's only rendering six sprites and some text.
* Possibly I did something wrong, but not something simple. I noticed the slowdown gradually happening when I was adding more platforms, which rules out a lot of stupid things. And the platform draw/update code is very simmple.
* Possibly it's just a pyglet thing. Batched rendering might have made it faster. But batched rendering would also require calculating rotations manually, and keeping track of considerably more stuff, which at least partially nullifies the advantages of Python over C++. Also it annoys me when I submit a perfectly good bug report and get no response, even a "this is not our fault, take this up with...". (I had a similar experience with clojure, which I think is part of why I no longer use that.)
And synce python is never going to be as fast as C++, and I do not have a fast machine, I'm just going to stick with C++ for game development. And for non-game development, I don't think python is going to fill any niche that perl doesn't for me.

On the theme of programming, I've started the CS coursework. At first I decided I really didn't like JavaCC. When you tell it "find me something that matches this regex", what it does is more like:
* Read something.
* Match it, in turn, against every regex used in your program until it finds one that matches.
* If that isn't the one you asked for, it throws an error, even if the one you asked for would have worked.

(For pedantic clarity's sake: "regex" here refers to JavaCC's brand of regular expressions, which are equivalent in power to the ones commonly used by sed, grep, etc. but with a much more cumbersome syntax. It definitely does not refer to perl's regexes, which are non-regular.)

For me, what this meant was that I couldn't ask for A) "a word without globs" versus B) "a word that might have globs", because either all A's would be returned as B's, or all B's that don't contain globs would be returned as A's. So I was thinking that I'd basically have to read input character-at-a-time, which would be horribly complicated and have lots of hidden bugs.

But then, as I was lying in bed at about 2:30 one morning, I started to think about what was actually going on. Regexes are used in the lexing phase, where JavaCC just blindly reads stuff and converts it into "tokens". When you ask for "something matching this regex", what you mean is "this kind of token". So if a piece of input could be one of multiple tokens, it has to pick one arbitrarily. (And it can't really say "this or that", because it might be "this token or that sequence of tokens", and that quickly blows up in terms of memory and CPU time.) The key point is that lexing is done with no context: you can't make a token be one thing or another depending on the preceeding tokens.

Now that I understand why regexes act like they do, their shortcomings are a lot less annoying. I also realised that I was trying to make the lexer do too much. I should just break everything into "words", and later check whether they have globs or not (and reject if necessary).

I haven't started to implement this approach yet, but I think it's going to make everything much more pleasant. I don't expect to like it nearly as much as Haskell's Parsec, but I do expect to not finish the project wondering why anyone would ever choose to use JavaCC.

There's been precisely one reply to my forum thread asking for clarifications, and that was another student saying he wanted some as well. That's annoying.

From an email that the Bristol airsoft site sent me:
1st April 2010

A team of 15 models are coming down to play against Bristol Airsoft.

These girls may need some help being shown what to do as they haven't played Airsoft before. So if you think you can help then please come down.

Accompanied by an image of a well-oiled girl in halter top and short shorts with a revolver.

Basically this reads to me like, "you're a bunch of horny adolescents who are incapable of attracting girls, so we've paid some for you to fawn over." (Much like GameCrush.) It seems pretty disrespectful, and it's made me less inclined to go back.

(On the other hand, I don't have a problem with the next line: "There will be a cash prize on the night of £100 and a fully paid for night out with one of the models!" But I don't understand how this event can possibly make money, unless they fit far more people on-site than I can imagine would be fun. Or charge an extortionate entry fee, which I can also believe because it wasn't specified in the email.)

I'm working tomorrow, and probably next week, which is good. I'll get about £40-50 for it, I guess. I don't yet know exactly when I'm going back to Coventry, but it won't be long after that.
Previous post Next post
Up