Sonntag, 23. August 2015

Hoppy Beaver and the squid

... or why you cannot increase counters based on conditions which are based on ranges.
About a month ago, I tried for the Intro to JS class at Khan Academy and was surprised how much fun it was actually. First, I was a little sceptical about the approach the class took.
What was this Processing JS and what were those functions like draw() doing there?
But slowly I became friends with the class and then a fan. Why? Because I liked the video guidance, I liked the challenges, they were a pleasure to follow and I also felt that the difficulty was slowly increased so chances were you would not fall behind.
The following class was about Games and Visualizations. With the already present knowledge of Javascript and Processing JS, a game was built.

I must admit that I liked the video guided classes in the Intro to JS course better than having to read a text, as the texts are quite long and I find it easier to listen and repeat.

Then, the challenge at the end of the Hoppy Beaver section was to change the game in some way.

I decided for enemies and for holes. First. I later dropped the holes, because I could not seem to manage to decrease the score when the beaver walks over a hole instead of jumping over it,

The same problem occurred for the enemies. I tried to define a hit with the enemy through determining whether the beaver was within a certain range from the x and y coordinates from the enemy. I then tried to increase the score, but the score++ then happened as long as the beaver was within that range.

What DID work was the defining of good and bad sticks. 

First, I made sure the Stick object had a third attribute "bad".

Then, I made this bad be a randomly generated number from 1 to 4. Number 2 would be bad and in a different colour. If the beaver catches them, the score decreases.

You can have a look at the project here:

Keine Kommentare:

Kommentar veröffentlichen