Friday, February 28, 2014

GreenCrab

So my neighbor Tiff asked for some programming advise from me last night, she showed me what they were doing at school.  They were task to create a Java Game using Greenfoot, I believe she's in high school, I think.

So she told me of their idea and everything they wanted to do, I said it was complicated since they have two days left and everything won't fit.  I simply advised that their group should keep it simple so as they can deliver on time.  Enough of the complex GUI and stuff, more of focus on what they can deliver quickly.

Poor old me because I knew nothing about Greenfoot.  Since it has an API, I guessed it was easy.  So I dwelt on it the next day since I was curious on how it's implemented.  Is it complicated or is it easy.  I tried to copy the infamous Flappy Bird game but rather than using the same images I used a different theme.  I don't want nintendo breathing down my neck, hahahahahaha.

So after a couple of hours I managed to program a game where you control a crab that is whisking through layers of rocks.  Same with the bird game, gravity does pull him down and the only control is to push on the "A" key for it to climb up.  I randomly had these rock formation come to the crab like pipes for the bird.  I simply counted the layers the crab passes through and displayed the score on the upper left of the screen.

Like the original game any contact with a rock or the top and bottom walls would end the game.  So here are some screen shots of the game.  I'll try and give this to my SQA team tomorrow for testing.  :)

There are still a lot more functions that are not yet present; such as sounds, high score and what not.  I was rushing the thing since it's already late.  I believe I won't go back to this project right away so I guess this would be the end product (for now).

I'm running the application using the Greenfoot tool
Here's the crab being pulled down by gravity along with the layers of rocks that are really moving towards the crab (programmatic) rather than the other way around.  But the effect is like the latter.
I place some lobsters on top that would be consumed by an object on top (like a pelican) but I decided to display the score instead.
The thing reminded me of FamCom so I was still that excited.  The GUI is not that user friendly still, you might ask what are the controls and what does that S thing on top behind the number.   I don't plan on making a UX thing for this so figure it out for yourself for now.
Upon hitting anything on the screen moving rocks or brick walls the game would come to a halt.
Well that's it for the game, I initially named it RockLobster that is why the crab is the main character.  I like to name the game to the villain rather than the hero.  so there you have it.

If you're that OC and you want to continue the effort I made. I'll make the code available tomorrow.  I don't want Tiff downloading it before her project submission. :P

Here's the jar file for your use download
If you want the source code, here you go download source code

Learn the damn thing http://www.greenfoot.org/home Enjoy while you're at it!

2 comments: