introduction to jam’s video game package

21
Last Edited 1/10/04 CPS4: Java for Video Games http://www.cs.duke.edu/education/courses/spring04/ cps004/calendar.html Video Game Package Intro 1 Introduction to Jam’s Video Game Package

Upload: adelio

Post on 12-Jan-2016

101 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Jam’s Video Game Package. The Plan. Scope of Video Game Package Basic Design of the Video Game Package Steps to making a game How the Pong was made Limitations of the Video Game Package. Scope of the Video Game Package. Goals of Jam’s Video Game Package Simple to use - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 1

Introduction to Jam’sVideo Game Package

Page 2: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 2

The Plan

• Scope of Video Game Package

• Basic Design of the Video Game Package

• Steps to making a game

• How the Pong was made

• Limitations of the Video Game Package

Page 3: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 3

Scope of the Video Game Package

• Goals of Jam’s Video Game Package– Simple to use

– Reasonably fast

– Designed to be examined and modified for academic purposes in computer science courses

• What Jam’s package is not designed for– High speed animation/user input

– Scripting games

– Complex games

Page 4: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 4

Basic Design of theVideo Game Package

AnimationCanvas

Keyboard

Mouse

GameLoopJFrameOr

Applet

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

Page 5: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 5

Basic Design of theVideo Game Package

Tracker

The Tracker is whatMakes the BallSprite move

Page 6: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 6

Basic Design of theVideo Game Package

• Point2D.Double getLocation()

• double getScaleFactor()

• double getRotationAddition()

• void advanceTime()

Tracker

Page 7: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 7

Basic Design of theVideo Game Package

Tracker

Sprite

Page 8: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 8

Basic Design of theVideo Game Package

Has instance variables, and mutator and accessor methods for:

• Shape• Location• Size• Rotation• Color

Tracker

Sprite

Page 9: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 9

Basic Design of theVideo Game Package

AnimationCanvas

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

Page 10: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 10

Basic Design of theVideo Game Package

AnimationCanvasis a JPanel

• with a collection of Sprites

• that paints itself by painting all of its Sprites

AnimationCanvas

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

Page 11: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 11

Basic Design of the

Video Game Package

GameLoop adds:

• animation

• interaction via– Keyboard– Mouse

Keyboard

Mouse

GameLoop AnimationCanvas

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

Page 12: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 12

Basic Design of theVideo Game Package

JFrame or Applet used to:

• Put the game on the screen

• Start the game

• Provide game control

JFrameOr

Applet

Page 13: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 13

Basic Design of theVideo Game Package

AnimationCanvas

Keyboard

Mouse

GameLoopJFrameOr

Applet

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

Page 14: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 14

Steps to Making a Game

1. Extend GameLoop.java– In Constructor

a. Make Spritesb. Make Trackersc. Attach Trackers to Spritesd. Add Sprites to AnimationCanvas

– In advanceFrame provide game logic

2. Make a JFrame or Applet3. Add extended GameLoop to JFrame or Applet4. setFrameRate to start the game

Page 15: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 15

Basic Design of theVideo Game Package

AnimationCanvas

Keyboard

Mouse

GameLoopJFrameOr

Applet

Tracker

Sprite

Tracker

Sprite

Tracker

Sprite

1. Extend GameLoop.java

– In Constructora. Make Spritesb. Make Trackersc. Attach Trackers to Spritesd. Add Sprites to AnimationCanvas

– In advanceFrame provide game logic

2. Make a JFrame or Applet3. Add extended GameLoop to JFrame or Applet4. setFrameRate to start the game

Page 16: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 16

How Pong was Made

1. BallSprite was written to extend Sprite

2. WallSprite was written to extend Sprite

3. ProjectileTracker was written to implement a Tracker

4. PongLoop was written to extend GameLoop

5. Pong was written to use PongLoop

Page 17: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 17

How Pong was Made

Some of the more complex parts of Pong that we’ll talk about in more detail later:

• Loops• Conditionals• Event handling• Inheritance & Interfaces• Collections• Collision detection

Page 18: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 18

How Pong was Made

What you will need to know shortly:• Basic classes in the package• Basic structure of the package• Basic steps to making the game• General idea about how Pong.java and

PongLoop.java work• Enough familiarity to make minor

modifications to BallSprite and PongLoop

Page 19: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 19

How Pong was Made

What you don’t need to understand yet:

• All of the classes in the package

• All of the code in the basic classes

• How to make your own classes like Pong and PongLoop from scratch

Page 20: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 20

How Pong was Made

What you’ll be doing in the next homework: (in addition to problems from Big Java)

• Altering BallSprite

• Altering ProjectileTracker

…and it will be fun (when it works)

Page 21: Introduction to Jam’s Video Game Package

Last Edited 1/10/04 CPS4: Java for Video Gameshttp://www.cs.duke.edu/education/courses/spring04/cps004/calendar.html

Video Game Package Intro 21

How Pong was Made

Let’s take a look at two classes:

1. Open up a web browser

2. Go to the course website and download pong.jar to the desktop (from code link)

3. Open up Eclipse

4. Import pong.jar

5. Look in tipgame for BallSprite.java

6. Look in tipgame for ProjectileTracker.java