Archive for January, 2009
Tower Defense in AS3 – Part IV
Many of you have been waiting patiently for this post, and let me say that I have worked many hours to get this where it is today. I wanted to get my code to the point where it was solid enough that I would actually publish something with it, and I believe it is there. Thanks to those who have encouraged me to finish this post, and I look forward to seeing how it is used!
In introduction, let me say a few things about this post: first, I have tried to alter my scope slightly in order to be more accessible to readers who may not have access to a full licensed copy of Flash. So, to help with that and make these lessons more accessible, I have decided to write them in such a way as to be compiled by the Flex SDK, a fully open source framework to allow anyone to build robust Flash applications. I prefer to use the full Flex Developer 3 for development and release, but even without it, you can compile full AS3 or Flex applications using only the SDK from the command line. One other major benefit to doing my development with Flex Builder is the ability to publish my source code for all to view online as well as download.
Obviously, this opens up the accessibility to a much broader range of individuals looking to learn Actionscript 3 or Flex. So, all this to say that the code in this post, while doing practically the same thing as the previous posts (and keeping the majority of the same logic), cleans up a ton of structural issues to lend itself more cleanly towards a completed project. That being said, we are simply focusing on the Tower object itself this time. I will leave it to your imagination and time to read through the rest of the cleaned – and fully documented, I might add – code. I may find time to write some more generalized posts on the Flex framework itself in days to come, but for now, suffice to say that the main file that is compiled as the application (in our case, called “MagicTD.as”) will be instantiated as the main() function and will serve as our entire platform base. You will notice on line 12 of this file all the variables needed to set up our SWF with the desired dimensions, background color and framerate.
So, without further ado, let’s jump right into our Tower class.
Read more
Linux tips with CVS
Well, we use CVS for our version control at work, and yesterday we had to do something a bit unorthodox that entailed me updating an entire branch back to the trunk (long story). So, in the process, I was responsible for committing literally hundreds of files in our project, and after confirming and reconfirming that I had all the files up to date and modified correctly, I devised a way to “automate” a mass add and commit. In case this helps someone else out there, I thought I would share.
Anyway, if you use CVS to any extent, you are probably aware of how update (up for short) works and the fact that you can use the -n and -q modifiers to keep the actions from actually taking place so you can examine the results before carrying it out. Well, for quite some time now, I have been piping the results through a simple grep command to get me a list of specific files I need to work with. For instance, if I wanted just a list of files that I have created (not yet in CVS) and those I have locally modified in order to know a full list of files I have yet to commit, I would run something like this:
> cvs -nq up -d | grep ^[?M]
Obviously, the question mark is the new file listing and the M is for local modifications. If you have already added files to the repository but not yet committed them, you may also need to add the ‘A’ modifier in there to pull in those files as well (so your regexp for your grep would look like this instead: ^[?MA]).
Read more