java programming session 2. objectives to design a range of different blocks to create the code for...

7
Java Programming Session 2

Upload: gavin-richards

Post on 28-Mar-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Java Programming

Session 2

Page 2: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Objectives

• To design a range of different ‘blocks’

• To create the code for these blocks

• To test that each block rotates correctly

• To alter the code to select random blocks

Page 3: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Block Rotation 1

piece_Toppiece_Leftpiece_Bottompiece_Right

Page 4: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Block Rotation 2

piece_Toppiece_Leftpiece_Bottompiece_Right

Page 5: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Block Coding

piece_Top { BLUE , BLUE , NONE }, { BLUE , NONE , NONE }, { BLUE , NONE , NONE }

piece_Left { BLUE , BLUE , BLUE }, { NONE , NONE , BLUE }, { NONE , NONE , NONE }

piece_Bottom { NONE , NONE , BLUE }, { NONE , NONE , BLUE }, { NONE , BLUE , BLUE }

piece_Right { NONE , NONE , NONE }, { BLUE , NONE , NONE }, { BLUE , BLUE , BLUE }

Page 6: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Fitting Blocks Together

Remember that the shapes you make must fit together without leaving gaps

Some shapes are more difficult to fit together than others

Don’t make a shape that will be impossible for the person playing the game

Page 7: Java Programming Session 2. Objectives To design a range of different blocks To create the code for these blocks To test that each block rotates correctly

Tasks:

• Design a piece

• Modify the code

• Test the piece rotates well

• Keep doing this until you have lots of good pieces.

• Switch to random piece generation and try it out.