"It does not matter how slowly you go as long as you do not stop." | ||
--Confucius |
In this chapter, you will build a simple game where the player controls a character using the mouse to try to avoid oncoming enemies. As the game progresses, the enemies become harder to avoid. This game contains many of the basic elements needed to create interactive Greenfoot applications. Specifically, in this chapter, you will learn how to:
Create introduction and game-over screens
Display a user score
Use the mouse to control the movement of an actor
Play background music
Dynamically spawn enemies and remove them when appropriate
Create game levels
Throughout this chapter, we'll learn basic programming concepts and gain familiarity with the Greenfoot development environment. As you proceed, think about the concepts presented and how you would use them in your own projects. If you are new to Java, or it's been a while since you've programmed in Java, be sure to take the time to look up things that may be confusing to you. Java is a well-established programming language, and there are endless online resources you can consult. Similarly, this book assumes a minimal understanding of Greenfoot. Be sure to look at the simple tutorials and documentation at www.greenfoot.org when needed. Experiment with the code and try new things—you'll be glad you did. In other words, follow the advice of Confucius, quoted in the first line of this chapter.
Many of the chapters in this book are independent; however, most are dependent on this chapter. This chapter provides the framework to create Greenfoot applications that we will continue to use, and refer to, in later chapters.