api board - Office Mix

game development
game development– learning targets
•
•
•
•
I will be able to apply variables in physics app
I will be able to create single sprites
I will be able to write assenting statements
I will be able to design geometric shapes
game development– common core state standards
• Educational Technology
• Language
• Speaking and Listening
1.1 Innovate: Demonstrate creative thinking, construct knowledge and develop
innovative products and processes using technology.
1.3 Investigate and Think Critically: Research, manage and evaluate
information and solve problems using digital tools and resources
2.4 Adapt to Change (Technology Fluency): Transfer current knowledge to new
and emerging technologies
L.11-12.1. Demonstrate command of the conventions of standard English
grammar and usage when writing or speaking.
SL.11-12.5. Make strategic use of digital media (e.g., textual, graphical, audio,
visual, and interactive elements) in presentations to enhance understanding of
findings, reasoning, and evidence and to add interest.
9-12 SYSB Systems thinking can be especially useful in analyzing complex
situations. To be useful, a system needs to be specified as clearly as possible.
9-12 SYSD Systems can be changing or in equilibrium.
• Science
• Math
S-CP.1. Describe events as subsets of a sample space (the set of outcomes)
using characteristics (or categories) of the
outcomes, or as unions, intersections, or complements of other events (“or,”
“and,” “not”).
Reasoning: Unions, intersections and complements of other events are
common items to analyze in a project management plan, looking for
interdependencies in determining project scheduling and deliverable dates.
Project management requires that one be able to analyze those
interdependencies.
board
o
sprite-based
o
objects have speed, gravity,
friction (physics engine)
o
game loop (timer event)
o
touch events on sprites
coordinates and units
(0,0)
o
o
o
origin (0, 0) is top left corner
extent (480,800) is just
outside of bottom right
corner
Y: (up to) 800 pixel
o
positions are based on
pixels
Windows Phone 7 platform
mandates 480x800 screen
resolution
X: 480 pixel
(240,400)
(480,800)
coordinates and units
o
sprite positions refer to center of sprite
(makes rotation easy)
o
speed measured in pixels/second
o
acceleration measured in pixels/second2
demo/exercise: static layout
(0,0)
X: 480 pixel
var board: Board
action main
data->board->create ellipse(20,20)
data->board->post to wall
run script to see static layout
Y: (up to) 800 pixel
data->board := media->create full board
ellipse
+(20,20)
create ellipse
create ellipse(w, h)
o
w is width of
enclosing rectangle
o
h is height
w
h
gravity
o
gravity is property of board
o
Board→set gravity
sets the uniform acceleration vector for objects on the
board to pixels/seconds2
o
sprites are affected when Board→evolve is called
o
typical use of the accelerometer in gameloop:
var p := senses→acceleration quick→scale(800)
◳board→set gravity(p→x, p→y)
demo/exercise: gravity
(0,0)
X: 480 pixel
var board: Board
action main
◳board→create ellipse(20,20)
◳board→post to wall
Y: (up to) 800 pixel
◳board := media→create full board
ellipse
+(20,20)
event game loop
var p := senses→acceleration quick→scale(800)
◳board→set gravity(p→x, p→y)
◳board→evolve
◳board→update on wall
tilt phone to change gravity
Important! Moves things around according
to speed/gravity/friction/…
Important! Makes changes visible
exercise
o
try replacing
var p := senses→acceleration quick→scale(800)
with
var p := senses→acceleration quick→scale(2000)
or
var p := senses→acceleration quick→scale(100)
o
What is the influence of the scaling factor on
the sprite movements?
obstacles
o
by default, board is open, has no boundary; objects
moving off the visual part of the board will simply
continue moving away. Use Board→create boundary to
create reflecting walls around the board
o
use Board→create obstacle(x,y,w,h,elasticity) to create
line obstacle with elasticity:
•
1 means the entire impulse is maintained
•
0 means full absorption of the impulse (a sprite will
stick to the wall).
demo/exercise: boundary
(0,0)
var board: Board
X: 480 pixel
Keep sprites within screen!
action main
◳board→create boundary(0)
◳board→create ellipse(20,20)
◳board→post to wall
Y: (up to) 800 pixel
◳board := media→create full board
ellipse
+(20,20)
event game loop
var p := senses→acceleration quick→scale(800)
◳board→set gravity(p→x, p→y)
◳board→evolve
◳board→update on wall
tilt phone to change gravity
create obstacle
create obstacle(x, y, w, h,
elasticity)
o
(x, y) is upper left
corner
o
obstacle is a
straight line
o
(w, h) is size of
bounding rectangle
(x, y)
h
w
demo/exercise: obstacle
(0,0)
var board: Board
action main
◳board→create boundary(0)
◳board→create obstacle(100,100,50,50,1)
◳board→create ellipse(20,20)
◳board→post to wall
Y: (up to) 800 pixel
◳board := media→create full board
X: 480 pixel
(100,100)
obstacle +(50,50)
ellipse
+(20,20)
event game loop
var p := senses→acceleration quick→scale(800)
◳board→set gravity(p→x, p→y)
◳board→evolve
◳board→update on wall
tilt phone to change gravity
Important! Moves things around according
to speed/gravity/friction/…
Important! Makes changes visible
friction
o
without friction, ball doesn’t slow down
o
set friction:
o
o
•
default setting for entire board
•
custom setting for each sprite
“A friction is the fraction of the forward speed that is
experienced as a backwards force.”
•
friction of 0 corresponds to no friction at all
•
friction of 1 means the sprite will not move at all
example: board→set friction(0.01)
demo/exercise: friction
(0,0)
var board: Board
action main
◳board→create boundary(0)
◳board→create obstacle(100,100,50,50,1)
var ball := ◳board→create ellipse(20,20)
ball→set friction(0.05)
◳board→post to wall
(new code in bold)
Y: (up to) 800 pixel
◳board := media→create full board
X: 480 pixel
(100,100)
obstacle +(50,50)
ellipse
+(20,20)
exercise
o
try replacing
ball→set friction(0.05)
with
ball→set friction(0.95)
or
ball→set friction(0.001)
o
What is the influence of the friction
coefficient on the sprite movements?
testing border
o
is the sprite on the left?
(0,0)
(50,0)
(sprite→ x, sprite→ y)
event gameloop
if sprite->x < 50
then
phone->vibrate(0.1)
(480,800)
exercise
o
is the sprite on the top?
(0,0)
(sprite→ x, sprite→
event gameloop
(0,50)
if ……………………………………………
then
phone->vibrate(0.1)
(480,800)
extra-exercises
o
is the sprite on the left or on the top?
o
is the sprite on the bottom?
o
is the sprite on the right?
o
is the sprite on the any of the sides?
o
is the sprite in the center?
fun with the board
o
change background color
board->set background(colors->random)
o
change sprite color
ball->set color(colors->random)
o
make sprite bigger
ball->set width(200)
ball->set height(400)
testing border
o
is the sprite on the left?
(0,0)
(50,0)
(sprite→ x, sprite→ y)
event gameloop
if sprite->x < 50
then
phone->vibrate(0.1)
(480,800)
testing border
o
is the sprite on the top?
(0,0)
(sprite→ x, sprite→
event gameloop
(0,50)
if ……………………………………………
then
phone->vibrate(0.1)
(480,800)
testing border
o
is the sprite on
(0,0)
the top or bottom?
(sprite→ x, sprite→
(0,50)
event gameloop
if ……………………………………………
then
phone->vibrate(0.1)
(480,800)
exercise
o
create a game where 1 sprite (called
ball)
•
ball moves with the accelerometer
•
ball bounces on the screen boundary
•
ball is red when it is “near” the center of the
screen; otherwise ball is blue
•
ball size increases each time it hits the
screen boundary (+5)
project pitch
o
o
2 min: prepare a 1 minute demo/story why
someone should buy your game.
At each “beep”, pick a new student and
pitch each other’s game. Mark down the
other student’s name and whether you
would pay .99c to buy his game.
Your Name: _____________________
Student’s Name
Buy YES!
Buy NO!