You are previewing Creative Greenfoot.
O'Reilly logo
Creative Greenfoot

Book Description

Build engaging interactive applications, games, and simulations using Java and Greenfoot

In Detail

The worlds of computers and art are merging in new and complex ways. Greenfoot is designed to ease the transition into this immerging field, allowing for the easy development of two-dimensional graphical applications, such as simulations and interactive games.

This book provides you with the knowledge and processes necessary to create engaging interactive applications in Greenfoot. It systematically covers essential technologies and algorithms used in creative programming, such as collision detection, easing, and particle effects. You will not only learn to use best practices, but also learn about how these practices were developed and how to augment them to suit your individual needs. After learning the ins and outs of designing and implementing interactive applications, you will see how to interface gamepad controllers to provide an unparalleled immersive experience.

The book will take you through the advanced, creative, and engaging functions of Greenfoot while teaching object-orientated Java.

What You Will Learn

  • Use various methods of animation to breathe life into all aspects of a game or simulation

  • Evaluate the different methods of collision detection and choose the right method for the task at hand

  • Design and implement scrolling and mapped environments

  • Incorporate simple techniques to give the illusion of intelligence to actors in Greenfoot scenarios

  • Create user-friendly and intuitive user interfaces

  • Heighten the user's experience by providing gamepad support for your Greenfoot scenarios

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Creative Greenfoot
      1. Table of Contents
      2. Creative Greenfoot
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      8. 1. Let's Dive Right in…
        1. The Avoider Game tutorial
        2. Basic game elements
          1. Creating a scenario
            1. Creating our world
            2. Creating our hero
            3. What have we just done?
            4. Adding our hero
            5. Using the mouse as a game controller
              1. Creating the followMouse function
              2. Breaking down the code
            6. Adding enemies
              1. Enemy code
              2. Creating an army
            7. Unbounding the world
            8. Memory management
            9. Your assignment
              1. Next…
          2. Making it a game
            1. Detecting collisions
            2. Adding a game-over screen
              1. Switching scenes
              2. Adding a "play again" button
            3. Adding an introduction screen
              1. Setting the initial screen
              2. Adding a "play" button
            4. Adding background music
              1. Writing the music code
              2. Analyzing the music code
              3. Stop the music
            5. Your assignment
            6. Next…
          3. Enhancing playability
            1. Game scoring
              1. Adding the Counter class
              2. Increasing the score over time
            2. Adding levels
              1. Increasing spawn rates and enemy speed
              2. Increasing difficulty based on the score
              3. Implementing enemy speed increases
            3. Your assignment
            4. Next…
        3. Summary
      9. 2. Animation
        1. Revisiting Avoider Game
        2. Image swapping and movement
          1. Using setImage()
            1. Making enemies less happy
              1. Finding assets
              2. Calling setImage() based on Actor location
          2. Using setLocation()
            1. Creating a star field
              1. A blank slate
              2. The Star class
              3. Creating a moving field
              4. Using parallax
              5. Using GreenfootImage
        3. Timing and synchronization
          1. Delay variables
            1. Hurting the avatar
          2. Random actions
            1. Blinking
          3. Triggered events
            1. Adding eyes
            2. Giving our hero sight
        4. Easing
          1. Power-ups and power-downs
            1. Base class
            2. Linear easing
            3. Exponential easing
            4. Sinusoidal easing
            5. Changes to the Avatar class
            6. Changes to the AvoiderWorld class
        5. Avoider Game
        6. Your assignment
        7. Summary
      10. 3. Collision Detection
        1. ZombieInvasion interactive simulation
          1. Dynamically creating actors in ZombieInvasionWorld
          2. Creating obstacles
          3. Creating our main actor framework
          4. Creating an explosion
          5. Test it out
        2. Built-in collision detection methods
          1. Detecting a collision with a single object
            1. isTouching() and removeTouching()
          2. Detecting a collision with multiple objects
          3. Detecting multiple objects in range
          4. Time to test it out
        3. Border-based collision detection methods
          1. Detecting single-object collisions at an offset
          2. Detecting multiple-object collisions at an offset
        4. Hidden-sprite collision detection methods
        5. Challenge
        6. Summary
      11. 4. Projectiles
        1. Cupcake Counter
          1. How to play
          2. Implementing Cupcake Counter
          3. The CupcakeWorld class
          4. Enemies
          5. Fountains
          6. Turrets
          7. Rewards
          8. Jumpers
          9. Platforms
          10. Test it out
          11. Your assignment
        2. Launching actors
          1. Gravity and jumping
          2. Bouncing
          3. Particle effects
          4. Bullets and turrets
          5. Your assignment
        3. Challenge
        4. Summary
      12. 5. Interactive Application Design and Theory
        1. Meaningful play
          1. Complexity
          2. Goals
        2. User conditioning
        3. Storytelling
          1. Fictional worlds
          2. Narrative descriptors
        4. The interactive entertainment iterative development process
          1. Game pitch and initial design
          2. Prototype
          3. Playtest
          4. Evaluation
          5. Refinement
          6. Benefits
        5. Avoider Game
          1. Avoider Game recap
          2. High-score list
          3. Achievement badges
          4. Player conditioning
          5. Storytelling
            1. Adding a story screen
            2. Changing the score
            3. Adding sound effects
          6. Playtesting
        6. Challenge
        7. Additional readings
        8. Summary
      13. 6. Scrolling and Mapped Worlds
        1. Chapter scenario examples
        2. Dynamically generated worlds
          1. Side-scrolling
            1. The Rocket class
            2. The CloudsWorld class
            3. Side-scrolling actors
              1. Clouds
              2. Walls
            4. Try it out
        3. Mapped worlds
          1. Side-scrolling
            1. The HikingWorld class
            2. The Hiker class
            3. The ScrollingActor class
            4. Try it out
          2. 2D scrolling
            1. The HikingWorld2D class
            2. The Hiker class
            3. The ScrollingActor class
            4. Try it out
        4. Tile-based worlds
          1. Actors as tiles
            1. The HikingWorld class
            2. The Hiker class
            3. The ScrollingActor class
              1. Tiles
              2. The Lake class
              3. Try it out
          2. Other game sprites
        5. Summary
      14. 7. Artificial Intelligence
        1. The MazeWorld scenario
          1. The MazeWorld class
          2. The Hiker class
          3. Scrolling actor
            1. The ScrollingObstacle class
        2. Intelligently behaving actors
          1. The ScrollingEnemy class
          2. Randomness
            1. Spider
          3. Behavior heuristics
            1. The Snake class
          4. A* pathfinding
            1. Overview
            2. Algorithm
            3. The Mouse class
          5. Play test
        3. Summary
      15. 8. User Interfaces
        1. UIWorld
          1. The Button class
          2. The TextBox class
          3. The Menu class
          4. Heads-up display
        2. Adding a UI to MazeWorld
        3. Adding menus and buttons
        4. Adding a HUD
        5. Implementing game difficulty settings and HUD controls
        6. Summary
      16. 9. Gamepads in Greenfoot
        1. Gamepad overview
        2. Windows setup
          1. Connecting your controller
          2. Greenfoot gamepad software
        3. The Greenfoot Gamepad API
          1. Overview
          2. The GamePad and Direction classes
        4. Avoider Game with Gamepad
          1. Try it out
        5. OS X setup/workarounds
          1. Gamepad mapper software
        6. Exporting games with gamepads
        7. Summary
      17. 10. What to Dive into Next…
        1. Build something larger
        2. Share your work
          1. Publishing on Greenfoot.org
          2. Desktop application
          3. Exporting as a web page
        3. Explore other input devices
        4. Learn more Java
        5. Summary
      18. Index