Gnibbles
For most of the past week, I have been working intensively on a Java program -- more specifically, a clone of Gnibbles (a snake game officially known as GNOME Nibbles).
I'm not close to being finished yet, but the game is basically functional. Here is a screenshot with two players (at the moment there can be up to four):
The green triangle is a "frog", which is eaten to gain points (and to grow longer). The dark grey triangle is a bonus, which currently has the same effect as the frog when eaten, but which will in later versions come in various colours and shapes, and have more interesting effects (like gaining a life, temporarily slowing down, getting shorter, teleporting, shedding skin, and so on).
The right part of the screen shows the players' scores and how many lives they have left (each life being represented by a circle). At the moment, the only serious bug is that the players' lives don't update properly. Well, behind the scenes they do, but the number of circles displayed on the screen is always the same.
The main gap in functionality is that there are no impermeable walls. In fact, there aren't really any walls at all. The outer boundaries only serve as teleporters to keep the snakes in the playing field. When, for example, the head of a snake goes past the right boundary, it pops up at the left boundary (i.e. the playing field wraps around).
In the Game menu, when one clicks on "Options", the following window pops up:
At the moment, there is only one level, so the level-related options have no effect. Everything else works, though; it is possible to adjust the number of players, the players' colours, the keys used to move around, and the speed. Other settings (maximum number of players, possible speeds, initial positions, and so on) can be changed with more or less ease by changing the code.
Anyway, speaking of the keys used to move around, they can be changed by clicking on the "Controls" button beside each player's colour in the "Options" window. The following window pops up:
As you can see, there are four squares at the top, each representing a direction of movement. The selected direction is highlighted. One presses the desired key for that direction, then selects another direction (by clicking on the square or pressing TAB), presses the desired key for that direction, and so on. Some keys, like TAB, ALT, and SPACE, aren't allowed, because they have other functions.
Well, that's the gist of the game. As a programming project, I suppose it's shamefully elementary for an Informatik student about to begin her fifth semester, but I find it fun and worthwhile, and much easier now than it was the first time I attempted to make my own version of Gnibbles (maybe a year or two ago).
For the next while, I'll probably be concentrating on fixing the abovementioned bug, writing Javadoc comments, and increasing the elegance, consistency, and flexibility of what I've already written. The latter two activities (writing comments and refactoring) are actually surprisingly interesting and rewarding, but they do slow the momentum of the project down considerably. It would be unjust to liken refactoring to a bog, because (as I said) it's not unpleasant, but one does risk getting so caught up in tweaking the code that the actual functionality of the program never advances beyond a certain point.
By the way, one last (lengthy) remark: I have been using Eclipse for the project, and have finally begun exploring some of the many handy features. I have really only scratched the surface, but even having things like bookmarks and tasks (and arranging the workspace and views to my taste) makes the experience much pleasanter.
One especially useful feature that I don't make nearly enough use of is the debugger. Somehow I've never properly caught on to debuggers in general, even though they're much better than my usual approach of inserting print commands at select locations in the code. But I hope to change all that (and by "that", I mean doing it the stupid way (o: ).
1 Comments:
I like the computer science jargon that's creeping into your writing, like "tweaking" and "bug" and "functionality." !
Post a Comment
<< Home