presenter: (mike, rob, etc.) readings: (link to the game’s design doc?) java & spacesmasher...
TRANSCRIPT
Presenter: (Mike, Rob, etc.) Readings: (link to the game’s design doc?) Java & SpaceSmasher Version:
“Some witty game quote here”
Repetition & Real-time Simulations
Soon we’ll switch software simulations, but
this time we’ll reuse our familiar SpaceSmasher environment
Demo
SpaceSmasher V2
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
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
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
For & While Flowchart
Should we make another row of blocks? True
False
addFireBlock()addIceBlock()
Start
End
For & While Flowchart
Should we make another row of blocks? True
False
addFireBlock()addIceBlock()
Sequential Loops Flowchart
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
Loops Inside Loops (Nested)
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!
INSERT CLICKER QUESTION
• 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
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…
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
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
Variables & Methods
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…
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
tba
SpaceSmasher Assignment
tba
SpaceSmasher Assignment
tba
SpaceSmasher Assignment