Creative Greenfoot
eBook - ePub

Creative Greenfoot

Michael Haungs

Share book
  1. 310 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Creative Greenfoot

Michael Haungs

Book details
Book preview
Table of contents
Citations

About This Book

About This Book

  • Apply a wide variety of game design and programming animation techniques to create immersive interactive applications that use state-of-the-art controllers and input devices
  • Quickly learn key concepts in animation, physics, and artificial intelligence to jump-start your journey into creative computing
  • Gain a deep understanding of interactive development by working systematically from concept to design with several engaging example applications

Who This Book Is For

This book is for coding students and Java programmers of all levels interested in building engaging, interactive applications with Greenfoot. Familiarity with the very basics of Greenfoot is assumed.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Creative Greenfoot an online PDF/ePUB?
Yes, you can access Creative Greenfoot by Michael Haungs in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation en Java. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781783980390

Creative Greenfoot


Table of Contents

Creative Greenfoot
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Let's Dive Right in

The Avoider Game tutorial
Basic game elements
Creating a scenario
Creating our world
Creating our hero
What have we just done?
Adding our hero
Using the mouse as a game controller
Creating the followMouse function
Breaking down the code
Adding enemies
Enemy code
Creating an army
Unbounding the world
Memory management
Your assignment
Next

Making it a game
Detecting collisions
Adding a game-over screen
Switching scenes
Adding a "play again" button
Adding an introduction screen
Setting the initial screen
Adding a "play" button
Adding background music
Writing the music code
Analyzing the music code
Stop the music
Your assignment
Next

Enhancing playability
Game scoring
Adding the Counter class
Increasing the score over time
Adding levels
Increasing spawn rates and enemy speed
Increasing difficulty based on the score
Implementing enemy speed increases
Your assignment
Next

Summary
2. Animation
Revisiting Avoider Game
Image swapping and movement
Using setImage()
Making enemies less happy
Finding assets
Calling setImage() based on Actor location
Using setLocation()
Creating a star field
A blank slate
The Star class
Creating a moving field
Using parallax
Using GreenfootImage
Timing and synchronization
Delay variables
Hurting the avatar
Random actions
Blinking
Triggered events
Adding eyes
Giving our hero sight
Easing
Power-ups and power-downs
Base class
Linear easing
Exponential easing
Sinusoidal easing
Changes to the Avatar class
Changes to the AvoiderWorld class
Avoider Game
Your assignment
Summary
3. Collision Detection
ZombieInvasion interactive simulation
Dynamically creating actors in ZombieInvasionWorld
Creating obstacles
Creating our main actor framework
Creating an explosion
Test it out
Built-in collision detection methods
Detecting a collision with a single object
isTouching() and removeTouching()
Detecting a collision with multiple objects
Detecting multiple objects in range
Time to test it out
Border-based collision detection methods
Detecting single-object collisions at an offset
Detecting multiple-object collisions at an offset
Hidden-sprite collision detection methods
Challenge
Summary
4. Projectiles
Cupcake Counter
How to play
Implementing Cupcake Counter
The CupcakeWorld class
Enemies
Fountains
Turrets
Rewards
Jumpers
Platforms
Test it out
Your assignment
Launching actors
Gravity and jumping
Bouncing
Particle effects
Bullets and turrets
Your assignment
Challenge
Summary
5. Interactive Application Design and Theory
Meaningful play
Complexity
Goals
User conditioning
Storytelling
Fictional worlds
Narrative descriptors
The interactive entertainment iterative development process
Game pitch and initial design
Prototype
Playtest
Evaluation
Refinement
Benefits
Avoider Game
Avoider Game recap
High-score list
Achievement badges
Player conditioning
Storytelling
Adding a story screen
Changing the score
Adding sound effects
Playtesting
Challenge
Additional readings
Summary
6. Scrolling and Mapped Worlds
Chapter scenario examples
Dynamically generated worlds
Side-scrolling
The Rocket class
The CloudsWorld class
Side-scrolling actors
Clouds
Walls
Try it out
Mapped worlds
Side-scrolling
The HikingWorld class
The Hiker class
The ScrollingActor class
Try it out
2D scrolling
The HikingWorld2D class
The Hiker class
The ScrollingActor class
Try it out
Tile-based worlds
Actors as tiles
The HikingWorld class
The Hiker class
The ScrollingActor class
Tiles
The Lake class
Try it out
Other game sprites
Summary
7. Artificial Intelligence
The MazeWorld scenario
The MazeWorld class
The Hiker class
Scrolling actor
The ScrollingObstacle class
Intelligently behaving actors
The ScrollingEnemy class
Randomness
Spider
Behavior heuristics
The Snake class
A* pathfinding
Overview
Algorithm
The Mouse class
Play test
Summary
8. User Interfaces
UIWorld
The Button class
The TextBox class
The Menu class
Heads-up display
Adding a UI to MazeWorld
Adding menus and buttons
Adding a HUD
Implementing game difficulty settings and HUD controls
Summary
9. Gamepads in Greenfoot
Gamepad overview
Windows setup
Connecting your controller
Greenfoot gamepad software
The Greenfoot Gamepad API
Overview
The GamePad and Direction classes
Avoider Game with Gamepad
Try it out
OS X setup/workarounds
Gamepad mapper software
Exporting games with gamepads
Summary
10. What to Dive into Next

Build something larger
Share your work
Publishing on Greenfoot.org
Desktop application
Exporting as a web page
Explore other input devices
Learn more Java
Summary
Index

Creative Greenfoot

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: April 2015
Production reference: 1230415
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-038-3
www.packtpub.com

Credits

Author
Michael Haungs
Reviewers
Thomas Cooper
Keenan Gebze
Foaad Khosmood
Kevin Rowan
Commissioning Editor
Sam Wood
Acquisition Editor
Sam Wood
Content Development Editor
Ar...

Table of contents