Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations - 2010.

Slides:



Advertisements
Similar presentations
Game with US Beginner Tutorial. Welcome!! Who I am What is Processing? Basic Coding Input Methods Images Classes Arrays.
Advertisements

RAPTOR Syntax and Semantics By Lt Col Schorsch
Chapter 10 - Additional Scenario Ideas Bruce Chittenden.
Teaching with Greenfoot
Getting to know Greenfoot
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
Written by: Dr. JJ Shepherd
Games and Simulations O-O Programming in Java The Walker School
Program: Little Crab Mr Gano.
Chapter 7 - Collision Detection: Asteroids
Greenfoot Asteroids Mrs. C. Furman August 16, 2010.
Wombats Creating Games with Greenfoot The Walker School – Games and Simulations
Inheritance. Extending Classes It’s possible to create a class by using another as a starting point  i.e. Start with the original class then add methods,
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Cosc 5/4730 Game Design. A short game design primer. A game or animation is built on an animation loop. – Instance variables of “objects” are updated.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
Arrays, Loops weeks 4-6 (change from syllabus for week 6) Chapter 4.
IAT 800 Lecture Oct, Fall 2006IAT 8002 Outline  Programming concepts –Super and this –Java SDK classes Lists Reading the Java docs –Programming.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Copyright 2010 by Pearson Education 1 Assignment 11: Critters.
LO: Learn how to develop your game further to include interactions with the device.
Games and Simulations O-O Programming in Java The Walker School
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Guide to Programming with Python
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
Fruitful functions. Return values The built-in functions we have used, such as abs, pow, int, max, and range, have produced results. Calling each of these.
GREENFOOT CLUB RESOURCES Brian Cullen – Rossett School
Introduction to TouchDevelop
Topic 3 The Stack ADT.
GAME:IT Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Nachos Phase 1 Code -Hints and Comments
Greenfoot. Getting Started Open the Greenfoot download site: Select Greenfoot
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
Description, Classes, Interfaces, Hierarchy, Specifics George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
The while Loop Syntax while (condition) { statements } As long condition is true, the statements in the while loop execute.
Chapter 6 – Interacting Objects: Newton’s Lab. topics: objects interacting with each other, using helper classes, using classes from the Java library.
Chapter 7 – Collision Detection: Asteroids
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Game Maker Terminology
Session 16 Pinball Game Construction Kit:. Pinball Version 1 Replaced the fire button with a mouse event. Multiple balls can be in the air at once. –Uses.
Guide to Programming with Python Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Guide to Programming with Python Week 15 Chapter Twelve Sound, Animation, and Program Development: The Astrocrash Game.
Advanced Stuff Learning by example: Responding to the mouse.
CS100A, Fall 1998 Key Concepts 1 These notes contain short definitions of the basic entities that make up a Java program, along with a description of the.
Lesson 2: Reading a program. Remember: from yesterday We learned about… Precise language is needed to program Actors and Classes Methods – step by step.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Action Script 12 "The games of a people.
Written by: Dr. JJ Shepherd
Game Maker Evil Clutches.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Tank Game Part 2 of 6. Firing Shells Coming up… Players Scores Large Explosions Small Explosions Damage Health Bars Parent Shell Destructible Walls Reappear.
Newton’s Lab Games and Simulations O-O Programming in Java.
The Stingray Example Program CMT3311. Stingray - an example 2D game May be useful as a simple case study Most 2D games need to solve generic problems.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 11 "The games of a people reveal.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
CS100Lecture 61 Announcements Homework P1 due on Thursday Homework P2 handed out.
Chapter 9 - Collision Detection: Asteroids Bruce Chittenden (modified by Jeff Goldstein)
Chapter 5 – Making Music: An On-Screen Piano (Part 1 – Using Loops)
MOM! Phineas and Ferb are … Aims:
Java Programming with BlueJ
Organizing Memory in Java
Games and Simulations O-O Programming in Java The Walker School
Game Loop Update & Draw.
Bishopston Comprehensive School
Presentation transcript:

Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations

