What project is complete without its own share of tedious refactoring? Today I realized a few follies in my code design, and shifted some logic around. For one, sprites (sprites==entities=='things') are now created from a set of 'sprite templates', rather than generated from a hard-coded list every time one is created. This set contains things like: the player, enemies, fruit, and doors. The 'Sprites.txt' file in my Data\ folder resembles:
The first field is the ID of the sprite template (zero being a non-template, generic sprite), and the next two are the width/height of each frame in the animation. The last being both the sprite's name and filename; coincidentally paying homage to Java's equally restricting naming style. :P
I also formed an AddList and DeadList, for adding and removing sprites from the game. Since I can't directly modify a list while I'm in a foreach() loop, I toss to-be-destroyed and to-be-added sprites in their respective lists, and they get added in the next iteration of the game loop. Is this elegant enough? I'm no optimzation buff. Feedback is good. :)
I added the (arguably) most basic foe there is: The Bounder! This little fellow jumps up and down in whatever direction it's facing, and reverses directions upon hitting a wall. These squirts come in three flavours: green (jumps a medium amount and moves at a medium speed), blue (jumps really far at a fast speed), and red (jumps really high very frequently). I figured I'd take the multiple enemies per-AI approach, since time is in low supply. Not only is it easier, but it still looks pretty cool! Here's a shot from the map editor whilst making my little test-map:
(The editor's viewport is 50% the actual game screen, for ease of use)
Points! (and HUD)
I implemented the "points" system today, which is essentially a trivial accumulation of values by collecting fruit sprites and other tasks. As trivial as it might seem, when I grab an apple and I see some flashing numbers appear and fade up into the air...well, it just feels good!
Also shown here is the HUD/status-bar, which currently shows points (functional), lives (non-functional), and tomato(e)s left (non-functional) in a cool semi-graphical fashion.
Overall I'm very pleased with how the game is coming together. Granted I only have one week left until I need to finish it -- so stress is a factor -- but I'm surprised how easy it's been to toss together a game in C# -- a language I've never made a game with before -- and SDL.NET -- a library I've never used before. The other cool thing is that there's been zero speed issues. The game runs wonderfully, and I haven't even optimized that much of the drawing!
An Extra Gloat
Oh, and I apparently have won two awards at my highschool. The "Computer Science Award" which is "based on your outstanding achievement in Computer Science". And, to which I feel particularly humbled: the "Eric Knabe Memorial Award" which honours my late CS teacher, and was given for my advocating of technology and helping others, to be presented by his wife. Mr. Knabe was an awesome teacher who taught CS at my highschool for many years, and helped form me become the programmer I am today. I feel very flattered for receiving both. :)