presenter: (mike, rob, etc.) readings: (link to the game’s design doc?) java & spacesmasher...

22
Presenter: (Mike, Rob, etc.) Readings: (link to the game’s design doc?) Java & SpaceSmasher Version: “Some witty game quote here” Repetition & Real-time Simulations

Upload: jalyn-slingsby

Post on 14-Dec-2015

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Presenter: (Mike, Rob, etc.) Readings: (link to the game’s design doc?) Java & SpaceSmasher Version:

“Some witty game quote here”

Repetition & Real-time Simulations

Page 2: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Soon we’ll switch software simulations, but

this time we’ll reuse our familiar SpaceSmasher environment

Demo

SpaceSmasher V2

Page 3: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Understanding & practice with:

A Single While Loop A Single For Loop Translating For Loops to While Loops

And vice-versa TBAWhile Loops with Multiple ConditionsTBA

<booleanExpressionA> && <booleanExpressionB> <booleanExpressionA> || <booleanExpressionB>

Nesting loops inside loops with For Mixing nested For and While Loops

Lab Goals & Outcomes

Page 4: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

SpaceSmasher is a complex but exciting environment!

Outcomes are similar to a typical CS1 class, but with different: Pros

Examples Content Motivation

Cons Setup Length Complexity

Game Lab Pros & Cons

Page 5: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

An even more fully-featured SpaceSmasher

game When compared to the if statement lab

The first step is to read the lab We’ll start together on TODO1

At the End of Lab

Page 6: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

For & While Flowchart

Should we make another row of blocks? True

False

addFireBlock()addIceBlock()

Start

End

Page 7: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

For & While Flowchart

Should we make another row of blocks? True

False

addFireBlock()addIceBlock()

Page 8: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Sequential Loops Flowchart

Page 9: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Sequential Loops Flowchart

• Loops here are not logically related to one another• In other words, they’re not nested or

related in any way• If one loop fails to execute due to the loop

condition evaluating to false, this affects no other loops

• A set of loops that each must be evaluated• And if one is skipped, this has no bearing

on the other loops.• Contrast this behavior to Nested Loops

Page 10: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Loops Inside Loops (Nested)

Page 11: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Also called Nested

Loops for(…) { //outer loop

//outer loop code //which includes //an inner loop for(…) { //inner loop //inner loop code }

}

Loops Inside Loops (Nested)

Note that if the outer loop’s condition is initially false: You never do any part of the

outer loop, including the inner loop!

Page 12: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

INSERT CLICKER QUESTION

Page 13: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

• TBAWhich of the following are true regarding Sequential IFs?

• Which of the following are true regarding Chained IF/ELSEs?

Single, Sequential Loops Versus Nested Loops

Page 14: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Paddles don’t work

No keyboard support for movement No mouse support for movement

Spawning only No collision support They do change when an upgrade block is hit

Balls don’t work They pass right through the paddle They don’t change with the paddle

To an IceBall or FireBall

TBAIn The Beginning…

Page 15: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

First, we’ll add keyboard support

This should spawn balls just like the left mouse button (TODO1 Single IF)

And, the left and right keys should move the paddle (TODO2 Single IF)

Then, we’ll add mouse support for left & right (TODO3 Chained IF)

Next, we’ll fix the issue regarding paddle and ball collisions (TODO 0)

TBALab Activities

Page 16: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

We’ll refactor some existing code using &&

(TODO4) To make it shorter and clearer

Then reduce a different code segment using || (TODO5)

Finally, we’ll fix the ball so it turns to an IceBall if the paddle is ice (TODO6)** And a FireBall if the paddle is fire

Lab Activities Continued

Page 17: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Variables & Methods

Page 18: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

An even more complete SpaceSmasher

experience

Start by reading the lab We’ll start together on TODO1 in 10 minutes

Look at the EXAMPLES for code samples

At the End…

Page 19: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

Once the lab is complete, look at the

assignment. What about a version of this game that TBA Or, what about a version of this game that TBA

Building BetterVersions of SmaceSmasher

Page 20: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

tba

SpaceSmasher Assignment

Page 21: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

tba

SpaceSmasher Assignment

Page 22: Presenter: (Mike, Rob, etc.)  Readings: (link to the game’s design doc?)  Java & SpaceSmasher Version:  “Some witty game quote here” Repetition

tba

SpaceSmasher Assignment