Asteroids The Walker School – Games and Simulations Take some time to play with Asteroids. What can the program do and what can’t it do?

Discovering Keyboard Controls The Walker School – Games and Simulations Which keyboard key is used to fire a bullet?

Explosions The Walker School – Games and Simulations Place an explosion into a running scenario. Does it work? What does it do?

Painting Stars The Walker School – Games and Simulations

Create a New Scenario The Walker School – Games and Simulations Directions 1.Create a new scenario. 2.Save it as “asteriods-lastname”.

Create the World The Walker School – Games and Simulations Directions 1.Create a new subClass called “Space”. 2.Leave the background empty.

Enlarge the Background The Walker School – Games and Simulations Directions: 1.Change the size of the world (600, 400, 1). 2.Change the comment.

Painting Backgrounds The Walker School – Games and Simulations Part IV -

Import the Java Color Library The Walker School – Games and Simulations

Use Java to Paint Black Background The Walker School – Games and Simulations

Create a method createStars() The Walker School – Games and Simulations Comment it out until we create the method.

Create a Method Body The Walker School – Games and Simulations Takes a parameter of type integer, as we stated we wanted 300 stars.

Create The Stars The Walker School – Games and Simulations Step through this loop and explain what is happening.

For Loops The Walker School – Games and Simulations for (initialization; loop-condition; increment) { loop-body; } The initialization part declares and initializes a loop variable. This variable is often called i, and often initialized to 0. The loop condition checks whether our loop variable is still less than a given limit. If it is, the loop will continue. The increment section simply increments the loop variable.

Vary Star Brightness The Walker School – Games and Simulations

Rocket Firing The Walker School – Games and Simulations

Turning The Walker School – Games and Simulations

Flying Forward The Walker School – Games and Simulations

Flying Forward The Walker School – Games and Simulations Calls the move() method from SmoothMover class. What happens?

What Do We Need To Do? Add initial movement to the rocket. To add movement, we need to add force to the rocket. And we need to change its vector. So we’ll need to call this vector from the Vector abstract class. The vector needs 2 variables: direction (dy) and length (dx). The Walker School – Games and Simulations So where are we going to do this?

Adding Drift The Walker School – Games and Simulations What happens when you change the variables in the vector?

What Do We Need To Do? Create variables to handle each rocket image. Add a method called ignite to checkKeys(), so that we when hit the “up” button, the rocket image is changed. Define a method called ignite. It will need a boolean parameter and a void return type. The Walker School – Games and Simulations

Create a Method Stub to Ignite Rocket The Walker School – Games and Simulations Remember to create an instance variable called boosterOn.

Igniting the Rocket Boosters The Walker School – Games and Simulations

Colliding with Asteroids The Walker School – Games and Simulations

What Do We Need to Do? If we collide with an asteroid, Remove the rocket from the world; Place an explosion into the world; Show final score (game over); The Walker School – Games and Simulations

Methods for Collision Detection file:///C:/Greenfoot/doc/API/index.html file:///C:/Greenfoot/doc/API/index.html The Walker School – Games and Simulations Both methods accept a parameter of type Class, which means we can check for intersections with a specific class of objects if we want to. Which of these 2 methods do we want to use and why?

Colliding with Asteroids The Walker School – Games and Simulations Remember to call the method in the rocket act() method.

Creating Better Explosions Part I - Part II - Part III - Part IV - Part V The Walker School – Games and Simulations

What Do We Need To Do? Add abstract classes SmoothMover and Vector from Greenfoot. Create a constructor for Debris Update the move() method

Casting The Walker School – Games and Simulations

Create the Score Board The Walker School – Games and Simulations

Import Java Libraries The Walker School – Games and Simulations

Create the Assignment Variables The Walker School – Games and Simulations

