Entries in BreakOut (2)

Sunday
Feb202011

Building Skills in Programming and Design

It was a wonderful and intense week for me (in a good way).  Minutes after posting my last note one week ago I decided to change the design of the web-site.  Again…  So, I spent a couple of hours tweaking a completely new template to better suit my needs.  I’ve also added tags cloud, changed appearance of Twitter feed a bit, and… that’s it for now.  :)  It still is in a ‘beta’ stage though, I will definitely change the colors (I liked the previous color scheme better), and the icons, and will pay special attention to the header.  I plan to make a collage of my working environment in Eclipse and have it as the header image.  Basically, that’s my goal for the week ahead in terms of the web-site design.

My programming skills are also improving.  I’ve completed, debugged, and polished ‘BreakOut’ game.  Even though it’s a very simple game, it turned out to be a valuable experience in programming.  I’ve learned how to program mouse and keyboard events, and also how to make many things to happen all at the same time.

This was also a great experience in debugging.  I had three major bugs.  One was that the ball may get stuck inside the puddle, another — the puddle might in some cases disappear when hit by the ball, and the last one (which I got rid of very quickly) — the ball could become invisible if the initial direction of movement was to the left and not to the right.  So, the major problem for me was not to identify the bug, but to actually come up with a fix.  And to my surprise the two bugs I had no clue to fix got worked out relatively fast once I started thinking about possible solutions.  Thus, the first lesson: 

Even if you don’t seem to know how to fix a bug, keep trying, it may be easier to fix than it looks! 

Another game (it’s even less complicated than ‘BreakOut’) I’ve implemented just yesterday is ‘UFO’.  I’ve coded it from scratch in two hours, then eliminated the bugs (which took me roughly another two hours), and implemented an advanced feature:  when the bullet hits the UFO there is a little green alien falling down from it and bouncing away.  :)

I’ve implemented a separate class for the alien named… well, GAlien, which I designed to be a separate class extending GCompound class.  It allowed me to do various things with it in simple and convenient ways.  By the way, this is how the alien looks like:      and here's the code for the GAlien class:


Next week I’ll continue my study by reviewing the lectures, reading on the book, doing the exercises.  I hope to complete the course by mid March and start with the next one immediately!  And now back to work, blog-time is over!  :)

Sunday
Feb132011

Intermediate steps

So, this week was a much more productive than the last one.  I've successfully recovered from sickness and my close relative is doing perfectly fine as well.

There were significant steps made in understanding how the object-oriented programming works.  I finally got solid answer what is a class, what is an object, what are instance variables, and so on.  In fact, there was a major break-through in the study, so if it was lack of understanding which held me back in the past, now it is the technical 'bricks-and-pieces' of the Java language (which I hope to learn quickly).

I am at 70+ programs in my practice programming, and from now on I am going to stop counting such exercises as full-fledged programs.  And from such point of view I've made only 2 programs so far:  the game of 'Craps!' and the BreakOut.

'Craps!' is a console game (which means not XBox or PS3, but rather that everything is displayed in textual form in a console window), and based completely on random numbers generator.  Player has literally nothing to do, but to hit a key and watch the results of virtual dice rolling.

BreakOut is much more entertaining.  This is classics!  I've implemented a very basic gameplay:  one paddle, one ball, a wall of bricks at the top, and the score system.  When the player clicks, the ball starts traveling around the screen, hitting walls and bricks.  The speed of the ball doesn't change, the collision system is primitive, no sound, everything on the screen represented through basic shapes of various colors.  There is also only one level, and only one try to complete it.  At the end there is a message (congratulations or game over).

Now, it took me about 4-5 hours to complete the program (I took breaks of course throughout the day), but still I find it to be somewhat messy and buggy.  For example, at some unknown conditions the ball may become invisible right at the beginning of the game!  Or it may get 'stuck' in the puddle, and then descend down to the bottom of the screen in a weird way.  I've also witnessed a very rare bug when puddle hit by the ball... disappeared!

The program doesn't implement classes (except for the build-in GObjects).  So, my second try on BreakOut will be a completely different approach, but that's in the future...