After spending a little time with Eclipse and going deeper into libGDX, and going through one of the libGDX tutorials, namely this oneĀ https://code.google.com/p/libgdx/wiki/SimpleApp#Project_Setup. I decided to try and expand a bit on it.

“Drop” which is the name of the game you create in that short tutorial, taught me a few things, but I realized that I would have to stop and go back a bit when I wanted to extend on the Rectangle class in libGDX. Let me try and explain my reasons for wanting to extend that class.
If you follow the code precisely you end up with a small game, where you move a bucket in the bottom of the screen around, to catch drops falling at random spots from the top of the screen (Zen indeed). Now all these drops that are falling, fall with the same speed, so I wanted to randomize the speed of the drops, to add a little variation to the game, merely for learning purposes.

This is the section of the code that spawns the raindrops

1
2
3
4
5
6
7
8
9
private void spawnRaindrop() {
    Rectangle raindrop = new Rectangle();
    raindrop.x = MathUtils.random(0, 800-48);
    raindrop.y = 480;
    raindrop.width = 48;
    raindrop.height = 48;
    raindrops.add(raindrop);
    lastDropTime = TimeUtils.nanoTime();
}
private void spawnRaindrop() {
    Rectangle raindrop = new Rectangle();
    raindrop.x = MathUtils.random(0, 800-48);
    raindrop.y = 480;
    raindrop.width = 48;
    raindrop.height = 48;
    raindrops.add(raindrop);
    lastDropTime = TimeUtils.nanoTime();
}

 

Now I wanted to add a little more to it

1
 raindrop.speed = MathUtils.random(50, 200);
 raindrop.speed = MathUtils.random(50, 200);

 

However to do this I needed to extend the Rectangle class, which with my knowledge of Java was not possible.
So the only way for me to go for now, is to read up a bit more about the basics of Java, and take it slower. For this I’ve allied myself with a book called “Head First Java”, which so far seems like a very good read. Also, Mario’s Beginning Android Games, but that will probably be used on a later time, since I first need to take a few steps back.

 

It looks like the score for now is.

Drop 1
Me 0

But the battle is not over yet!