Create the Constructors Why are their 2 constructors? How is this an example of overloading? The Walker School – Games and Simulations

Make Scoreboard Image The Walker School – Games and Simulations So, what else needs to be done?

Activity – Change Attributes Modify the ScoreBoard class: – Change the text shown on it. – Change the color of the text. – Change the background and frame colors. – Change the font size so that your text fits well. – Change the width of the scoreboard to suit your text. The Walker School – Games and Simulations

Homework – Scoreboard Search the Greenfoot library for other games that have scoreboards. Study how they were built. What attributes do they have that this board does not? What could you add to your scoreboard? The Walker School – Games and Simulations

Add a Variable for the Counter The Walker School – Games and Simulations

Assign the Counter to the Constructor The Walker School – Games and Simulations

Call the Counter When Game Over The Walker School – Games and Simulations How can you make sure that the counter is in the middle of the board without hard coding the numbers?

Ensure the Scoreboard is in the Middle of the Background The Walker School – Games and Simulations Where do we call the gameOver() method?

Call the Game Over Method The Walker School – Games and Simulations Example of Casting

Casting Casting is the technique of telling the compiler a more precise type for our object then it can work out for itself. We do this by writing the class name (Space) in parentheses before the method call. Once we have done this we can call methods defined in Space space.gameOver(); Casting does not change the type of the object returned. The Walker School – Games and Simulations

Add a Proton Wave What does it do? What doesn’t it do? The Walker School – Games and Simulations

Import the Library The Walker School – Games and Simulations We are going to need the Java List class because we are going to create a list of images to create a proton wave that increases in size.

Assign Variables The Walker School – Games and Simulations How do we make the wave grow?

Add A List (Array) to Store Image Set The Walker School – Games and Simulations How many images will this list store?

Create a Constructer for the Wave The Walker School – Games and Simulations

Create a Method to Initialize Images The Walker School – Games and Simulations

Create a Instance Field to Set Image Count

Create a Method to Initialize Images The Walker School – Games and Simulations Rewrite the While loop using a For loop. What needs to change?

Create a Method Stub to Grow Wave The Walker School – Games and Simulations

Call Method to Grow the Wave The Walker School – Games and Simulations

Add Statements to Grow Wave The Walker School – Games and Simulations Square [] brackets, not curly {} brackets here

Add Sound to the Proton Wave The Walker School – Games and Simulations

Create a Method Stub to Ignite Proton Wave The Walker School – Games and Simulations Where do we create this method?

Call Method When “Z” is Pressed The Walker School – Games and Simulations What is the problem with the proton wave? 1. It can be released too easily! 2. It doesn’t do anything to the asteroids!

Create Reload and Delay for Wave The Walker School – Games and Simulations

Add an Instance Variable for the Delay The Walker School – Games and Simulations Where do we create these variables?

Assign the Delay to the Constructor The Walker School – Games and Simulations

Add Delay Count to act() Method The Walker School – Games and Simulations

Program the Delay into the Wave The Walker School – Games and Simulations

Interacting with Objects in a Range The Walker School – Games and Simulations

Program a Method Stub to Check for Collision The Walker School – Games and Simulations Purpose is to check to see if the wave touches and asteroid. So, in what Class do we create this method?

Call it in the Wave act() Method The Walker School – Games and Simulations

Write Statements to Check for Collision The Walker School – Games and Simulations Why didn’t we use the “getIntersectingObjects() method? Range is the radius of the circle (wave).

hit() Method The Walker School – Games and Simulations What are the parameters for this method and what does it return?

Evaluating the Damage Constant The Walker School – Games and Simulations What happens when you change the damage constant of the proton wave?

For Further Development Fix the score counter. Add new asteroids when all have been cleared. Add a level counter. Every time all asteroids are destroyed you go up a level. Add an end of level sound. Add an indicator showing the load state of the proton wave. Add a shield. The Walker School – Games and Simulations