![]() ![]() BlueJ also comes in a generic form: packaged as a JAR file so that BlueJ can be installed on any system that supports Java. When Java appeared, the tool was rebuilt using Java as the language and the name was changed to BlueJ.Įditions of BlueJ exist for Linux, MacOS, and Windows. At that time, it was both a development environment and a language. Learn Java with BlueJīlueJ first appeared in 1999, named simply Blue. Consequently, both provide an easy introduction not only to the Java language, but to the tools and techniques needed to build applications in that language. In fact, as Neil Brown, the lead developer explains, BlueJ’s and Greenfoot’s features are “.revealed as users come to them.” You are not thrown into the deep end of the pool. The creators of BlueJ and Greenfoot selected the feature set and interface design to not overwhelm beginners. ![]() They are the product of a team based at King’s College in London (though team members have, at times, been affiliated with universities in Australia and Denmark). Your chosen development tool is as impenetrable as the language it’s supposed to help you with.Įnter BlueJ and Greenfoot, two IDEs very specifically designed for beginners. You choose one, download and install it, and in a very short time you realize that you now have two things to learn: Java and the IDE. ![]() Several popular, free Java IDEs are available: Eclipse, NetBeans, and the community edition of IntelliJ, for example. ![]() A single application in which you can edit, build, run, debug, and deploy your soon-to-be-written Java application. Ok, first things first: You need one of those integrated development environments (IDEs) you’ve read about. But, you take a deep breath and resolve to give it a go. It might even seem impenetrable if you’re a new programmer. You can play with the finished game (including a couple of simple AI players) over on the Greenfoot site.You say you want to learn Java. The 8000 in the last line is simply the volume of the sound (the height of the sine wave). The 0.25 and the 3200 on the middle line of the loop adjust the amount that the height of the projectile affects the frequency of the sine wave. There are three constants in this code that I fiddled with until they sounded right (literally!). Here’s some code that does just that, using the height calculation from our previous post:įor (int i = 0 i < soundWave.length i++)ĭouble t = (double)i / (timePerFrame * 44000.0) Ī += 0.25 + (t * vy - 0.5 * g * t * (t - 1)) / 3200.0 What this means is that instead of using a steadily-increasing number to feed to the sine wave function, you increase the number faster when the banana is higher. The gist is something like this - the sine wave gets more frequent (the peaks get closer together, horizontally), the higher the projectile is in the air: This creates a more familiar flight sound (such as you hear in cartoons). If we change the frequency in proportion to the height of the banana, we get a sound that starts low, increases in pitch as the banana reaches the apex of its flight, then decreases again as it comes back down. We can greatly improve the suitability of the sound if we vary the frequency of the sine wave during the flight. Just playing a simple sine wave for the sound of the flight is dull and incongruous. I subtract 5 frames off the total, to make sure that the sound is finished before we need to play the impact sound. The length of the sound in seconds will be the time it takes to execute one frame in Greenfoot, multiplied by the number of frames before impact (“impactTime”, above - which we saw how to calculate last post). The sound will play at 44000 samples per second, so we need to multiply the number of seconds by 44000 to get the number of samples. We can use this information to construct a sound that’s exactly as long as the time the banana will spend in the air:ĭouble lengthInSecs = timePerFrame * (impactTime - 5) We saw in our last post that for our monkeys-throwing-bananas game, we can work out how long the banana will be in flight for. Here’s an example of a sine wave on youtube. If you treat this as a sound wave, then you get a dull tone that we recognise as an electronic beep, since it’s used so often by electronic devices. If you take an ever increasing number and pass it to the sine function, you get back this graph: As well as being useful for working with triangles, the sine function can also be used for generating sounds. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |